diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "witchsky-app",
- "version": "1.115.0",
+ "version": "1.116.0",
"private": true,
"engines": {
"node": ">=18"
diff --git a/src/analytics/metrics/client.ts b/src/analytics/metrics/client.ts
--- a/src/analytics/metrics/client.ts
+++ b/src/analytics/metrics/client.ts
@@ -51,7 +51,7 @@ metadata,
}
this.queue.push(e)
- logger.info(`event: ${e.event as string}`, e)
+ logger.debug(`event: ${e.event as string}`, e)
if (this.queue.length > this.maxBatchSize) {
this.flush()
diff --git a/src/features/liveEvents/components/SidebarLiveEventFeedsBanner.tsx b/src/features/liveEvents/components/SidebarLiveEventFeedsBanner.tsx
--- a/src/features/liveEvents/components/SidebarLiveEventFeedsBanner.tsx
+++ b/src/features/liveEvents/components/SidebarLiveEventFeedsBanner.tsx
@@ -1,13 +1,90 @@
+import {View} from 'react-native'
+import {msg, Trans} from '@lingui/macro'
+import {useLingui} from '@lingui/react'
+
+import {atoms as a} from '#/alf'
+import {Button} from '#/components/Button'
+import {TimesLarge_Stroke2_Corner0_Rounded as CloseIcon} from '#/components/icons/Times'
+import * as Toast from '#/components/Toast'
import {LiveEventFeedCardCompact} from '#/features/liveEvents/components/LiveEventFeedCardCompact'
-import {useLiveEvents} from '#/features/liveEvents/context'
+import {useUserPreferencedLiveEvents} from '#/features/liveEvents/context'
+import {useUpdateLiveEventPreferences} from '#/features/liveEvents/preferences'
+import {type LiveEventFeed} from '#/features/liveEvents/types'
export function SidebarLiveEventFeedsBanner() {
- const events = useLiveEvents()
- return events.feeds.map(feed => (
-
- ))
+ const events = useUserPreferencedLiveEvents()
+ return events.feeds.map(feed => )
+}
+
+function Inner({feed}: {feed: LiveEventFeed}) {
+ const {_} = useLingui()
+ const layout = feed.layouts.wide
+
+ const {mutate: update, variables} = useUpdateLiveEventPreferences({
+ feed,
+ metricContext: 'sidebar',
+ onUpdateSuccess({undoAction}) {
+ Toast.show(
+
+
+
+ {undoAction ? (
+ Live event hidden
+ ) : (
+ Live event unhidden
+ )}
+
+ {undoAction && (
+ {
+ if (undoAction) {
+ update(undoAction)
+ }
+ }}>
+ Undo
+
+ )}
+ ,
+ {type: 'success'},
+ )
+ },
+ })
+
+ if (variables) return null
+
+ return (
+
+
+
+
+
+
+
+ )
}
diff --git a/src/features/liveEvents/context.tsx b/src/features/liveEvents/context.tsx
--- a/src/features/liveEvents/context.tsx
+++ b/src/features/liveEvents/context.tsx
@@ -1,6 +1,7 @@
import {createContext, useContext, useMemo} from 'react'
import {QueryClient, useQuery} from '@tanstack/react-query'
+import {useOnAppStateChange} from '#/lib/appState'
import {useIsBskyTeam} from '#/lib/hooks/useIsBskyTeam'
import {
convertBskyAppUrlIfNeeded,
@@ -35,18 +36,22 @@
export function Provider({children}: React.PropsWithChildren<{}>) {
const [isDevMode] = useDevMode()
const isBskyTeam = useIsBskyTeam()
- const {data} = useQuery(
+ const {data, refetch} = useQuery(
{
// keep this, prefectching handles initial load
staleTime: 1000 * 15,
queryKey: liveEventsQueryKey,
- refetchInterval: 1000 * 60 * 5,
+ refetchInterval: 1000 * 60 * 5, // refetch every 5 minutes
async queryFn() {
return fetchLiveEvents()
},
},
qc,
)
+
+ useOnAppStateChange(state => {
+ if (state === 'active') refetch()
+ })
const ctx = useMemo(() => {
if (!data) return DEFAULT_LIVE_EVENTS
diff --git a/src/lib/appState.ts b/src/lib/appState.ts
--- a/src/lib/appState.ts
+++ b/src/lib/appState.ts
@@ -12,15 +12,15 @@ cb(next)
})
}
-export function useAppState() {
- const [state, setState] = useState(AppState.currentState)
-
+export function useOnAppStateChange(cb: (state: AppStateStatus) => void) {
useEffect(() => {
- const sub = onAppStateChange(next => {
- setState(next)
- })
+ const sub = onAppStateChange(next => cb(next))
return () => sub.remove()
- }, [])
+ }, [cb])
+}
+export function useAppState() {
+ const [state, setState] = useState(AppState.currentState)
+ useOnAppStateChange(setState)
return state
}