add mention to composer

This commit is contained in:
Ren Amamiya
2023-07-21 18:07:17 +07:00
parent 64cd17389d
commit 17d2a8cb56
11 changed files with 250 additions and 183 deletions

View File

@@ -2,7 +2,7 @@ import destr from 'destr';
import Database from 'tauri-plugin-sql-api';
import { getParentID } from '@utils/transform';
import { Account, Block, Chats, LumeEvent, Settings } from '@utils/types';
import { Account, Block, Chats, LumeEvent, Profile, Settings } from '@utils/types';
let db: null | Database = null;
@@ -451,7 +451,20 @@ export async function createMetadata(id: string, pubkey: string, content: string
);
}
// get metadata
export async function getAllMetadata() {
const db = await connect();
const result: LumeEvent[] = await db.select(`SELECT * FROM metadata;`);
const users: Profile[] = result.map((el) => {
const profile: Profile = destr(el.content);
return {
pubkey: el.pubkey,
ident: profile.name || profile.display_name || profile.username,
};
});
return users;
}
// get user metadata
export async function getUserMetadata(pubkey: string) {
const db = await connect();
const result = await db.select(`SELECT * FROM metadata WHERE pubkey = "${pubkey}";`);