From c20c56b8d355864d93a133e303cbd57c2eb64d97 Mon Sep 17 00:00:00 2001 From: Hailey Date: Sun, 9 Jun 2024 17:11:08 -0700 Subject: [PATCH] show toast for over limits --- src/screens/StarterPack/Wizard/State.tsx | 17 +++++++++++++++-- src/screens/StarterPack/Wizard/index.tsx | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/screens/StarterPack/Wizard/State.tsx b/src/screens/StarterPack/Wizard/State.tsx index 0b52593be9..9724ce19dc 100644 --- a/src/screens/StarterPack/Wizard/State.tsx +++ b/src/screens/StarterPack/Wizard/State.tsx @@ -5,6 +5,9 @@ import { AppBskyGraphStarterpack, } from '@atproto/api' import {GeneratorView} from '@atproto/api/dist/client/types/app/bsky/feed/defs' +import {msg} from '@lingui/macro' + +import * as Toast from '#/view/com/util/Toast' const steps = ['Details', 'Profiles', 'Feeds'] as const type Step = (typeof steps)[number] @@ -20,6 +23,7 @@ type Action = | {type: 'AddFeed'; feed: GeneratorView} | {type: 'RemoveFeed'; feedUri: string} | {type: 'SetProcessing'; processing: boolean} + | {type: 'SetError'; error: string} interface State { canNext: boolean @@ -29,6 +33,7 @@ interface State { profiles: AppBskyActorDefs.ProfileViewBasic[] feeds: GeneratorView[] processing: boolean + error?: string } type TStateContext = [State, (action: Action) => void] @@ -58,7 +63,11 @@ function reducer(state: State, action: Action): State { updatedState = {...state, description: action.description} break case 'AddProfile': - updatedState = {...state, profiles: [...state.profiles, action.profile]} + if (state.profiles.length >= 51) { + Toast.show(msg`You may only add up to 50 profiles`.message ?? '') + } else { + updatedState = {...state, profiles: [...state.profiles, action.profile]} + } break case 'RemoveProfile': updatedState = { @@ -69,7 +78,11 @@ function reducer(state: State, action: Action): State { } break case 'AddFeed': - updatedState = {...state, feeds: [...state.feeds, action.feed]} + if (state.feeds.length >= 50) { + Toast.show(msg`You may only add up to 50 feeds`.message ?? '') + } else { + updatedState = {...state, feeds: [...state.feeds, action.feed]} + } break case 'RemoveFeed': updatedState = { diff --git a/src/screens/StarterPack/Wizard/index.tsx b/src/screens/StarterPack/Wizard/index.tsx index 402e39aafb..9d0deb7942 100644 --- a/src/screens/StarterPack/Wizard/index.tsx +++ b/src/screens/StarterPack/Wizard/index.tsx @@ -60,7 +60,7 @@ export function Wizard({ data: profilesData, isLoading: isLoadingProfiles, isError: isErrorProfiles, - } = useListMembersQuery(listUri, 50) + } = useListMembersQuery(listUri, 51) // 51 because we also include the current user const profiles = profilesData?.pages.flatMap(p => p.items.map(i => i.subject)) if (name && rkey && (!starterPack || (starterPack && listUri && !profiles))) {