Restore Feeds sparkle, fix line height
This commit is contained in:
@@ -23,6 +23,7 @@ import {getAgent, useSession} from '#/state/session'
|
|||||||
import {router} from '#/routes'
|
import {router} from '#/routes'
|
||||||
|
|
||||||
export type FeedSourceFeedInfo = {
|
export type FeedSourceFeedInfo = {
|
||||||
|
isPrimaryAlgorithm: boolean
|
||||||
type: 'feed'
|
type: 'feed'
|
||||||
uri: string
|
uri: string
|
||||||
route: {
|
route: {
|
||||||
@@ -41,6 +42,7 @@ export type FeedSourceFeedInfo = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type FeedSourceListInfo = {
|
export type FeedSourceListInfo = {
|
||||||
|
isPrimaryAlgorithm: boolean
|
||||||
type: 'list'
|
type: 'list'
|
||||||
uri: string
|
uri: string
|
||||||
route: {
|
route: {
|
||||||
@@ -71,6 +73,7 @@ const feedSourceNSIDs = {
|
|||||||
|
|
||||||
export function hydrateFeedGenerator(
|
export function hydrateFeedGenerator(
|
||||||
view: AppBskyFeedDefs.GeneratorView,
|
view: AppBskyFeedDefs.GeneratorView,
|
||||||
|
options?: Pick<FeedSourceFeedInfo, 'isPrimaryAlgorithm'>,
|
||||||
): FeedSourceInfo {
|
): FeedSourceInfo {
|
||||||
const urip = new AtUri(view.uri)
|
const urip = new AtUri(view.uri)
|
||||||
const collection =
|
const collection =
|
||||||
@@ -79,6 +82,7 @@ export function hydrateFeedGenerator(
|
|||||||
const route = router.matchPath(href)
|
const route = router.matchPath(href)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
isPrimaryAlgorithm: options?.isPrimaryAlgorithm ?? false,
|
||||||
type: 'feed',
|
type: 'feed',
|
||||||
uri: view.uri,
|
uri: view.uri,
|
||||||
cid: view.cid,
|
cid: view.cid,
|
||||||
@@ -110,6 +114,7 @@ export function hydrateList(view: AppBskyGraphDefs.ListView): FeedSourceInfo {
|
|||||||
const route = router.matchPath(href)
|
const route = router.matchPath(href)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
isPrimaryAlgorithm: false,
|
||||||
type: 'list',
|
type: 'list',
|
||||||
uri: view.uri,
|
uri: view.uri,
|
||||||
route: {
|
route: {
|
||||||
@@ -205,6 +210,7 @@ export function useSearchPopularFeedsMutation() {
|
|||||||
* The following feed, with fallbacks to Discover
|
* The following feed, with fallbacks to Discover
|
||||||
*/
|
*/
|
||||||
const HOME_FEED_STUB: FeedSourceInfo = {
|
const HOME_FEED_STUB: FeedSourceInfo = {
|
||||||
|
isPrimaryAlgorithm: false,
|
||||||
type: 'feed',
|
type: 'feed',
|
||||||
displayName: 'Following',
|
displayName: 'Following',
|
||||||
uri: 'home',
|
uri: 'home',
|
||||||
@@ -221,7 +227,8 @@ const HOME_FEED_STUB: FeedSourceInfo = {
|
|||||||
likeCount: 0,
|
likeCount: 0,
|
||||||
likeUri: '',
|
likeUri: '',
|
||||||
}
|
}
|
||||||
const DISCOVER_FEED_STUB: FeedSourceInfo = {
|
const PWI_DISCOVER_FEED_STUB: FeedSourceInfo = {
|
||||||
|
isPrimaryAlgorithm: true,
|
||||||
type: 'feed',
|
type: 'feed',
|
||||||
displayName: 'Discover',
|
displayName: 'Discover',
|
||||||
uri: DISCOVER_FEED_URI,
|
uri: DISCOVER_FEED_URI,
|
||||||
@@ -273,7 +280,7 @@ export function usePinnedFeedsInfos() {
|
|||||||
(hasSession ? 'authed:' : 'unauthed:') + allUris.join(','),
|
(hasSession ? 'authed:' : 'unauthed:') + allUris.join(','),
|
||||||
],
|
],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
let resolved = new Map()
|
let resolved = new Map<string, FeedSourceInfo>()
|
||||||
|
|
||||||
// Get all feeds. We can do this in a batch.
|
// Get all feeds. We can do this in a batch.
|
||||||
let feedsPromise = Promise.resolve()
|
let feedsPromise = Promise.resolve()
|
||||||
@@ -302,14 +309,16 @@ export function usePinnedFeedsInfos() {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
let result = [hasSession ? HOME_FEED_STUB : DISCOVER_FEED_STUB]
|
let result = [hasSession ? HOME_FEED_STUB : PWI_DISCOVER_FEED_STUB]
|
||||||
|
|
||||||
await Promise.allSettled([feedsPromise, ...listsPromises])
|
await Promise.allSettled([feedsPromise, ...listsPromises])
|
||||||
|
|
||||||
// if primary algo is enabled and was fetched, add it to the front of the list
|
// if primary algo is enabled and was fetched, add it to the front of the list
|
||||||
if (primaryAlgo?.enabled && primaryAlgo?.uri) {
|
if (primaryAlgo?.enabled && primaryAlgo?.uri) {
|
||||||
if (resolved.has(primaryAlgo.uri)) {
|
const feedInfo = resolved.get(primaryAlgo.uri)
|
||||||
result = [resolved.get(primaryAlgo.uri), ...result]
|
if (feedInfo) {
|
||||||
|
feedInfo.isPrimaryAlgorithm = true
|
||||||
|
result = [feedInfo, ...result]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,10 +331,12 @@ export function usePinnedFeedsInfos() {
|
|||||||
|
|
||||||
// order the feeds/lists in the order they were pinned
|
// order the feeds/lists in the order they were pinned
|
||||||
for (let pinnedUri of pinnedUrisSansPrimary) {
|
for (let pinnedUri of pinnedUrisSansPrimary) {
|
||||||
if (resolved.has(pinnedUri)) {
|
const feedInfo = resolved.get(pinnedUri)
|
||||||
result.push(resolved.get(pinnedUri))
|
if (feedInfo) {
|
||||||
|
result.push(feedInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(result)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,7 +24,12 @@ export function HomeHeader(
|
|||||||
|
|
||||||
const hasPinnedCustom = React.useMemo<boolean>(() => {
|
const hasPinnedCustom = React.useMemo<boolean>(() => {
|
||||||
if (!hasSession) return false
|
if (!hasSession) return false
|
||||||
return feeds.some(tab => !['home', 'following'].includes(tab.uri))
|
return feeds.some(tab => {
|
||||||
|
const isFollowing = ['home', 'following'].includes(tab.uri)
|
||||||
|
const isPrimaryAlgo = tab.isPrimaryAlgorithm
|
||||||
|
const isCustom = !isFollowing && !isPrimaryAlgo
|
||||||
|
return isCustom
|
||||||
|
})
|
||||||
}, [feeds, hasSession])
|
}, [feeds, hasSession])
|
||||||
|
|
||||||
const items = React.useMemo(() => {
|
const items = React.useMemo(() => {
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import React, {useRef, useMemo, useEffect, useState, useCallback} from 'react'
|
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
||||||
import {StyleSheet, View, ScrollView, LayoutChangeEvent} from 'react-native'
|
import {LayoutChangeEvent, ScrollView, StyleSheet, View} from 'react-native'
|
||||||
import {Text} from '../util/text/Text'
|
|
||||||
import {PressableWithHover} from '../util/PressableWithHover'
|
import {isNative} from '#/platform/detection'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
|
import {PressableWithHover} from '../util/PressableWithHover'
|
||||||
|
import {Text} from '../util/text/Text'
|
||||||
import {DraggableScrollView} from './DraggableScrollView'
|
import {DraggableScrollView} from './DraggableScrollView'
|
||||||
import {isNative} from '#/platform/detection'
|
|
||||||
|
|
||||||
export interface TabBarProps {
|
export interface TabBarProps {
|
||||||
testID?: string
|
testID?: string
|
||||||
@@ -139,7 +140,10 @@ export function TabBar({
|
|||||||
<Text
|
<Text
|
||||||
type={isDesktop || isTablet ? 'xl-bold' : 'lg-bold'}
|
type={isDesktop || isTablet ? 'xl-bold' : 'lg-bold'}
|
||||||
testID={testID ? `${testID}-${item}` : undefined}
|
testID={testID ? `${testID}-${item}` : undefined}
|
||||||
style={selected ? pal.text : pal.textLight}>
|
style={[
|
||||||
|
selected ? pal.text : pal.textLight,
|
||||||
|
{lineHeight: 20},
|
||||||
|
]}>
|
||||||
{item}
|
{item}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user