mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-18 22:44:26 +01:00
update
This commit is contained in:
@@ -447,7 +447,7 @@ export const useFollowings = (propsProvider: () => UseFollowingsProps | null): U
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
staleTime: 5 * 60 * 1000, // 5 min
|
staleTime: 5 * 60 * 1000, // 5 min
|
||||||
cacheTime: 4 * 60 * 60 * 1000, // 4 hour
|
cacheTime: 24 * 60 * 60 * 1000, // 24 hour
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -475,9 +475,7 @@ export const useFollowings = (propsProvider: () => UseFollowingsProps | null): U
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const followingPubkeys = (): string[] => {
|
const followingPubkeys = (): string[] => followings().map((follow) => follow.pubkey);
|
||||||
return followings().map((follow) => follow.pubkey);
|
|
||||||
};
|
|
||||||
|
|
||||||
return { followings, followingPubkeys, query };
|
return { followings, followingPubkeys, query };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ const [pubkey, setPubkey] = createSignal<string | undefined>(undefined);
|
|||||||
// TODO 失敗したときに通知等を表示したい
|
// TODO 失敗したときに通知等を表示したい
|
||||||
const usePubkey = (): Accessor<string | undefined> => {
|
const usePubkey = (): Accessor<string | undefined> => {
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
console.time('pubkey loaded');
|
if (pubkey() != null) return;
|
||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
let intervalId: ReturnType<typeof setInterval> | undefined;
|
const intervalId = setInterval(() => {
|
||||||
const loadPubkey = () => {
|
|
||||||
if (count >= 20) {
|
if (count >= 20) {
|
||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
if (pubkey() == null) {
|
if (pubkey() == null) {
|
||||||
@@ -29,7 +29,6 @@ const usePubkey = (): Accessor<string | undefined> => {
|
|||||||
.then((key) => {
|
.then((key) => {
|
||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
setPubkey(key);
|
setPubkey(key);
|
||||||
console.timeEnd('pubkey loaded');
|
|
||||||
})
|
})
|
||||||
.catch((err) => console.error('failed to obtain public key: ', err))
|
.catch((err) => console.error('failed to obtain public key: ', err))
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@@ -37,8 +36,7 @@ const usePubkey = (): Accessor<string | undefined> => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
count += 1;
|
count += 1;
|
||||||
};
|
}, 200);
|
||||||
intervalId = setInterval(loadPubkey, 200);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return pubkey;
|
return pubkey;
|
||||||
|
|||||||
@@ -54,18 +54,20 @@ const Home: Component = () => {
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
const { events: followingsPosts } = useSubscription(() =>
|
const { events: followingsPosts } = useSubscription(() => {
|
||||||
ensureNonNull([pubkey()] as const)(([pubkeyNonNull]) => ({
|
const authors = uniq([...followingPubkeys()]);
|
||||||
|
if (authors.length === 0) return null;
|
||||||
|
return {
|
||||||
relayUrls: config().relayUrls,
|
relayUrls: config().relayUrls,
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
kinds: [1, 6],
|
kinds: [1, 6],
|
||||||
authors: uniq([...followingPubkeys(), pubkeyNonNull]),
|
authors,
|
||||||
limit: 25,
|
limit: 25,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})),
|
};
|
||||||
);
|
});
|
||||||
|
|
||||||
const { events: myPosts } = useSubscription(() =>
|
const { events: myPosts } = useSubscription(() =>
|
||||||
ensureNonNull([pubkey()] as const)(([pubkeyNonNull]) => ({
|
ensureNonNull([pubkey()] as const)(([pubkeyNonNull]) => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user