-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.0.8
- Loading branch information
Showing
13 changed files
with
112 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
import { existsSync, readFileSync, writeFileSync } from "fs"; | ||
import { app } from 'electron'; | ||
import { config } from '../config'; | ||
import { stringMatchQuality } from '../../common/util'; | ||
import { getTranslation } from '../../common/local/locale'; | ||
import path from 'path'; | ||
|
||
let execute_history = []; | ||
|
||
const history_filename = 'history.json'; | ||
|
||
function loadHistory() { | ||
const history_path = path.join(app.getPath('userData'), history_filename); | ||
if (existsSync(history_path)) { | ||
try { | ||
execute_history = JSON.parse(readFileSync(history_path, { encoding: 'utf8' })); | ||
} catch (e) { } | ||
} | ||
writeFileSync(history_path, JSON.stringify(execute_history), { encoding: 'utf8' }); | ||
} | ||
|
||
function updateHistory() { | ||
const history_path = path.join(app.getPath('userData'), history_filename); | ||
writeFileSync(history_path, JSON.stringify(execute_history), { encoding: 'utf8' }); | ||
} | ||
|
||
const HistoryModule = { | ||
init: async () => { | ||
if (config.modules.history.active) { | ||
loadHistory(); | ||
} | ||
}, | ||
valid: (query) => { | ||
return config.modules.history.active && query.trim().length == 0; | ||
}, | ||
search: async (query) => { | ||
return execute_history.map((option) => ({ | ||
...option, | ||
quality: config.modules.history.quality, | ||
})); | ||
}, | ||
globalExecute: async (option) => { | ||
if (config.modules.history.active) { | ||
let existing = new Set(); | ||
execute_history = [option].concat(execute_history).filter((el) => { | ||
let value = (el.type || "") + (el.text || "") + (el.primary || "") + (el.secondary || "") + (el.html || ""); | ||
if (!existing.has(value)) { | ||
existing.add(value); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}).slice(0, config.modules.history.maximum_history); | ||
updateHistory(); | ||
} | ||
}, | ||
} | ||
|
||
export default HistoryModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters