-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
133 lines (131 loc) · 3.99 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import { Notice, Plugin, moment } from 'obsidian';
import PersonalOSSettings from './src/Component/Settings/SettingsTab';
import Engage from 'src/Component/Engage';
import EngageCurrentFile from 'src/Component/EngageCurrentFile';
import StartProcess from 'src/Component/StartProcess';
import ContextGraph from 'src/Component/ContextGraph';
import XpFeedback from 'src/Component/XpFeedback';
import TaskFailer from 'src/Component/TaskFailer';
import SnoozeModal from 'src/Modal/SnoozeModal';
import RandomSnoozeModal from 'src/Modal/RandomSnoozeModal';
import ChangelogModal from 'src/Modal/ChangelogModal';
import ProgressBar from 'src/Component/ProgressBar';
export default class PersonalOS extends Plugin {
settings: PersonalOSSettings;
engage: Engage;
engageCurrentFile: EngageCurrentFile;
startProcess: StartProcess;
graph: ContextGraph;
taskFailer: TaskFailer;
hideTasks: boolean;
xpFeedback: XpFeedback | null;
async onload(){
customElements.define('progress-bar', ProgressBar);
this.hideTasks = false;
this.app.workspace.onLayoutReady(async () => {
this.settings = new PersonalOSSettings(this.app, this);
await this.settings.loadSettings();
this.addSettingTab(this.settings);
this.checkForUpdate();
this.graph = new ContextGraph(this.app, this.settings.officePages, {multi:true, type:"mixed", allowSelfLoops:true});
this.taskFailer = new TaskFailer(this.app, this.graph);
this.engage = new Engage(this.app, this.settings.randomEvents, this.graph, this.settings.configFolder, this.settings.probabilityRandomEvents);
this.engageCurrentFile = new EngageCurrentFile(this.app);
this.startProcess = new StartProcess(this.app, this.graph, this.settings.inboxPages, this.settings.configFolder);
if(this.settings.toggleXp){
this.xpFeedback = new XpFeedback(this.app);
this.registerEvent(this.app.metadataCache.on('changed', this.xpFeedback.displayXpEarned));
}
this.loadCommands();
});
}
manageToggle = () => {
if(this.settings.toggleXp && !this.xpFeedback){
this.xpFeedback = new XpFeedback(this.app);
this.registerEvent(this.app.metadataCache.on('changed', this.xpFeedback.displayXpEarned));
}else if(!this.settings.toggleXp && this.xpFeedback){
this.app.metadataCache.off('changed', this.xpFeedback.displayXpEarned);
this.xpFeedback = null;
}
}
loadCommands = () =>{
this.addCommand({
id:"start-work",
name:"Engage",
callback:()=>{
this.engage.findNextFile();
}
});
this.addCommand({
id:"start-work-current-file",
name:"Engage Current File",
callback:()=>{
this.engageCurrentFile.findNextFile();
}
});
this.addCommand({
id:"start-process",
name:"Process",
callback:()=>{
this.startProcess.findNextFile();
}
});
this.addCommand({
id:"set-focus",
name:"Set focus",
callback:()=>{
this.engage.setManuallyFocus();
}
});
this.addCommand({
id:"reload-graph",
name:"Reload graph",
callback: ()=>{
this.graph.reload();
}
});
this.addCommand({
id:"auto-fail-tasks",
name:"Auto fail current file",
callback: ()=>{
this.taskFailer.failTask(null, true);
}
});
this.addCommand({
id:"auto-fail-wip-tasks",
name:"Auto fail work in progress files",
callback: ()=>{
this.taskFailer.autoFailVaultTask();
}
});
this.addCommand({
id:"snooze-tasks",
name:"Snooze tasks",
callback:()=>{
new SnoozeModal(this.app).open();
}
});
this.addCommand({
id:"random-snooze-tasks",
name:"Random snooze tasks",
callback:()=>{
new RandomSnoozeModal(this.app).open();
}
});
this.addCommand({
id:"toggle-task-hider",
name:"Toggle task hider",
callback:()=>{
this.hideTasks = !this.hideTasks;
document.body.toggleClass('hide-finished-tasks', this.hideTasks);
}
});
}
checkForUpdate = () => {
if(this.settings.enableChangelog && this.manifest.version != this.settings.currentVersion){
new ChangelogModal(this.app).open();
this.settings.currentVersion = this.manifest.version;
this.settings.saveSettings();
}
}
}