mirror of
https://github.com/block/buzz.git
synced 2026-11-11 20:01:09 +00:00
fix(desktop): retain confirmed aborts across refresh failures
Signed-off-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -27,7 +27,7 @@ type RefreshContext = {
|
||||
export async function refreshAcceptedCommunityDeletions(
|
||||
context: RefreshContext,
|
||||
): Promise<void> {
|
||||
if (!context.isCurrent()) return;
|
||||
if (!context.isCurrent() || context.identityMismatch) return;
|
||||
let auth = await invoke<BuilderlabAuth | null>("get_builderlab_auth");
|
||||
if (!context.isCurrent()) return;
|
||||
context.setAuth(auth);
|
||||
@@ -40,39 +40,47 @@ export async function refreshAcceptedCommunityDeletions(
|
||||
if (auth.canDeleteBuzzCommunities !== true) return;
|
||||
|
||||
let restored = false;
|
||||
for (const [communityId, envelope] of [...context.accepted.entries()]) {
|
||||
if (!listed.some((community) => community.id === communityId)) continue;
|
||||
const stillEligible = () =>
|
||||
context.isCurrent() &&
|
||||
context.ownerPubkey() === envelope.bound_owner_pubkey &&
|
||||
envelope.backend_origin === BUILDERLAB_BACKEND_ORIGIN &&
|
||||
context.accepted.get(communityId) === envelope &&
|
||||
!context.identityMismatch;
|
||||
if (!stillEligible()) return;
|
||||
auth = await invoke<BuilderlabAuth | null>("get_builderlab_auth");
|
||||
if (!stillEligible()) return;
|
||||
context.setAuth(auth);
|
||||
if (!auth) {
|
||||
context.clearAccount();
|
||||
return;
|
||||
}
|
||||
if (auth.canDeleteBuzzCommunities !== true) return;
|
||||
const request = publicDeletionRequest(envelope);
|
||||
if (!stillEligible()) return;
|
||||
const response = await invoke<CommunityDeletionTransport>(
|
||||
"delete_builderlab_community",
|
||||
{
|
||||
communityId: request.community_id,
|
||||
host: request.host,
|
||||
requestId: request.request_id,
|
||||
acknowledgementVersion: request.acknowledgement_version,
|
||||
},
|
||||
);
|
||||
if (!stillEligible()) return;
|
||||
if (deletionResponseDisposition(response, envelope, "check") === "abort") {
|
||||
context.accepted.delete(communityId);
|
||||
restored = true;
|
||||
try {
|
||||
for (const [communityId, envelope] of [...context.accepted.entries()]) {
|
||||
if (!listed.some((community) => community.id === communityId)) continue;
|
||||
const stillEligible = () =>
|
||||
context.isCurrent() &&
|
||||
context.ownerPubkey() === envelope.bound_owner_pubkey &&
|
||||
envelope.backend_origin === BUILDERLAB_BACKEND_ORIGIN &&
|
||||
context.accepted.get(communityId) === envelope;
|
||||
if (!stillEligible()) return;
|
||||
auth = await invoke<BuilderlabAuth | null>("get_builderlab_auth");
|
||||
if (!stillEligible()) return;
|
||||
context.setAuth(auth);
|
||||
if (!auth) {
|
||||
context.clearAccount();
|
||||
return;
|
||||
}
|
||||
if (auth.canDeleteBuzzCommunities !== true) return;
|
||||
const request = publicDeletionRequest(envelope);
|
||||
const response = await invoke<CommunityDeletionTransport>(
|
||||
"delete_builderlab_community",
|
||||
{
|
||||
communityId: request.community_id,
|
||||
host: request.host,
|
||||
requestId: request.request_id,
|
||||
acknowledgementVersion: request.acknowledgement_version,
|
||||
},
|
||||
);
|
||||
if (!stillEligible()) return;
|
||||
const disposition = deletionResponseDisposition(
|
||||
response,
|
||||
envelope,
|
||||
"check",
|
||||
);
|
||||
if (disposition === "abort") {
|
||||
context.accepted.delete(communityId);
|
||||
restored = true;
|
||||
} else if (disposition !== "accept") {
|
||||
throw new Error("Couldn't check deletion status.");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (restored && context.isCurrent()) context.restoreListed(listed);
|
||||
}
|
||||
if (restored && context.isCurrent()) context.restoreListed(listed);
|
||||
}
|
||||
|
||||
@@ -265,6 +265,7 @@ type E2eConfig = {
|
||||
code: string;
|
||||
message?: string;
|
||||
} | null>;
|
||||
builderlabDeletionRejectSequence?: boolean[];
|
||||
builderlabDeletionStatusSequence?: string[];
|
||||
builderlabDeletionHttpStatusSequence?: number[];
|
||||
builderlabDeletionBodyStatus?: number;
|
||||
@@ -12664,6 +12665,16 @@ export function maybeInstallE2eTauriMocks() {
|
||||
heldBuilderlabDeletionReleases.push(resolve);
|
||||
});
|
||||
}
|
||||
const rejectSequence =
|
||||
activeConfig?.mock?.builderlabDeletionRejectSequence;
|
||||
if (
|
||||
rejectSequence?.length &&
|
||||
(rejectSequence.length > 1
|
||||
? rejectSequence.shift()
|
||||
: rejectSequence[0])
|
||||
) {
|
||||
throw new Error("Mock deletion transport failure");
|
||||
}
|
||||
const sequence = activeConfig?.mock?.builderlabDeletionErrorSequence;
|
||||
const deletionError = sequence?.length
|
||||
? sequence.length > 1
|
||||
|
||||
Reference in New Issue
Block a user