From 173f3bf5b89633b8a5cd85175a3f2469da89f6d3 Mon Sep 17 00:00:00 2001 From: Daniel Holmgren Date: Wed, 27 Sep 2023 16:55:25 -0500 Subject: [PATCH] Bugfix: handle contention (#1629) bugfix: handle contention --- packages/bsky/src/services/indexing/index.ts | 32 +++++++++----------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/packages/bsky/src/services/indexing/index.ts b/packages/bsky/src/services/indexing/index.ts index 03dce203f36..60c465dc0fc 100644 --- a/packages/bsky/src/services/indexing/index.ts +++ b/packages/bsky/src/services/indexing/index.ts @@ -144,24 +144,22 @@ export class IndexingService { const handle: string | null = did === handleToDid ? atpData.handle.toLowerCase() : null - if (actor && actor.handle !== handle) { - const actorWithHandle = - handle !== null - ? await this.db.db - .selectFrom('actor') - .where('handle', '=', handle) - .selectAll() - .executeTakeFirst() - : null + const actorWithHandle = + handle !== null + ? await this.db.db + .selectFrom('actor') + .where('handle', '=', handle) + .selectAll() + .executeTakeFirst() + : null - // handle contention - if (handle && actorWithHandle && did !== actorWithHandle.did) { - await this.db.db - .updateTable('actor') - .where('actor.did', '=', actorWithHandle.did) - .set({ handle: null }) - .execute() - } + // handle contention + if (handle && actorWithHandle && did !== actorWithHandle.did) { + await this.db.db + .updateTable('actor') + .where('actor.did', '=', actorWithHandle.did) + .set({ handle: null }) + .execute() } const actorInfo = { handle, indexedAt: timestamp }