Skip to content

Commit

Permalink
fix: let people dismiss disclaimer modal & show popup as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarrazin committed Nov 5, 2024
1 parent 629b49c commit 51227b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/DisclaimerModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
const settings = useSettingsStore();
</script>

<Modal>
<Modal on:close>
<div
class="from-primary-500/40 via-primary-500/10 to-primary-500/0 flex w-full flex-col items-center gap-6 bg-gradient-to-b px-5 pb-8 pt-9 text-center sm:px-6"
>
Expand Down
8 changes: 5 additions & 3 deletions src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {

let loginRequired = false;

if (requiresUser && !locals.user && messagesBeforeLogin) {
if (nConversations > messagesBeforeLogin) {
if (requiresUser && !locals.user) {
if (messagesBeforeLogin === 0) {
loginRequired = true;
} else if (nConversations >= messagesBeforeLogin) {
loginRequired = true;
} else {
// get the number of messages where `from === "assistant"` across all conversations.
Expand All @@ -114,7 +116,7 @@ export const load: LayoutServerLoad = async ({ locals, depends }) => {
.toArray()
)[0]?.messages ?? 0;

loginRequired = totalMessages > messagesBeforeLogin;
loginRequired = totalMessages >= messagesBeforeLogin;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
</svelte:head>

{#if !$settings.ethicsModalAccepted && $page.url.pathname !== `${base}/privacy` && envPublic.PUBLIC_APP_DISCLAIMER === "1"}
<DisclaimerModal />
<DisclaimerModal on:close={() => ($settings.ethicsModalAccepted = true)} />
{/if}

<ExpandNavigation
Expand Down

0 comments on commit 51227b9

Please sign in to comment.