Skip to content

Commit

Permalink
Merge pull request #39 from saertna/time-for-notice
Browse files Browse the repository at this point in the history
Setting Value how long Notice to show
  • Loading branch information
saertna authored Nov 7, 2023
2 parents b88e526 + e3a44eb commit 0eb9780
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 26 deletions.
31 changes: 18 additions & 13 deletions main.js

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,13 @@ export default class gamification extends Plugin {
} catch (e) {
if (e?.name === 'YAMLParseError') {
const errorMessage = `Update majuritys failed Malformed frontamtter on this file : ${file.path} ${e.message}`;
new Notice(errorMessage, 4000);
new Notice(errorMessage, this.getSettingNumber('timeShowNotice') * 1000);
console.error(errorMessage);
}
}
}
if (pointsReceived > 0) {
new Notice(`${pointsReceived} Points received`,4000)
new Notice(`${pointsReceived} Points received`,this.getSettingNumber('timeShowNotice') * 1000)
console.log(`${pointsReceived} Points received`)
}

Expand All @@ -374,7 +374,7 @@ export default class gamification extends Plugin {
setTimeout(async () => {
// Code that you want to execute after the delay
const initBadge: Badge = getBadgeForInitLevel(this.getSettingNumber('statusLevel'));
new Notice(`You've earned the "${initBadge.name}" badge. ${initBadge.description}`,5000)
new Notice(`You've earned the "${initBadge.name}" badge. ${initBadge.description}`,this.getSettingNumber('timeShowNotice') * 1000 * 1.2)
console.log(`You earned ${initBadge.name} - ${initBadge.description}`)
await this.giveInitBadgeInProfile(this.getSettingString('avatarPageName'), initBadge);
await this.removeBadgesWhenInitLevelHigher(this.getSettingString('avatarPageName'), this.getSettingNumber('statusLevel'))
Expand Down Expand Up @@ -539,7 +539,7 @@ export default class gamification extends Plugin {
//console.log(`pointsReceived: ${pointsReceived}`)
if (pointsReceived > 0){
const messagePoints = getRandomMessagePoints(pointsReceived);
new Notice(messagePoints,4000)
new Notice(messagePoints,this.getSettingNumber('timeShowNotice') * 1000)
console.log(messagePoints)
}

Expand All @@ -549,7 +549,7 @@ export default class gamification extends Plugin {
} catch (e) {
if (e?.name === 'YAMLParseError') {
const errorMessage = `Update majuritys failed Malformed frontamtter on this file : ${file.path} ${e.message}`;
new Notice(errorMessage, 4000);
new Notice(errorMessage, this.getSettingNumber('timeShowNotice') * 1000);
console.error(errorMessage);
}
}
Expand Down Expand Up @@ -655,7 +655,7 @@ export default class gamification extends Plugin {
await this.giveStatusPoints(pointsForDailyChallenge,'formIncreaseDailyCreatedNoteCount')
const message = getRandomMessageTwoNoteChallenge(pointsForDailyChallenge * (this.getSettingNumber('badgeBoosterFactor') + this.getSettingNumber('streakbooster')));
console.log(`daily Challenge reached! ${newDailyNoteCreationTask}/2 created.`)
new Notice(message,4000)
new Notice(message,this.getSettingNumber('timeShowNotice') * 1000)
console.log(message)
} else {
// nothing else to do here
Expand Down Expand Up @@ -704,7 +704,7 @@ export default class gamification extends Plugin {
await this.giveStatusPoints(pointsForWeeklyChallenge, 'fromCheckForWeeklyNoteChallengeEvaluation')
console.log(`Weekly Challenge reached! ${newWeeklyNoteCreationTask}/7 created in a chain.`)
const message = getRandomMessageWeeklyChallenge(pointsForWeeklyChallenge * (this.getSettingNumber('badgeBoosterFactor') + this.getSettingNumber('streakbooster')));
new Notice(message,4000)
new Notice(message,this.getSettingNumber('timeShowNotice') * 1000)
console.log(message)
} else {
// nothing else to do here
Expand Down Expand Up @@ -891,7 +891,7 @@ export default class gamification extends Plugin {
let receiveBadge = false
if (this.getSettingNumber('statusLevel') < level.level){
// Level Up archived
new Notice(`With ${newPoints} points, the current level is ${level.level}.`,5000)
new Notice(`With ${newPoints} points, the current level is ${level.level}.`,this.getSettingNumber('timeShowNotice') * 1000 * 1.2)
// check first if this means a new badge before it gets overwritten
receiveBadge = checkIfReceiveABadge(this.getSettingNumber('statusLevel'), level.level)
this.setSettingNumber('statusLevel', level.level);
Expand Down Expand Up @@ -1109,7 +1109,7 @@ export default class gamification extends Plugin {
newLevel.then((result: boolean)=> {
if(result){
const badge : Badge = getBadgeForLevel(this.getSettingNumber('statusLevel'), false)
new Notice(`You've earned the "${badge.name}" badge. ${badge.description}`,5000)
new Notice(`You've earned the "${badge.name}" badge. ${badge.description}`,this.getSettingNumber('timeShowNotice') * 1000 * 1.2)
console.log(`You've earned the "${badge.name}" badge. ${badge.description}`)
this.giveBadgeInProfile(this.getSettingString('avatarPageName'), badge)
this.setSettingBoolean('badgeBoosterState', false);
Expand Down Expand Up @@ -1143,7 +1143,7 @@ export default class gamification extends Plugin {
} catch (e) {
if (e?.name === 'YAMLParseError') {
const errorMessage = `Update majuritys failed Malformed frontamtter ${e.message}`;
new Notice(errorMessage, 4000);
new Notice(errorMessage, this.getSettingNumber('timeShowNotice') * 1000);
console.error(errorMessage);
}
}
Expand Down Expand Up @@ -1220,7 +1220,7 @@ export default class gamification extends Plugin {
}
}
console.log(`You earned: ${concatenateStrings(earnedIngredientToShow)}`);
new Notice(`You earned ${concatenateStrings(earnedIngredientToShow)}`,3000)
new Notice(`You earned ${concatenateStrings(earnedIngredientToShow)}`,this.getSettingNumber('timeShowNotice') * 1000)
} else {
console.log('You did not earn an ingredient this time.');
}
Expand Down
18 changes: 16 additions & 2 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export const defaultSettings: Partial<ISettings> = {
boosterUseCountFortuneInfusion: "U2FsdGVkX191hJANYr8JHI1bn1YRrJfBh0cQ0vgkKRM=",
counterMajurityCalc: "U2FsdGVkX19TLndonGY4Y8vHuZFfLJ5gZ2t/CLprh0o=",
counterMajurityCalcInitial: "U2FsdGVkX1+2Qii8qhFSqrNqmKR1Wh6saEjYbwPdi8Q=",
delayLoadTime: "U2FsdGVkX19TLndonGY4Y8vHuZFfLJ5gZ2t/CLprh0o="
delayLoadTime: "U2FsdGVkX19TLndonGY4Y8vHuZFfLJ5gZ2t/CLprh0o=",
timeShowNotice: "U2FsdGVkX190u8cOsylOs1cQ8MeZFq+i+Wv4ox6qq0k="
};

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

Expand Down Expand Up @@ -262,6 +264,7 @@ export class GamificationPluginSettings extends PluginSettingTab {
public counterMajurityCalc: string;
public counterMajurityCalcInitial: string;
public delayLoadTime: string;
public timeShowNotice: string;

constructor(app: App, plugin: gamification) {
super(app, plugin);
Expand Down Expand Up @@ -373,6 +376,17 @@ export class GamificationPluginSettings extends PluginSettingTab {
await this.plugin.saveSettings();
}));

new Setting(containerEl)
.setName('Time how long Notices are shown')
.setDesc('Enter in seconds. 4 seconds or more is a good value')
.addText(text => text
.setPlaceholder('4')
.setValue(decryptNumber(this.plugin.settings.timeShowNotice).toString())
.onChange(async (value) => {
this.plugin.settings.timeShowNotice = encryptNumber(parseInt(value));
await this.plugin.saveSettings();
}));

new Setting(containerEl)
.setName('Progressive Summarization')
.setDesc('you can change which formatting you use for Layer 2 and 3.')
Expand Down

0 comments on commit 0eb9780

Please sign in to comment.