Skip to content

Commit

Permalink
Add favorite commands to history (fixes #13)
Browse files Browse the repository at this point in the history
  • Loading branch information
misaki-web committed Feb 22, 2023
1 parent 20af21d commit ae59a03
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/app-integrator-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class AppIntegratorFactory {
}

private get historyStore() {
this.cache.historyStore = this.cache.historyStore || new HistoryStore();
this.cache.historyStore = this.cache.historyStore || new HistoryStore(this.workspaceAdapter);
return this.cache.historyStore;
}

Expand Down
13 changes: 11 additions & 2 deletions src/lib/history-store.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import {EXTENSION_NAME} from './const';
import {Workspace} from './adapters/workspace';

interface FavoriteCommand {
id: string;
command: string;
}

export class HistoryStore {
private history: string[];

constructor() {
this.history = [];
constructor(private readonly workspaceAdapter: Workspace) {
this.workspaceAdapter = workspaceAdapter;
const favoriteCommands = this.workspaceAdapter.getConfig<FavoriteCommand[]>(`${EXTENSION_NAME}.favoriteCommands`);
this.history = favoriteCommands.filter(o => o.command).map(o => o.command);
}

getAll() {
Expand Down

0 comments on commit ae59a03

Please sign in to comment.