Skip to content

Commit e2fb205

Browse files
author
Jhih-Lin Jhou
committed
separage storage key for conversion and instruction
1 parent ad02f16 commit e2fb205

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/lib/common/shared/TimeRangePicker.svelte

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import { clickoutsideDirective } from '$lib/helpers/directives';
88
99
// Constants
10-
const RECENT_TIME_RANGES_KEY = 'botsharp_recent_time_ranges';
1110
const MAX_RECENT_ITEMS = 10;
1211
const TAB_RELATIVE = 'relative';
1312
const TAB_RECENT = 'recent';
@@ -48,6 +47,9 @@
4847
/** @type {Array<{ startDate: string, endDate: string, label: string, timeRange?: string }>} */
4948
let recentTimeRanges = [];
5049
50+
/** @type {string} */
51+
export let storageKey = 'botsharp_recent_time_ranges';
52+
5153
// Format date for flatpickr (Date object to YYYY-MM-DD string)
5254
/** @param {Date} date */
5355
function formatDateForFlatpickr(/** @type {Date} */ date) {
@@ -197,7 +199,7 @@
197199
198200
function loadRecentTimeRanges() {
199201
try {
200-
const stored = localStorage.getItem(RECENT_TIME_RANGES_KEY);
202+
const stored = localStorage.getItem(storageKey);
201203
if (stored) {
202204
recentTimeRanges = JSON.parse(stored);
203205
}
@@ -248,15 +250,15 @@
248250
// Add to beginning and limit to MAX_RECENT_ITEMS
249251
recentTimeRanges = [newRange, ...recentTimeRanges].slice(0, MAX_RECENT_ITEMS);
250252
251-
localStorage.setItem(RECENT_TIME_RANGES_KEY, JSON.stringify(recentTimeRanges));
253+
localStorage.setItem(storageKey, JSON.stringify(recentTimeRanges));
252254
} catch (e) {}
253255
}
254256
255257
/** @param {number} index */
256258
function removeRecentTimeRange(index) {
257259
recentTimeRanges = recentTimeRanges.filter((_, idx) => idx !== index);
258260
try {
259-
localStorage.setItem(RECENT_TIME_RANGES_KEY, JSON.stringify(recentTimeRanges));
261+
localStorage.setItem(storageKey, JSON.stringify(recentTimeRanges));
260262
} catch (e) {}
261263
}
262264

src/routes/page/conversation/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@
505505
</Col>
506506
<Col lg="2">
507507
<TimeRangePicker
508+
storageKey="botsharp_conversation_recent_time_ranges"
508509
bind:timeRange={searchOption.timeRange}
509510
bind:startDate={searchOption.startDate}
510511
bind:endDate={searchOption.endDate}

src/routes/page/instruction/log/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@
370370
</Col>
371371
<Col lg="2">
372372
<TimeRangePicker
373+
storageKey="botsharp_instruction_recent_time_ranges"
373374
bind:timeRange={searchOption.timeRange}
374375
bind:startDate={searchOption.startDate}
375376
bind:endDate={searchOption.endDate}

0 commit comments

Comments
 (0)