diff --git a/src/state/models/ui/saved-feeds.ts b/src/state/models/ui/saved-feeds.ts index bae98fc8..50bb1b87 100644 --- a/src/state/models/ui/saved-feeds.ts +++ b/src/state/models/ui/saved-feeds.ts @@ -61,24 +61,24 @@ export class SavedFeedsModel { return this.hasLoaded && !this.hasContent } - get numOfFeeds() { + get numFeeds() { return this.feeds.length } - get listOfFeedNames() { - return this.feeds.map(f => f.displayName) - } - - get listOfPinnedFeedNames() { - return this.pinned.map(f => f.displayName) - } - - get savedFeedsWithoutPinned() { + get unpinned() { return this.feeds.filter( f => !this.pinned.find(p => p.data.uri === f.data.uri), ) } + get feedNames() { + return this.feeds.map(f => f.displayName) + } + + get pinnedFeedNames() { + return this.pinned.map(f => f.displayName) + } + togglePinnedFeed(feed: CustomFeedModel) { if (!this.isPinned(feed)) { this.pinned.push(feed) @@ -92,7 +92,7 @@ export class SavedFeedsModel { } reorderPinnedFeeds(temp: CustomFeedModel[]) { - this.pinned = temp + this.pinned = temp.filter(item => this.isPinned(item)) } isPinned(feed: CustomFeedModel) { diff --git a/src/view/com/feeds/CustomFeed.tsx b/src/view/com/feeds/CustomFeed.tsx index 5440a8e8..5201ca84 100644 --- a/src/view/com/feeds/CustomFeed.tsx +++ b/src/view/com/feeds/CustomFeed.tsx @@ -1,16 +1,17 @@ import React from 'react' import { + Pressable, StyleProp, StyleSheet, View, ViewStyle, TouchableOpacity, } from 'react-native' +import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {Text} from '../util/text/Text' import {usePalette} from 'lib/hooks/usePalette' import {s} from 'lib/styles' import {UserAvatar} from '../util/UserAvatar' -import {Button} from '../util/forms/Button' import {observer} from 'mobx-react-lite' import {CustomFeedModel} from 'state/models/feeds/custom-feed' import {useNavigation} from '@react-navigation/native' @@ -18,6 +19,7 @@ import {NavigationProp} from 'lib/routes/types' import {useStores} from 'state/index' import {pluralize} from 'lib/strings/helpers' import {AtUri} from '@atproto/api' +import * as Toast from 'view/com/util/Toast' export const CustomFeed = observer( ({ @@ -37,6 +39,23 @@ export const CustomFeed = observer( const pal = usePalette('default') const navigation = useNavigation() + const onToggleSaved = React.useCallback(() => { + if (item.data.viewer?.saved) { + store.shell.openModal({ + name: 'confirm', + title: 'Remove from my feeds', + message: `Remove ${item.displayName} from my feeds?`, + onPressConfirm: () => { + store.me.savedFeeds.unsave(item) + Toast.show('Removed from my feeds') + }, + }) + } else { + store.me.savedFeeds.save(item) + Toast.show('Added to my feeds') + } + }, [store, item]) + return ( {showSaveBtn && ( -