Skip to content

Commit

Permalink
Integrate removeAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Nov 9, 2023
1 parent a5cac59 commit c1d7ac8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/state/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
setStateWrapped(s => {
return {
...s,
accounts: s.accounts.filter(a => a.did !== account.did),
accounts: s.accounts.filter(
a => !(a.did === account.did || a.handle === account.handle),
),
}
})
},
Expand Down
6 changes: 3 additions & 3 deletions src/view/com/util/AccountDropdownBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import {
FontAwesomeIconStyle,
} from '@fortawesome/react-native-fontawesome'
import {s} from 'lib/styles'
import {useStores} from 'state/index'
import {usePalette} from 'lib/hooks/usePalette'
import {DropdownItem, NativeDropdown} from './forms/NativeDropdown'
import * as Toast from '../../com/util/Toast'
import {useSessionApi} from '#/state/session'

export function AccountDropdownBtn({handle}: {handle: string}) {
const store = useStores()
const pal = usePalette('default')
const {removeAccount} = useSessionApi()
const items: DropdownItem[] = [
{
label: 'Remove account',
onPress: () => {
store.session.removeAccount(handle)
removeAccount({handle})
Toast.show('Account removed from quick access')
},
icon: {
Expand Down
8 changes: 5 additions & 3 deletions src/view/screens/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
useRequireAltTextEnabled,
useSetRequireAltTextEnabled,
} from '#/state/preferences'
import {useSessionApi} from '#/state/session'
import {useSession, useSessionApi} from '#/state/session'

// TEMPORARY (APP-700)
// remove after backend testing finishes
Expand Down Expand Up @@ -86,6 +86,7 @@ export const SettingsScreen = withAuthRequired(
)
const {openModal} = useModalControls()
const {logout} = useSessionApi()
const {accounts} = useSession()

const primaryBg = useCustomPalette<ViewStyle>({
light: {backgroundColor: colors.blue0},
Expand Down Expand Up @@ -294,7 +295,7 @@ export const SettingsScreen = withAuthRequired(
</View>
</Link>
)}
{store.session.switchableAccounts.map(account => (
{accounts.map(account => (
<TouchableOpacity
testID={`switchToAccountBtn-${account.handle}`}
key={account.did}
Expand All @@ -306,10 +307,11 @@ export const SettingsScreen = withAuthRequired(
accessibilityLabel={`Switch to ${account.handle}`}
accessibilityHint="Switches the account you are logged in to">
<View style={styles.avi}>
<UserAvatar size={40} avatar={account.aviUrl} />
{/*<UserAvatar size={40} avatar={account.aviUrl} />*/}
</View>
<View style={[s.flex1]}>
<Text type="md-bold" style={pal.text}>
{/* @ts-ignore */}
{account.displayName || account.handle}
</Text>
<Text type="sm" style={pal.textLight}>
Expand Down

0 comments on commit c1d7ac8

Please sign in to comment.