From 099c9d2b0ede396d333cadd6cb2d83111a10ef1f Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 9 Jan 2025 16:40:11 +1100 Subject: [PATCH] fix: disable resend button on resending, shorter timeout with UI --- ts/components/MemberListItem.tsx | 2 ++ ts/session/utils/job_runners/jobs/GroupInviteJob.ts | 3 ++- ts/session/utils/job_runners/jobs/GroupSyncJob.ts | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ts/components/MemberListItem.tsx b/ts/components/MemberListItem.tsx index 9289c8ff6..b7824b145 100644 --- a/ts/components/MemberListItem.tsx +++ b/ts/components/MemberListItem.tsx @@ -234,6 +234,7 @@ const GroupStatusContainer = ({ const ResendButton = ({ groupPk, pubkey }: { pubkey: PubkeyType; groupPk: GroupPubkeyType }) => { const acceptedInvite = useMemberHasAcceptedInvite(pubkey, groupPk); const nominatedAdmin = useMemberIsNominatedAdmin(pubkey, groupPk); + const memberStatus = useMemberStatus(pubkey, groupPk); // as soon as the `admin` flag is set in the group for that member, we should be able to resend a promote as we cannot remove an admin. const canResendPromotion = hasClosedGroupV2QAButtons() && nominatedAdmin; @@ -252,6 +253,7 @@ const ResendButton = ({ groupPk, pubkey }: { pubkey: PubkeyType; groupPk: GroupP buttonShape={SessionButtonShape.Square} buttonType={SessionButtonType.Solid} text={window.i18n('resend')} + disabled={memberStatus === 'INVITE_SENDING' || memberStatus === 'PROMOTION_SENDING'} onClick={async () => { const group = await UserGroupsWrapperActions.getGroup(groupPk); const member = await MetaGroupWrapperActions.memberGet(groupPk, pubkey); diff --git a/ts/session/utils/job_runners/jobs/GroupInviteJob.ts b/ts/session/utils/job_runners/jobs/GroupInviteJob.ts index 3bf752cfb..7a68a5718 100644 --- a/ts/session/utils/job_runners/jobs/GroupInviteJob.ts +++ b/ts/session/utils/job_runners/jobs/GroupInviteJob.ts @@ -199,6 +199,7 @@ class GroupInviteJob extends PersistedJob { unrevokeSubRequest, extraStoreRequests: [], allow401s: false, + timeoutMs: 10 * DURATION.SECONDS, }); if (sequenceResult !== RunJobResult.Success) { await LibSessionUtil.saveDumpsToDb(groupPk); @@ -236,7 +237,7 @@ class GroupInviteJob extends PersistedJob { message: rawMessage, isSyncMessage: false, }), - 30 * DURATION.SECONDS, + 10 * DURATION.SECONDS, controller ); diff --git a/ts/session/utils/job_runners/jobs/GroupSyncJob.ts b/ts/session/utils/job_runners/jobs/GroupSyncJob.ts index d0dae2e9e..dd3aa1dcb 100644 --- a/ts/session/utils/job_runners/jobs/GroupSyncJob.ts +++ b/ts/session/utils/job_runners/jobs/GroupSyncJob.ts @@ -37,6 +37,7 @@ import { } from '../PersistedJob'; import { DURATION } from '../../../constants'; import { WithAllow401s } from '../../../types/with'; +import type { WithTimeoutMs } from '../../../apis/snode_api/requestWith'; const defaultMsBetweenRetries = 15000; // a long time between retries, to avoid running multiple jobs at the same time, when one was postponed at the same time as one already planned (5s) const defaultMaxAttempts = 2; @@ -91,9 +92,10 @@ async function pushChangesToGroupSwarmIfNeeded({ deleteAllMessagesSubRequest, extraStoreRequests, allow401s, + timeoutMs }: WithGroupPubkey & WithAllow401s & - WithRevokeSubRequest & { + WithRevokeSubRequest & Partial & { supplementalKeysSubRequest?: StoreGroupKeysSubRequest; deleteAllMessagesSubRequest?: DeleteAllFromGroupMsgNodeSubRequest; extraStoreRequests: Array; @@ -175,7 +177,7 @@ async function pushChangesToGroupSwarmIfNeeded({ abortSignal: controller.signal, allow401s, }), - 30 * DURATION.SECONDS, + timeoutMs || 30 * DURATION.SECONDS, controller );