Skip to content

Commit ed2ae3a

Browse files
committed
chore: clear local search cache on hmr
1 parent 878f437 commit ed2ae3a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Diff for: src/client/theme-default/components/VPLocalSearchBox.vue

+5
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ const cache = new LRUCache<string, Map<string, string>>(16) // 16 files
148148
debouncedWatch(
149149
() => [searchIndex.value, filterText.value, showDetailedList.value] as const,
150150
async ([index, filterTextValue, showDetailedListValue], old, onCleanup) => {
151+
152+
if (old?.[0] !== index) { // in case of hmr
153+
cache.clear()
154+
}
155+
151156
let canceled = false
152157
onCleanup(() => {
153158
canceled = true

Diff for: src/client/theme-default/support/lru.ts

+4
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ export class LRUCache<K, V> {
3030
first(): K | undefined {
3131
return this.cache.keys().next().value
3232
}
33+
34+
clear(): void {
35+
this.cache.clear()
36+
}
3337
}

0 commit comments

Comments
 (0)