about summary refs log tree commit diff
path: root/src/state/queries/feed.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2024-04-12 14:13:13 -0700
committerGitHub <noreply@github.com>2024-04-12 14:13:13 -0700
commitec5c4929c1c5677d22c923193ce04f3d69b72711 (patch)
treeccc097ea1565ae506e522a76a019bfeb6a63faf3 /src/state/queries/feed.ts
parent44039c68d678e99f9dc712f1a6dae87aed970ca3 (diff)
downloadvoidsky-ec5c4929c1c5677d22c923193ce04f3d69b72711.tar.zst
PWI improvements (#3489)
* Enable home and feeds on the PWI

* Add global SigninDialog to drive useRequireAuth()

* Tweak desktop styles

* Make the logo in leftnav PWI a clickable home link

* Add label

* Improve dialog on web

* Fix query key

* Go to home after signout from settings screen

* Filter out feeds from the discover listing for logged out users which are known to break without auth

* Update profile header follow/subscribe to give signin prompt

* Show profile feeds tabs on pwi

* Add language selector to account creation footer and pwi left nav desktop

---------

Co-authored-by: dan <dan.abramov@gmail.com>
Diffstat (limited to 'src/state/queries/feed.ts')
-rw-r--r--src/state/queries/feed.ts27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/state/queries/feed.ts b/src/state/queries/feed.ts
index c56912491..0d3de8969 100644
--- a/src/state/queries/feed.ts
+++ b/src/state/queries/feed.ts
@@ -17,7 +17,7 @@ import {sanitizeDisplayName} from '#/lib/strings/display-names'
 import {sanitizeHandle} from '#/lib/strings/handles'
 import {STALE} from '#/state/queries'
 import {usePreferencesQuery} from '#/state/queries/preferences'
-import {getAgent} from '#/state/session'
+import {getAgent, useSession} from '#/state/session'
 import {router} from '#/routes'
 
 export type FeedSourceFeedInfo = {
@@ -216,17 +216,38 @@ const FOLLOWING_FEED_STUB: FeedSourceInfo = {
   likeCount: 0,
   likeUri: '',
 }
+const DISCOVER_FEED_STUB: FeedSourceInfo = {
+  type: 'feed',
+  displayName: 'Discover',
+  uri: '',
+  route: {
+    href: '/',
+    name: 'Home',
+    params: {},
+  },
+  cid: '',
+  avatar: '',
+  description: new RichText({text: ''}),
+  creatorDid: '',
+  creatorHandle: '',
+  likeCount: 0,
+  likeUri: '',
+}
 
 const pinnedFeedInfosQueryKeyRoot = 'pinnedFeedsInfos'
 
 export function usePinnedFeedsInfos() {
+  const {hasSession} = useSession()
   const {data: preferences, isLoading: isLoadingPrefs} = usePreferencesQuery()
   const pinnedUris = preferences?.feeds?.pinned ?? []
 
   return useQuery({
     staleTime: STALE.INFINITY,
     enabled: !isLoadingPrefs,
-    queryKey: [pinnedFeedInfosQueryKeyRoot, pinnedUris.join(',')],
+    queryKey: [
+      pinnedFeedInfosQueryKeyRoot,
+      (hasSession ? 'authed:' : 'unauthed:') + pinnedUris.join(','),
+    ],
     queryFn: async () => {
       let resolved = new Map()
 
@@ -264,7 +285,7 @@ export function usePinnedFeedsInfos() {
       )
 
       // The returned result will have the original order.
-      const result = [FOLLOWING_FEED_STUB]
+      const result = [hasSession ? FOLLOWING_FEED_STUB : DISCOVER_FEED_STUB]
       await Promise.allSettled([feedsPromise, ...listsPromises])
       for (let pinnedUri of pinnedUris) {
         if (resolved.has(pinnedUri)) {