Skip to content

Commit

Permalink
fix activity flicker
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul committed May 6, 2024
1 parent 60c9da8 commit 903e20b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/components/Activity.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { TagItem } from "@mutinywallet/mutiny-wasm";
import { cache, createAsync, reload, useNavigate } from "@solidjs/router";
import { cache, createAsync, useNavigate } from "@solidjs/router";
import { Plus, Save, Search, Shuffle, Users } from "lucide-solid";
import {
createEffect,
createMemo,
createResource,
createSignal,
For,
Match,
Expand All @@ -26,6 +27,7 @@ import { PrivacyLevel } from "~/routes";
import { useMegaStore, WalletWorker } from "~/state/megaStore";
import {
actuallyFetchNostrProfile,
createDeepSignal,
hexpubFromNpub,
profileToPseudoContact,
PseudoContact,
Expand Down Expand Up @@ -393,19 +395,23 @@ export function CombinedActivity() {
setDetailsOpen(true);
}

const activity = createAsync(async () => {
async function fetchActivity() {
try {
return await sw.get_activity(50, undefined);
} catch (e) {
console.error(e);
return [] as IActivityItem[];
}
}

const [activity, { refetch }] = createResource(fetchActivity, {
storage: createDeepSignal
});

createEffect(() => {
// Should re-run after every sync
if (!state.is_syncing) {
reload();
refetch();
}
});

Expand All @@ -429,7 +435,7 @@ export function CombinedActivity() {
</Show>
<Suspense fallback={<LoadingShimmer />}>
<Switch>
<Match when={activity()?.length === 0}>
<Match when={activity.latest?.length === 0}>
<Show when={state.federations?.length === 0}>
<ButtonCard
onClick={() =>
Expand All @@ -455,9 +461,11 @@ export function CombinedActivity() {
</div>
</ButtonCard>
</Match>
<Match when={activity() && activity()!.length >= 0}>
<Match
when={activity.latest && activity.latest!.length >= 0}
>
<div class="flex w-full flex-col divide-y divide-m-grey-800 overflow-x-clip">
<For each={activity()}>
<For each={activity.latest}>
{(activityItem) => (
<UnifiedActivityItem
item={activityItem}
Expand Down

0 comments on commit 903e20b

Please sign in to comment.