Skip to content

Commit

Permalink
feat(search): add max length to history
Browse files Browse the repository at this point in the history
  • Loading branch information
deansallinen committed Oct 4, 2024
1 parent da0b7ce commit ec60e6e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/state/search.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ type SearchResult = {
searchType: string;
};

const maxHistoryLength = 10;

export const history = $state<SearchResult[]>([]);

export function addHistory(s: SearchResult) {
history.unshift(s);
if (history.length > maxHistoryLength) {
history.splice(maxHistoryLength);
}
}

0 comments on commit ec60e6e

Please sign in to comment.