interface: support %started update

This commit is contained in:
Liam Fitzgerald 2021-03-29 10:30:44 +10:00 committed by Matilde Park
parent 95bf313ff9
commit 365f17f210
3 changed files with 15 additions and 2 deletions

View File

@ -6,17 +6,29 @@ import useGroupState, { GroupState } from '../state/group';
const initial = (json: any, state: GroupState): GroupState => { const initial = (json: any, state: GroupState): GroupState => {
const data = json.initial; const data = json.initial;
if(data) { if(data) {
console.log(data);
state.pendingJoin = data; state.pendingJoin = data;
} }
return state; 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 progress = (json: any, state: GroupState): GroupState => {
const data = json.progress; const data = json.progress;
if(data) { if(data) {
console.log(data);
const { progress, resource } = data; const { progress, resource } = data;
state.pendingJoin[resource].progress = progress; state.pendingJoin[resource].progress = progress;
if(progress === 'done') { if(progress === 'done') {
setTimeout(() => { setTimeout(() => {
delete state.pendingJoin[resource]; delete state.pendingJoin[resource];
}, 10000); }, 10000);
@ -40,6 +52,7 @@ export const GroupViewReducer = (json: any) => {
reduceState<GroupState, GroupUpdate>(useGroupState, data, [ reduceState<GroupState, GroupUpdate>(useGroupState, data, [
progress, progress,
hide, hide,
started,
initial initial
]); ]);
} }

View File

@ -119,7 +119,7 @@ export function InviteItem(props: InviteItemProps) {
api={api} api={api}
preview={preview} preview={preview}
invite={invite} invite={invite}
status={pendingJoin.progress} status={pendingJoin}
{...handlers} {...handlers}
/> />
); );

View File

@ -72,7 +72,7 @@ export function JoinGroup(props: JoinGroupProps): ReactElement {
MetadataUpdatePreview | string | null MetadataUpdatePreview | string | null
>(null); >(null);
const waiter = useWaitForProps({ associations, groups }, _.isString(preview) ? 1 : 30000); const waiter = useWaitForProps({ associations, groups }, _.isString(preview) ? 1 : 10);
const { query } = useQuery(); const { query } = useQuery();