-
-
Notifications
You must be signed in to change notification settings - Fork 603
feat(web): redirect logged-in users from root to /threads (opt-in) #950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a649d4c
docs: add design spec for root->threads redirect
AchoArnold ea6149e
docs: add implementation plan for root->threads redirect
AchoArnold d737d2f
feat(web): add redirectPreference store for per-browser threads redirect
AchoArnold 156a1e0
feat(web): optimistically redirect root to /threads when opted in
AchoArnold 4ecfa32
feat(web): add redirect opt-in popover component
AchoArnold 68f9411
feat(web): mount redirect opt-in popover under Dashboard button
AchoArnold e7323d8
feat(web): clear threads-redirect preference on logout
AchoArnold ec1401f
fix(web): use replace navigation in redirect enable() to avoid stuck …
AchoArnold 578e17e
ci(web): pin pnpm to 11.11.0 to avoid installer bug
AchoArnold 859dc88
fix(web): import ref from vue, drop gitignored docs
AchoArnold 258b381
fix(web): persist redirect before navigation
AchoArnold b7f7494
fix(web): gate landing nav auth buttons on authStateChanged
AchoArnold 5be36ab
refactor(web): render redirect prompt as v-menu not v-card
AchoArnold File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <script setup lang="ts"> | ||
| import { computed } from 'vue' | ||
| import { mdiClose, mdiArrowRight } from '@mdi/js' | ||
|
|
||
| const route = useRoute() | ||
| const authStore = useAuthStore() | ||
| const redirectStore = useRedirectPreferenceStore() | ||
|
|
||
| const showPopover = computed( | ||
| () => | ||
| route.name === 'index' && | ||
| authStore.authUser !== null && | ||
| !redirectStore.enabled && | ||
| !redirectStore.dismissedThisSession, | ||
| ) | ||
|
|
||
| const menuOpen = computed({ | ||
| get: () => showPopover.value, | ||
| set: (value: boolean) => { | ||
| if (!value) redirectStore.dismiss() | ||
| }, | ||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <v-menu | ||
| v-model="menuOpen" | ||
| activator="parent" | ||
| location="bottom end" | ||
| offset="8" | ||
| :open-on-click="false" | ||
| :close-on-content-click="false" | ||
| > | ||
| <v-list width="280" class="py-0" rounded="lg" elevation="8"> | ||
| <v-list-item> | ||
| <v-list-item-title class="text-body-1"> | ||
| Skip this page next time? | ||
| </v-list-item-title> | ||
| <template #append> | ||
| <v-btn | ||
| :icon="mdiClose" | ||
| variant="text" | ||
| size="small" | ||
| color="warning" | ||
| density="comfortable" | ||
| aria-label="Dismiss" | ||
| @click="redirectStore.dismiss()" | ||
| /> | ||
| </template> | ||
| </v-list-item> | ||
| <v-list-item class="text-primary" @click="redirectStore.enable()"> | ||
| <v-list-item-title>Always open dashboard</v-list-item-title> | ||
| <template #append> | ||
| <v-icon :icon="mdiArrowRight" size="small" /> | ||
| </template> | ||
| </v-list-item> | ||
| </v-list> | ||
| </v-menu> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { STORAGE_KEY } from '~/stores/redirectPreference' | ||
|
|
||
| export default defineNuxtRouteMiddleware(() => { | ||
| try { | ||
| if (localStorage.getItem(STORAGE_KEY) === 'true') { | ||
| return navigateTo('/threads', { replace: true }) | ||
| } | ||
| } catch (error) { | ||
| console.error(error) | ||
| } | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { defineStore } from 'pinia' | ||
| import { ref } from 'vue' | ||
|
|
||
| export const STORAGE_KEY = 'httpsms_redirect_to_threads' | ||
|
|
||
| function readFlag(): boolean { | ||
| try { | ||
| return localStorage.getItem(STORAGE_KEY) === 'true' | ||
| } catch (error) { | ||
| console.error(error) | ||
| return false | ||
| } | ||
| } | ||
|
|
||
| export const useRedirectPreferenceStore = defineStore( | ||
|
Check warning on line 15 in web/app/stores/redirectPreference.ts
|
||
| 'redirectPreference', | ||
| () => { | ||
| const enabled = ref(readFlag()) | ||
| const dismissedThisSession = ref(false) | ||
|
|
||
| function enable() { | ||
| try { | ||
| localStorage.setItem(STORAGE_KEY, 'true') | ||
| enabled.value = true | ||
| navigateTo('/threads', { replace: true }) | ||
| } catch (error) { | ||
| console.error(error) | ||
| } | ||
| } | ||
|
AchoArnold marked this conversation as resolved.
|
||
|
|
||
| function dismiss() { | ||
| dismissedThisSession.value = true | ||
| } | ||
|
|
||
| function resetState() { | ||
| enabled.value = false | ||
| dismissedThisSession.value = false | ||
| try { | ||
| localStorage.removeItem(STORAGE_KEY) | ||
| } catch (error) { | ||
| console.error(error) | ||
| } | ||
| } | ||
|
|
||
| return { enabled, dismissedThisSession, enable, dismiss, resetState } | ||
| }, | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.