Skip to content

Commit

Permalink
Merge pull request #33 from saertna/Delay-Load
Browse files Browse the repository at this point in the history
Delay load
  • Loading branch information
saertna committed Nov 1, 2023
2 parents ef5511e + ffbcb76 commit e110b8f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 66 deletions.
28 changes: 13 additions & 15 deletions main.js

Large diffs are not rendered by default.

47 changes: 9 additions & 38 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
pointsNoteMajurity,
pointsForDailyChallenge,
pointsForWeeklyChallenge,
incrediments,
elements,
boosterRecipes,
streakboosterDecrease,
Expand Down Expand Up @@ -62,12 +61,6 @@ export default class gamification extends Plugin {
public settings: ISettings;


/*getSetting(key: string) {
// Retrieve a specific setting
// return this.settings[key];
return this.settings[key] !== undefined ? this.settings[key] : null;
}*/

getSettingString(key: string) {
const decryptedValue = this.settings[key] !== undefined ? this.settings[key].toString() : ''
//console.log(`String: decrypted ${key} is ${decryptString(decryptedValue)}`)
Expand All @@ -87,13 +80,6 @@ export default class gamification extends Plugin {
}


/*setSetting(key: string, value: number) {
// Set a specific setting
//console.log(`new value for ${key} is ${value}`)
this.settings[key] = value;
this.saveSettings();
}*/

setSettingString(key: string, value: string) {
// Set a specific setting
const valueEncrypted = encryptString(value)
Expand Down Expand Up @@ -132,29 +118,26 @@ export default class gamification extends Plugin {
console.log('obsidian-pkm-gamification loaded!');
//this.settings = defaultSettings;





await this.loadSettings();



this.addSettingTab(new GamificationPluginSettings(this.app, this));


/*
await this.loadSettings();

// take care to reset when opened on a new day, don't wait for trigger
setTimeout(async () => {
// Code that you want to execute after the delay
await this.loadSettings();
await this.resetDailyGoals()
}, 2000); // 2000 milliseconds = 2 seconds
*/
await this.updateStatusBar(this.statusbarGamification)
}, this.getSettingNumber('delayLoadTime')*1000); // 2000 milliseconds = 2 seconds


// to set timer for reset daily and weekly goals
this.timerInterval = 30 * 60 * 1000; // minutes x seconds x milliseconds
this.timerId = window.setInterval(this.resetDailyGoals.bind(this), this.timerInterval);

await this.updateStatusBar(this.statusbarGamification)



if (this.getSettingBoolean('debug')){
Expand Down Expand Up @@ -231,19 +214,7 @@ export default class gamification extends Plugin {
});
}

/*
// command: update chart in Avatar Page
this.addCommand({
id: 'update-chart-avatarpage',
name: 'update chart on profile page',
callback: async () => {
const { vault } = app;
const chartString = await this.createChart(vault)
await replaceChartContent(this.getSettingString('avatarPageName'), chartString)
},
});
*/


// command: rate note maturity
this.addCommand({
id: 'rate-note-maturity',
Expand Down
26 changes: 13 additions & 13 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export const defaultSettings: Partial<ISettings> = {
boosterUseCountEphemeralEuphoria: "U2FsdGVkX191hJANYr8JHI1bn1YRrJfBh0cQ0vgkKRM=",
boosterUseCountFortuneInfusion: "U2FsdGVkX191hJANYr8JHI1bn1YRrJfBh0cQ0vgkKRM=",
counterMajurityCalc: "U2FsdGVkX19TLndonGY4Y8vHuZFfLJ5gZ2t/CLprh0o=",
counterMajurityCalcInitial: "U2FsdGVkX1+2Qii8qhFSqrNqmKR1Wh6saEjYbwPdi8Q="
counterMajurityCalcInitial: "U2FsdGVkX1+2Qii8qhFSqrNqmKR1Wh6saEjYbwPdi8Q=",
delayLoadTime: "U2FsdGVkX19TLndonGY4Y8vHuZFfLJ5gZ2t/CLprh0o="
};

export interface DynamicSettings {
Expand Down Expand Up @@ -173,14 +174,14 @@ export interface ISettings extends DynamicSettings{
boosterUseCountEphemeralEuphoria: string;
counterMajurityCalc: string;
counterMajurityCalcInitial: string;
delayLoadTime: string
//[key: string]: number | string | boolean | MomentInput;
}


export class GamificationPluginSettings extends PluginSettingTab {
private readonly plugin: gamification;
public settings: ISettings;

public enableInitCommand: string;
public bindEnter: string;
public bindTab: string;
Expand Down Expand Up @@ -260,6 +261,7 @@ export class GamificationPluginSettings extends PluginSettingTab {
public boosterUseCountEphemeralEuphoria: string;
public counterMajurityCalc: string;
public counterMajurityCalcInitial: string;
public delayLoadTime: string;

constructor(app: App, plugin: gamification) {
super(app, plugin);
Expand Down Expand Up @@ -358,20 +360,18 @@ export class GamificationPluginSettings extends PluginSettingTab {
}),
);

/*
new Setting(containerEl)
.setName('limit the visible month in the chart on your avatar page: ' + this.plugin.settings.avatarPageName)
.setDesc('if 0, all month will be shown. Enter a number how many month shall be shown.')
new Setting(containerEl)
.setName('Delay Settings at startup')
.setDesc('Enter in seconds to delay the load time. e.g. when GIT pull is performed before and settings get merge conflicts. Without GIT usage, keep it to 0.')
.addText(text => text
.setPlaceholder('Number of Month to show')
//.setValue(decryptNumber(this.plugin.settings.chartReduzierungMonate).toString())
.setValue("0")
.setPlaceholder('0')
.setValue(decryptNumber(this.plugin.settings.delayLoadTime).toString())
//.setValue("0")
.onChange(async (value) => {
this.plugin.settings.chartReduzierungMonate = encryptNumber(parseInt(value));
this.plugin.settings.delayLoadTime = encryptNumber(parseInt(value));
await this.plugin.saveSettings();
}));
*/

}));

new Setting(containerEl)
.setName('Progressive Summarization')
Expand Down

0 comments on commit e110b8f

Please sign in to comment.