Skip to content

Commit

Permalink
feat: reset container number on startup (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
stoically committed Nov 2, 2019
1 parent d2781cc commit 728bdc9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@
"optionsGeneralContainerNumberKeepCounting": {
"message": "Keep counting (default)"
},
"optionsGeneralContainerNumberKeepCountingUntilRestart": {
"message": "Keep counting until browser restart"
},
"optionsGeneralContainerNumberReuseNumbers": {
"message": "Reuse available numbers"
},
Expand Down
2 changes: 1 addition & 1 deletion src/background/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Container {

getContainerNameIconColor(url) {
let tempContainerNumber;
if (this.pref.container.numberMode === 'keep') {
if (this.pref.container.numberMode.startsWith('keep')) {
this.storage.local.tempContainerCounter++;
tempContainerNumber = this.storage.local.tempContainerCounter;
}
Expand Down
10 changes: 8 additions & 2 deletions src/background/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,14 @@ class Runtime {

async onStartup() {
// queue a container cleanup
await delay(15000);
this.container.cleanup(true);
delay(15000).then(() =>
this.container.cleanup(true)
);

if (this.pref.container.numberMode === 'keepuntilrestart') {
this.storage.local.tempContainerCounter = 0;
this.storage.persist();
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/ui/components/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ export default {
<option value="keep">
{{ t('optionsGeneralContainerNumberKeepCounting') }}
</option>
<option value="keepuntilrestart">
{{ t('optionsGeneralContainerNumberKeepCountingUntilRestart') }}
</option>
<option value="reuse">
{{ t('optionsGeneralContainerNumberReuseNumbers') }}
</option>
Expand Down

0 comments on commit 728bdc9

Please sign in to comment.