clean up
This commit is contained in:
@@ -13,21 +13,13 @@ export function FollowList() {
|
|||||||
queryKey: ['follows'],
|
queryKey: ['follows'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const user = ndk.getUser({ pubkey: db.account.pubkey });
|
const user = ndk.getUser({ pubkey: db.account.pubkey });
|
||||||
const follows = await user.follows();
|
const follows = [...(await user.follows())].map((user) => user.pubkey);
|
||||||
const followsAsArr = [];
|
|
||||||
|
|
||||||
follows.forEach((user) => {
|
|
||||||
followsAsArr.push(user.pubkey);
|
|
||||||
});
|
|
||||||
|
|
||||||
// update db
|
// update db
|
||||||
await db.updateAccount('follows', JSON.stringify(followsAsArr));
|
await db.updateAccount('follows', JSON.stringify(follows));
|
||||||
await db.updateAccount('circles', JSON.stringify(followsAsArr));
|
db.account.follows = follows;
|
||||||
|
|
||||||
db.account.follows = followsAsArr;
|
return follows;
|
||||||
db.account.circles = followsAsArr;
|
|
||||||
|
|
||||||
return followsAsArr;
|
|
||||||
},
|
},
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -451,7 +451,7 @@ export class LumeStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async createSetting(key: string, value: string) {
|
public async createSetting(key: string, value: string) {
|
||||||
const currentSetting = await this.getSettingValue(key);
|
const currentSetting = await this.checkSettingValue(key);
|
||||||
|
|
||||||
if (!currentSetting)
|
if (!currentSetting)
|
||||||
return await this.db.execute(
|
return await this.db.execute(
|
||||||
@@ -475,6 +475,15 @@ export class LumeStorage {
|
|||||||
return results;
|
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) {
|
public async getSettingValue(key: string) {
|
||||||
const results: { key: string; value: string }[] = await this.db.select(
|
const results: { key: string; value: string }[] = await this.db.select(
|
||||||
'SELECT * FROM settings WHERE key = $1 ORDER BY id DESC LIMIT 1;',
|
'SELECT * FROM settings WHERE key = $1 ORDER BY id DESC LIMIT 1;',
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ export function TitleBar({
|
|||||||
<div className="col-span-1 flex justify-center">
|
<div className="col-span-1 flex justify-center">
|
||||||
{id === '9999' ? (
|
{id === '9999' ? (
|
||||||
<div className="isolate flex -space-x-2">
|
<div className="isolate flex -space-x-2">
|
||||||
{db.account.circles
|
{db.account.follows
|
||||||
?.slice(0, 8)
|
?.slice(0, 8)
|
||||||
.map((item) => <User key={item} pubkey={item} variant="ministacked" />)}
|
.map((item) => <User key={item} pubkey={item} variant="ministacked" />)}
|
||||||
{db.account.circles?.length > 8 ? (
|
{db.account.follows?.length > 8 ? (
|
||||||
<div className="inline-flex h-6 w-6 items-center justify-center rounded-full bg-neutral-300 text-neutral-900 ring-1 ring-white dark:bg-neutral-700 dark:text-neutral-100 dark:ring-black">
|
<div className="inline-flex h-6 w-6 items-center justify-center rounded-full bg-neutral-300 text-neutral-900 ring-1 ring-white dark:bg-neutral-700 dark:text-neutral-100 dark:ring-black">
|
||||||
<span className="text-[8px] font-medium">
|
<span className="text-[8px] font-medium">
|
||||||
+{db.account.circles?.length - 8}
|
+{db.account.follows?.length - 8}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export function ArticleWidget({ widget }: { widget: Widget }) {
|
|||||||
} else {
|
} else {
|
||||||
filter = {
|
filter = {
|
||||||
kinds: [NDKKind.Article],
|
kinds: [NDKKind.Article],
|
||||||
authors: db.account.circles,
|
authors: db.account.follows,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export function FileWidget({ widget }: { widget: Widget }) {
|
|||||||
} else {
|
} else {
|
||||||
filter = {
|
filter = {
|
||||||
kinds: [1063],
|
kinds: [1063],
|
||||||
authors: db.account.circles,
|
authors: db.account.follows,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export function NewsfeedWidget() {
|
|||||||
relayUrls,
|
relayUrls,
|
||||||
{
|
{
|
||||||
kinds: [NDKKind.Text, NDKKind.Repost],
|
kinds: [NDKKind.Text, NDKKind.Repost],
|
||||||
authors: db.account.circles,
|
authors: db.account.follows,
|
||||||
},
|
},
|
||||||
FETCH_LIMIT,
|
FETCH_LIMIT,
|
||||||
{ asOf: pageParam === 0 ? undefined : pageParam, abortSignal: signal }
|
{ asOf: pageParam === 0 ? undefined : pageParam, abortSignal: signal }
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ export function AddGroupFeeds({ currentWidgetId }: { currentWidgetId: string })
|
|||||||
Users
|
Users
|
||||||
</span>
|
</span>
|
||||||
<div className="flex h-[420px] flex-col overflow-y-auto rounded-xl bg-neutral-100 py-2 dark:bg-neutral-900">
|
<div className="flex h-[420px] flex-col overflow-y-auto rounded-xl bg-neutral-100 py-2 dark:bg-neutral-900">
|
||||||
{db.account.circles.map((item: string) => (
|
{db.account.follows.map((item: string) => (
|
||||||
<button
|
<button
|
||||||
key={item}
|
key={item}
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ export function LiveUpdater({ status }: { status: QueryStatus }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let sub: NDKSubscription = undefined;
|
let sub: NDKSubscription = undefined;
|
||||||
|
|
||||||
if (status === 'success' && db.account && db.account.circles.length > 0) {
|
if (status === 'success' && db.account && db.account.follows.length > 0) {
|
||||||
queryClient.fetchQuery({ queryKey: ['notification'] });
|
queryClient.fetchQuery({ queryKey: ['notification'] });
|
||||||
|
|
||||||
const filter: NDKFilter = {
|
const filter: NDKFilter = {
|
||||||
kinds: [NDKKind.Text, NDKKind.Repost],
|
kinds: [NDKKind.Text, NDKKind.Repost],
|
||||||
authors: db.account.circles,
|
authors: db.account.follows,
|
||||||
since: Math.floor(Date.now() / 1000),
|
since: Math.floor(Date.now() / 1000),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user