From 365f17f21082b2c10b047ab78cec988c713b0940 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald <liam.fitzgerald@tlon.io> Date: Mon, 29 Mar 2021 10:30:44 +1000 Subject: [PATCH] interface: support %started update --- pkg/interface/src/logic/reducers/group-view.ts | 13 +++++++++++++ pkg/interface/src/views/components/Invite/index.tsx | 2 +- .../src/views/landscape/components/JoinGroup.tsx | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/interface/src/logic/reducers/group-view.ts b/pkg/interface/src/logic/reducers/group-view.ts index 816a313b9..63f14ec4e 100644 --- a/pkg/interface/src/logic/reducers/group-view.ts +++ b/pkg/interface/src/logic/reducers/group-view.ts @@ -6,17 +6,29 @@ import useGroupState, { GroupState } from '../state/group'; const initial = (json: any, state: GroupState): GroupState => { const data = json.initial; if(data) { + console.log(data); state.pendingJoin = data; } return state; }; +const started = (json: any, state: GroupState): GroupState => { + const data = json.started; + if(data) { + const { resource, request } = data; + state.pendingJoin[resource] = request; + } + return state; +} + const progress = (json: any, state: GroupState): GroupState => { const data = json.progress; if(data) { + console.log(data); const { progress, resource } = data; state.pendingJoin[resource].progress = progress; if(progress === 'done') { + setTimeout(() => { delete state.pendingJoin[resource]; }, 10000); @@ -40,6 +52,7 @@ export const GroupViewReducer = (json: any) => { reduceState<GroupState, GroupUpdate>(useGroupState, data, [ progress, hide, + started, initial ]); } diff --git a/pkg/interface/src/views/components/Invite/index.tsx b/pkg/interface/src/views/components/Invite/index.tsx index b89e5e630..a8d90f781 100644 --- a/pkg/interface/src/views/components/Invite/index.tsx +++ b/pkg/interface/src/views/components/Invite/index.tsx @@ -119,7 +119,7 @@ export function InviteItem(props: InviteItemProps) { api={api} preview={preview} invite={invite} - status={pendingJoin.progress} + status={pendingJoin} {...handlers} /> ); diff --git a/pkg/interface/src/views/landscape/components/JoinGroup.tsx b/pkg/interface/src/views/landscape/components/JoinGroup.tsx index b0a6d0c47..c12b399a3 100644 --- a/pkg/interface/src/views/landscape/components/JoinGroup.tsx +++ b/pkg/interface/src/views/landscape/components/JoinGroup.tsx @@ -72,7 +72,7 @@ export function JoinGroup(props: JoinGroupProps): ReactElement { MetadataUpdatePreview | string | null >(null); - const waiter = useWaitForProps({ associations, groups }, _.isString(preview) ? 1 : 30000); + const waiter = useWaitForProps({ associations, groups }, _.isString(preview) ? 1 : 10); const { query } = useQuery();