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 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
]);
}

View File

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

View File

@ -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();