fix: bugs with history push
fix: ui font
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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%);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface HistoryEntry {
|
||||
export interface HistoryRepository {
|
||||
getAll(): Promise<HistoryEntry[]>;
|
||||
add(content: string): Promise<HistoryEntry>;
|
||||
getLast(): Promise<HistoryEntry | null>;
|
||||
}
|
||||
|
||||
class SQLiteHistoryRepository implements HistoryRepository {
|
||||
@@ -29,6 +30,18 @@ class SQLiteHistoryRepository implements HistoryRepository {
|
||||
}));
|
||||
}
|
||||
|
||||
async getLast(): Promise<HistoryEntry | null> {
|
||||
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<HistoryEntry> {
|
||||
const [row] = await this.db.exec('INSERT INTO history (content) VALUES (?) RETURNING *', [
|
||||
content
|
||||
|
||||
@@ -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<Table[]>([]);
|
||||
@@ -149,7 +157,6 @@
|
||||
|
||||
&:is(:hover, :focus-within):not(:disabled) {
|
||||
cursor: pointer;
|
||||
background-color: hsl(0deg 0% 15%);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user