diff --git a/src/lib/components/History.svelte b/src/lib/components/History.svelte index b2740c7..8cc3f39 100644 --- a/src/lib/components/History.svelte +++ b/src/lib/components/History.svelte @@ -52,7 +52,7 @@ .time { font-size: 10px; - color: hsl(0deg 0% 96%); + color: hsl(0deg 0% 70%); } li { @@ -62,6 +62,7 @@ cursor: default; user-select: none; -webkit-user-select: none; + font-weight: 500; &:is(:focus-within) { outline: none; diff --git a/src/lib/components/Queries/Queries.svelte b/src/lib/components/Queries/Queries.svelte index f13c8eb..fad916d 100644 --- a/src/lib/components/Queries/Queries.svelte +++ b/src/lib/components/Queries/Queries.svelte @@ -154,11 +154,12 @@ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + font-weight: 500; } & > span.time { font-size: 10px; - color: hsl(0deg 0% 96%); + color: hsl(0deg 0% 60%); } } diff --git a/src/lib/repositories/history.ts b/src/lib/repositories/history.ts index 79ee58a..033a771 100644 --- a/src/lib/repositories/history.ts +++ b/src/lib/repositories/history.ts @@ -13,6 +13,7 @@ export interface HistoryEntry { export interface HistoryRepository { getAll(): Promise; add(content: string): Promise; + getLast(): Promise; } class SQLiteHistoryRepository implements HistoryRepository { @@ -29,6 +30,18 @@ class SQLiteHistoryRepository implements HistoryRepository { })); } + async getLast(): Promise { + const [row] = await this.db.exec('SELECT * FROM history ORDER BY timestamp DESC LIMIT 1'); + if (!row) return null; + return { + id: row.id as number, + content: row.content as string, + timestamp: dayjs(row.timestamp as string) + .utc(true) + .toDate() + }; + } + async add(content: string): Promise { const [row] = await this.db.exec('INSERT INTO history (content) VALUES (?) RETURNING *', [ content diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 9f1088d..151f95e 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -22,10 +22,18 @@ let loading = $state(false); async function handleExec() { - if (loading) return; + if (loading || !query) { + return; + } + loading = true; response = await engine.exec(query).finally(() => (loading = false)); - if (response) await addHistoryEntry(); + + const last = await history_repository.getLast(); + + if (response && last?.content !== query) { + await addHistoryEntry(); + } } let tables = $state.raw([]); @@ -149,7 +157,6 @@ &:is(:hover, :focus-within):not(:disabled) { cursor: pointer; - background-color: hsl(0deg 0% 15%); } }