show toast for over limits

This commit is contained in:
Hailey
2024-06-09 17:11:08 -07:00
parent ab908e18b2
commit c20c56b8d3
2 changed files with 16 additions and 3 deletions
+15 -2
View File
@@ -5,6 +5,9 @@ import {
AppBskyGraphStarterpack, AppBskyGraphStarterpack,
} from '@atproto/api' } from '@atproto/api'
import {GeneratorView} from '@atproto/api/dist/client/types/app/bsky/feed/defs' 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 const steps = ['Details', 'Profiles', 'Feeds'] as const
type Step = (typeof steps)[number] type Step = (typeof steps)[number]
@@ -20,6 +23,7 @@ type Action =
| {type: 'AddFeed'; feed: GeneratorView} | {type: 'AddFeed'; feed: GeneratorView}
| {type: 'RemoveFeed'; feedUri: string} | {type: 'RemoveFeed'; feedUri: string}
| {type: 'SetProcessing'; processing: boolean} | {type: 'SetProcessing'; processing: boolean}
| {type: 'SetError'; error: string}
interface State { interface State {
canNext: boolean canNext: boolean
@@ -29,6 +33,7 @@ interface State {
profiles: AppBskyActorDefs.ProfileViewBasic[] profiles: AppBskyActorDefs.ProfileViewBasic[]
feeds: GeneratorView[] feeds: GeneratorView[]
processing: boolean processing: boolean
error?: string
} }
type TStateContext = [State, (action: Action) => void] type TStateContext = [State, (action: Action) => void]
@@ -58,7 +63,11 @@ function reducer(state: State, action: Action): State {
updatedState = {...state, description: action.description} updatedState = {...state, description: action.description}
break break
case 'AddProfile': 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 break
case 'RemoveProfile': case 'RemoveProfile':
updatedState = { updatedState = {
@@ -69,7 +78,11 @@ function reducer(state: State, action: Action): State {
} }
break break
case 'AddFeed': 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 break
case 'RemoveFeed': case 'RemoveFeed':
updatedState = { updatedState = {
+1 -1
View File
@@ -60,7 +60,7 @@ export function Wizard({
data: profilesData, data: profilesData,
isLoading: isLoadingProfiles, isLoading: isLoadingProfiles,
isError: isErrorProfiles, 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)) const profiles = profilesData?.pages.flatMap(p => p.items.map(i => i.subject))
if (name && rkey && (!starterPack || (starterPack && listUri && !profiles))) { if (name && rkey && (!starterPack || (starterPack && listUri && !profiles))) {