Skip to content

Commit

Permalink
Removing unused settings and adding status bar text
Browse files Browse the repository at this point in the history
  • Loading branch information
heliostatic committed Jan 5, 2021
1 parent 8fd9c89 commit 1b0c8e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
40 changes: 11 additions & 29 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
import { App, Plugin, PluginSettingTab, Setting, addIcon} from 'obsidian';
import { brotliDecompressSync } from 'zlib';

interface TaskHiderSettings {
hide: boolean;
}

const DEFAULT_SETTINGS: TaskHiderSettings = {
hide: false
}
import { App, Plugin, addIcon} from 'obsidian';

export default class TaskHiderPlugin extends Plugin {
settings: TaskHiderSettings;

async onload() {
console.log('loading plugin');

await this.loadSettings();
console.log('loading completed-task-display plugin');

let statusBar = this.addStatusBarItem();
statusBar.setText('Showing Completed Tasks');

addIcon('tasks', taskShowIcon);
this.addRibbonIcon('tasks', 'Task Hider', () => {
document.body.toggleClass('hide-completed-tasks', this.settings.hide);
this.settings.hide = !this.settings.hide;
// this.addStatusBarItem().setText(this.settings.hide ? 'Showing Completed Tasks' : 'Hiding Completed Tasks');
this.saveSettings()
document.body.toggleClass('hide-completed-tasks', hiddenState);
hiddenState = !hiddenState;
statusBar.setText(hiddenState ? 'Showing Completed Tasks' : 'Hiding Completed Tasks');
});
}

onunload() {
console.log('unloading plugin');
}

async loadSettings() {
this.settings = Object.assign(DEFAULT_SETTINGS, await this.loadData());
}

async saveSettings() {
await this.saveData(this.settings);
console.log('unloading completed-task-display plugin');
}
}
const taskShowIcon = `<svg aria-hidden="true" focusable="false" data-prefix="fal" data-icon="tasks" class="svg-inline--fa fa-tasks fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M145.35 207a8 8 0 0 0-11.35 0l-71 71-39-39a8 8 0 0 0-11.31 0L1.35 250.34a8 8 0 0 0 0 11.32l56 56a8 8 0 0 0 11.31 0l88-88a8 8 0 0 0 0-11.32zM62.93 384c-17.67 0-32.4 14.33-32.4 32s14.73 32 32.4 32a32 32 0 0 0 0-64zm82.42-337A8 8 0 0 0 134 47l-71 71-39-39a8 8 0 0 0-11.31 0L1.35 90.34a8 8 0 0 0 0 11.32l56 56a8 8 0 0 0 11.31 0l88-88a8 8 0 0 0 0-11.32zM503 400H199a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h304a8 8 0 0 0 8-8v-16a8 8 0 0 0-8-8zm0-320H199a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h304a8 8 0 0 0 8-8V88a8 8 0 0 0-8-8zm0 160H199a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h304a8 8 0 0 0 8-8v-16a8 8 0 0 0-8-8z"></path></svg>`
const taskShowIcon = `<svg aria-hidden="true" focusable="false" data-prefix="fal" data-icon="tasks" class="svg-inline--fa fa-tasks fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M145.35 207a8 8 0 0 0-11.35 0l-71 71-39-39a8 8 0 0 0-11.31 0L1.35 250.34a8 8 0 0 0 0 11.32l56 56a8 8 0 0 0 11.31 0l88-88a8 8 0 0 0 0-11.32zM62.93 384c-17.67 0-32.4 14.33-32.4 32s14.73 32 32.4 32a32 32 0 0 0 0-64zm82.42-337A8 8 0 0 0 134 47l-71 71-39-39a8 8 0 0 0-11.31 0L1.35 90.34a8 8 0 0 0 0 11.32l56 56a8 8 0 0 0 11.31 0l88-88a8 8 0 0 0 0-11.32zM503 400H199a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h304a8 8 0 0 0 8-8v-16a8 8 0 0 0-8-8zm0-320H199a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h304a8 8 0 0 0 8-8V88a8 8 0 0 0-8-8zm0 160H199a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h304a8 8 0 0 0 8-8v-16a8 8 0 0 0-8-8z"></path></svg>`
let hiddenState = true;
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "completed-task-display",
"name": "Completed Task Display",
"version": "1.0.1",
"version": "1.0.2",
"minAppVersion": "0.10.0",
"description": "Provides a button in the ribbon to hide or display completed tasks",
"author": "Ben Lee-Cohen",
Expand Down

0 comments on commit 1b0c8e6

Please sign in to comment.