Skip to content

Commit

Permalink
Merge pull request #69 from saertna/Check-If-Daily-Changed
Browse files Browse the repository at this point in the history
Load settings to discover changes from other instance and abort updat…
  • Loading branch information
saertna authored Mar 20, 2024
2 parents 445d384 + fdb4475 commit 99ed95c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default class gamification extends Plugin implements GamificationMediator
this.saveSettings();
}


setSettingBoolean(key: string, value: boolean) {
// Set a specific setting
this.settings[key] = encryptBoolean(value);
Expand Down Expand Up @@ -742,11 +742,12 @@ export default class gamification extends Plugin implements GamificationMediator

async resetDailyGoals(){
let reset = false;
await this.loadSettings()
if(!isSameDay(window.moment(this.getSettingString('dailyNoteCreationDate'), 'DD.MM.YYYY'))){
this.setSettingNumber('dailyNoteCreationTask', 0);
this.setSettingString('dailyNoteCreationDate', window.moment().format('DD.MM.YYYY'))
await this.saveSettings();
if(debugLogs) console.debug(`daily Challenge reseted`)
if(debugLogs) console.debug(`reset daily Challenge`)
reset = true;
}
if(!isOneDayBefore(window.moment(this.getSettingString('weeklyNoteCreationDate'), 'DD.MM.YYYY')) && !isSameDay(window.moment(this.getSettingString('weeklyNoteCreationDate'), 'DD.MM.YYYY'))){
Expand All @@ -758,7 +759,7 @@ export default class gamification extends Plugin implements GamificationMediator
if(debugLogs) console.debug(`${daysPassed} days passed`)
await this.saveSettings();
await this.updateStatusBar(this.statusbarGamification)
if(debugLogs) console.debug(`weekly Challenge reseted`)
if(debugLogs) console.debug(`reset weekly Challenge`)
reset = true;
}
if(isOneDayBefore(window.moment(this.getSettingString('weeklyNoteCreationDate'), 'DD.MM.YYYY')) && this.getSettingNumber('weeklyNoteCreationTask') == 7){
Expand Down

0 comments on commit 99ed95c

Please sign in to comment.