jack
jack
Explore posts from servers
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
update: i think batch is what i was looking for
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
or at least as far as I can tell
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
There's no suspense boundary, but none of the signals i'm accessing are async (ie. createResource/createAsync)
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
here's my whole component, maybe i'm messing up the conditional rendering in some way?
export default function JoinGroupPage() {
const session = useUser();
const z = useZero();
const navigate = useNavigate();
const params = useParams<Params>();

const group = useQuery(() =>
getTopLevelGroupDetailsByInviteLink(z, params.invitationId),
);

const guardedGroupWithMembers = useQuery(() =>
getGroupMembersWhereUserIsAMember(
z,
group()?.id ?? '',
session.user()?.id ?? '',
),
);

const isMember = () => guardedGroupWithMembers() !== undefined;

const handleJoinGroup = () => {
const g = group();
const user = session.user();
if (!g || !user || !user.username || isMember()) return;

// TODO: fix new state flash
void joinGroup(z, group()?.id ?? '', user.id, user.username);
navigate(`/group/${g.id}`);
};

return (
<Show when={session.user() && group()}>
{(group) => (
...
<StyledCard class="max-w-md w-full">
<StyledCardHeader>
<StyledCardTitle>
<Show when={!isMember()} fallback={"Can't join "}>
Join{' '}
</Show>
'{group().title}'
</StyledCardTitle>
<StyledCardDescription>
<Show
when={!isMember()}
fallback={"you're already a member of"}
>
you&apos;ve been invited to join
</Show>{' '}
'{group().title}'
</StyledCardDescription>
</StyledCardHeader>
<StyledCardContent class="flex justify-center">...</StyledCardContent>
</StyledCard>
)}
</Show>
);
}
export default function JoinGroupPage() {
const session = useUser();
const z = useZero();
const navigate = useNavigate();
const params = useParams<Params>();

const group = useQuery(() =>
getTopLevelGroupDetailsByInviteLink(z, params.invitationId),
);

const guardedGroupWithMembers = useQuery(() =>
getGroupMembersWhereUserIsAMember(
z,
group()?.id ?? '',
session.user()?.id ?? '',
),
);

const isMember = () => guardedGroupWithMembers() !== undefined;

const handleJoinGroup = () => {
const g = group();
const user = session.user();
if (!g || !user || !user.username || isMember()) return;

// TODO: fix new state flash
void joinGroup(z, group()?.id ?? '', user.id, user.username);
navigate(`/group/${g.id}`);
};

return (
<Show when={session.user() && group()}>
{(group) => (
...
<StyledCard class="max-w-md w-full">
<StyledCardHeader>
<StyledCardTitle>
<Show when={!isMember()} fallback={"Can't join "}>
Join{' '}
</Show>
'{group().title}'
</StyledCardTitle>
<StyledCardDescription>
<Show
when={!isMember()}
fallback={"you're already a member of"}
>
you&apos;ve been invited to join
</Show>{' '}
'{group().title}'
</StyledCardDescription>
</StyledCardHeader>
<StyledCardContent class="flex justify-center">...</StyledCardContent>
</StyledCard>
)}
</Show>
);
}
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
in that the nav happens before the next frame, so i'm not sure i'll have to look into my code a little more
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
yea there's something weird on my end going on. the minimal-ish repro i could make it only happens if i wrap the navigate in a setTimeout
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
might be tough in playground, working on a repro rn though
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
the signal that updates as a result of joinGroup is a memo
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
joinGroup returns a void promise, which i don't await, and then navigate is called next, nothing in between
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
no
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
Maybe the issue is that the navigation isn’t instant?
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
Yea even in the .then it’s already updated in the ui
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
There is the option to just track with a signal if the user clicked the submit button, and if so, force the page to keep the original view. But I feel like there’s a got to be a better solution
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
But it resolves very fast
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
Yea
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
i can't put navigate before joinGroup with any sort of confidence, because then i may send the user to their next page before the app state is totally updated
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
and as such, navigate comes in too late
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
by the time joinGroup finishes, the ui will have gotten the signal updates
45 replies
SSolidJS
Created by jack on 12/24/2024 in #support
invoke navigate() after function call but before signal update propagates to ui
the goal is to invoke joinGroup and navigate before the next render, so basically, yea
45 replies