Skip to content

Commit 03c5607

Browse files
authored
Merge pull request framer#403 from framer/global-search/fix-stale-data
Global Search: remove items up to current indexer run
2 parents 94d7062 + d75fde2 commit 03c5607

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

plugins/global-search/src/components/DevToolsScene.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ export function DevToolsScene() {
149149
{selectedEntry.rootNodeName} ({selectedEntry.rootNodeType})
150150
</p>
151151
</div>
152+
153+
<div>
154+
<label className="block text-xs font-medium text-gray-700 mb-1">Indexer Run</label>
155+
<pre className="text-sm bg-gray-50 p-2 rounded whitespace-pre-wrap">
156+
{selectedEntry.addedInIndexRun}
157+
</pre>
158+
</div>
152159
</div>
153160
</div>
154161
) : (

plugins/global-search/src/utils/db.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ export class GlobalSearchDatabase implements ResumableAsyncIterable<IndexEntry>
5050
const tx = db.transaction("entries", "readonly")
5151
const store = tx.objectStore("entries")
5252

53-
const keyRange = startKey ? IDBKeyRange.lowerBound(startKey) : undefined
53+
// Use exclusive lower bound (true) to avoid re-processing the startKey item when resuming
54+
const keyRange = startKey ? IDBKeyRange.lowerBound(startKey, true) : undefined
5455
let cursor = await store.openCursor(keyRange)
5556

5657
try {

plugins/global-search/src/utils/indexer/indexer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
type AnyNode,
3-
Collection,
3+
type Collection,
44
framer,
55
isComponentNode,
66
isFrameNode,
@@ -198,7 +198,7 @@ export class GlobalSearchIndexer {
198198
// this isn't a unnecassary static expression, as the value could change during the async loop
199199
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
200200
if (!this.abortRequested) {
201-
await this.db.clearEntriesFromBefore(lastIndexRun)
201+
await this.db.clearEntriesFromBefore(currentIndexRun)
202202
this.eventEmitter.emit("completed")
203203
}
204204
} catch (error) {

0 commit comments

Comments
 (0)