Skip to content

Commit

Permalink
Dark mode for the browser action popup (#530)
Browse files Browse the repository at this point in the history
* Add a dark theme for the browser action popup. 
* Speed up the template insert autocomplete method, by tweaking the way we update stats and waiting for the plugins to finish running.
* Increase the average words-per-minute (used for calculating time saved) to 35.
  • Loading branch information
ghinda authored Mar 12, 2024
1 parent 1a3e846 commit c07ce93
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 132 deletions.
158 changes: 80 additions & 78 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "briskine",
"version": "7.12.1",
"version": "7.12.2",
"description": "Write everything faster.",
"private": true,
"type": "module",
Expand Down
16 changes: 4 additions & 12 deletions src/content/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,8 @@ export function getSelectedWord (params) {
}
}

export function autocomplete (params) {
runPlugins(Object.assign({}, params))

store.updateTemplateStats(params.quicktext.id)

// updates word stats
const wordCount = (params.quicktext._body_plaintext || '').split(' ').length
store.getExtensionData().then((data) => {
store.setExtensionData({
words: data.words + wordCount
})
})
export async function autocomplete (params) {
await runPlugins(Object.assign({}, params))
await store.updateTemplateStats(params.quicktext)
return params
}
2 changes: 1 addition & 1 deletion src/content/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async function keyboardAutocomplete (e) {
getSelection(element).setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset)
}

return autocomplete({
autocomplete({
element: element,
quicktext: template,
word: word,
Expand Down
25 changes: 12 additions & 13 deletions src/content/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@
* Plugin
*/

var plugins = [];
var plugins = []
export function register (plugin) {
plugins.push(plugin);
plugins.push(plugin)
}

// sequentially run promises until one returns true, or we reach the end
export function run (params = {}, index = 0) {
var plugin = plugins[index];
if (!plugin) {
return true;
}
export async function run (params = {}, index = 0) {
var plugin = plugins[index]
if (!plugin) {
return true
}

return Promise.resolve().then(() => plugin(params)).then((done) => {
if (done === true) {
return true;
}
const done = await Promise.resolve().then(() => plugin(params))
if (done === true) {
return true
}

return run(params, index + 1);
});
return run(params, index + 1)
}

Loading

0 comments on commit c07ce93

Please sign in to comment.