Unify the display name fallback behavior

zio/stable
Paul Frazee 2023-05-17 14:38:23 -05:00
parent 4e56d24a9d
commit 9c02fbb925
3 changed files with 16 additions and 11 deletions

View File

@ -1,6 +1,7 @@
import {AppBskyFeedDefs, AtUri} from '@atproto/api'
import {makeAutoObservable} from 'mobx'
import {RootStoreModel} from 'state/models/root-store'
import {sanitizeDisplayName} from 'lib/strings/display-names'
export class CustomFeedModel {
// data
@ -34,6 +35,13 @@ export class CustomFeedModel {
return this.data.uri
}
get displayName() {
if (this.data.displayName) {
return sanitizeDisplayName(this.data.displayName)
}
return `Feed by @${this.data.creator.handle}`
}
get isSaved() {
return this.data.viewer?.saved
}

View File

@ -66,15 +66,11 @@ export class SavedFeedsModel {
}
get listOfFeedNames() {
return this.feeds.map(
f => f.data.displayName ?? f.data.creator.displayName + "'s feed",
)
return this.feeds.map(f => f.displayName)
}
get listOfPinnedFeedNames() {
return this.pinned.map(
f => f.data.displayName ?? f.data.creator.displayName + "'s feed",
)
return this.pinned.map(f => f.displayName)
}
get savedFeedsWithoutPinned() {

View File

@ -54,9 +54,7 @@ export const CustomFeed = observer(
navigation.navigate('CustomFeed', {
name: item.data.creator.did,
rkey: new AtUri(item.data.uri).rkey,
displayName:
item.data.displayName ??
`${item.data.creator.displayName}'s feed`,
displayName: item.displayName,
})
}}
key={item.data.uri}>
@ -65,8 +63,11 @@ export const CustomFeed = observer(
<UserAvatar type="algo" size={36} avatar={item.data.avatar} />
</View>
<View style={[styles.headerTextContainer]}>
<Text style={[pal.text, s.bold]}>
{item.data.displayName ?? 'Feed name'}
<Text style={[pal.text, s.bold]} numberOfLines={3}>
{item.displayName}
</Text>
<Text style={[pal.textLight]} numberOfLines={3}>
by @{item.data.creator.handle}
</Text>
</View>
{showSaveBtn && (