diff --git a/src/app/auth/components/features/followList.tsx b/src/app/auth/components/features/followList.tsx index 769c1f520..03a7c29f4 100644 --- a/src/app/auth/components/features/followList.tsx +++ b/src/app/auth/components/features/followList.tsx @@ -13,21 +13,13 @@ export function FollowList() { queryKey: ['follows'], queryFn: async () => { const user = ndk.getUser({ pubkey: db.account.pubkey }); - const follows = await user.follows(); - const followsAsArr = []; - - follows.forEach((user) => { - followsAsArr.push(user.pubkey); - }); + const follows = [...(await user.follows())].map((user) => user.pubkey); // update db - await db.updateAccount('follows', JSON.stringify(followsAsArr)); - await db.updateAccount('circles', JSON.stringify(followsAsArr)); - - db.account.follows = followsAsArr; - db.account.circles = followsAsArr; + await db.updateAccount('follows', JSON.stringify(follows)); + db.account.follows = follows; - return followsAsArr; + return follows; }, refetchOnWindowFocus: false, }); diff --git a/src/libs/storage/instance.ts b/src/libs/storage/instance.ts index 23b184029..200b02a38 100644 --- a/src/libs/storage/instance.ts +++ b/src/libs/storage/instance.ts @@ -451,7 +451,7 @@ export class LumeStorage { } public async createSetting(key: string, value: string) { - const currentSetting = await this.getSettingValue(key); + const currentSetting = await this.checkSettingValue(key); if (!currentSetting) return await this.db.execute( @@ -475,6 +475,15 @@ export class LumeStorage { return results; } + public async checkSettingValue(key: string) { + const results: { key: string; value: string }[] = await this.db.select( + 'SELECT * FROM settings WHERE key = $1 ORDER BY id DESC LIMIT 1;', + [key] + ); + if (!results.length) return false; + return results[0].value; + } + public async getSettingValue(key: string) { const results: { key: string; value: string }[] = await this.db.select( 'SELECT * FROM settings WHERE key = $1 ORDER BY id DESC LIMIT 1;', diff --git a/src/shared/titleBar.tsx b/src/shared/titleBar.tsx index 36575caed..fa038ffd3 100644 --- a/src/shared/titleBar.tsx +++ b/src/shared/titleBar.tsx @@ -33,13 +33,13 @@ export function TitleBar({