Skip to content

Commit

Permalink
Added "don't show emojis" feature
Browse files Browse the repository at this point in the history
  • Loading branch information
plasmabit committed Feb 12, 2024
1 parent 5536c47 commit d0dfd7d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 13 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "timethings",
"name": "Time Things",
"version": "1.2.5",
"version": "1.2.6",
"minAppVersion": "0.15.0",
"description": "Show clock in the corner. Track total editing time of a note and the last time it was modified.",
"author": "Nick Winters",
Expand Down
22 changes: 15 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,17 @@ export default class TimeThings extends Plugin {
const ignoreKeys = [
"ArrowDown",
"ArrowUp",
"ArrowLeft",
"ArrowRight",
"Tab",
"CapsLock",
"Alt",
"PageUp",
"PageDown",
"Home",
"End",
"Meta",
"Escape",
]

if (evt.ctrlKey || ignoreKeys.includes(evt.key)) {
Expand Down Expand Up @@ -195,12 +203,12 @@ export default class TimeThings extends Plugin {

if (this.isDebugBuild) { // Add DEBUG icon
this.debugBar = this.addStatusBarItem();
this.debugBar.setText("☢️ DEBUG BUILD ☢️")
this.settings.showEmojiStatusBar ? this.debugBar.setText("☢️ DEBUG BUILD ☢️") : this.debugBar.setText("/ DEBUG BUILD /");
}

if (this.settings.enableEditDurationKey) { // Ad duration icon
this.editDurationBar = this.addStatusBarItem();
this.editDurationBar.setText("⌛");
this.settings.showEmojiStatusBar ? this.editDurationBar.setText("⌛") : this.editDurationBar.setText("/");
}
}

Expand Down Expand Up @@ -228,21 +236,21 @@ export default class TimeThings extends Plugin {
}
let text = "";
if (+value < 60) {
text = `⌛ <1 m`;
text = this.settings.showEmojiStatusBar ? `⌛ <1 m` : `<1 m`;
}
else if (+value < 60 * 60) {
const minutes = Math.floor(+value / 60);
text = `⌛ ${minutes} m`;
text = this.settings.showEmojiStatusBar ? `⌛ ${minutes} m` : `${minutes} m`;
}
else if (+value < 60 * 60 * 24) {
const hours = Math.floor(+value / (60 * 60));
const minutes = Math.floor((+value - (hours * 60 * 60)) / 60);
text = `⌛ ${hours} h ${minutes} m`;
text = this.settings.showEmojiStatusBar ? `⌛ ${hours} h ${minutes} m` : `${hours} h ${minutes} m`;
}
else {
const days = Math.floor(+value / (24 * 60 * 60));
const hours = Math.floor((+value - (days * 24 * 60 * 60)) / (60 * 60));
text = `⌛ ${days} d ${hours} h`;
text = this.settings.showEmojiStatusBar ? `⌛ ${days} d ${hours} h` : `${days} d ${hours} h`;
}
this.editDurationBar.setText(text);
}
Expand Down Expand Up @@ -301,7 +309,7 @@ export default class TimeThings extends Plugin {
const dateFormatted = dateChosen.format(this.settings.clockFormat);
const emoji = timeUtils.momentToClockEmoji(dateChosen);

this.clockBar.setText(emoji + " " + dateFormatted);
this.settings.showEmojiStatusBar ? this.clockBar.setText(emoji + " " + dateFormatted) : this.clockBar.setText(dateFormatted);
}

async standardUpdateModifiedKey(file: TAbstractFile) {
Expand Down
32 changes: 27 additions & 5 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { App, PluginSettingTab, Setting } from 'obsidian';
import TimeThings from './main';

export interface TimeThingsSettings {
showEmojiStatusBar: boolean;
clockFormat: string;
isUTC: boolean;
updateIntervalMilliseconds: string;
Expand All @@ -11,12 +12,16 @@ export interface TimeThingsSettings {
enableModifiedKeyUpdate: boolean;
useCustomFrontmatterHandlingSolution: boolean;
updateIntervalFrontmatterMinutes: number;
editDurationPath: string,
enableEditDurationKey: boolean,
nonTypingEditingTimePercentage: number,
editDurationPath: string;
enableEditDurationKey: boolean;
nonTypingEditingTimePercentage: number;
enableSwitch: boolean;
switchKey: string;
switchKeyValue: string;
}

export const DEFAULT_SETTINGS: TimeThingsSettings = {
showEmojiStatusBar: true,
clockFormat: 'hh:mm A',
updateIntervalMilliseconds: '1000',
isUTC: false,
Expand All @@ -29,6 +34,9 @@ export const DEFAULT_SETTINGS: TimeThingsSettings = {
editDurationPath: "edited_seconds",
enableEditDurationKey: true,
nonTypingEditingTimePercentage: 22,
enableSwitch: false,
switchKey: "timethings.switch",
switchKeyValue: "true",
}

export class TimeThingsSettingsTab extends PluginSettingTab {
Expand Down Expand Up @@ -71,7 +79,20 @@ export class TimeThingsSettingsTab extends PluginSettingTab {
);

containerEl.createEl('h1', { text: 'Status bar' });
containerEl.createEl('p', { text: 'Displays clock in the status bar.' });
containerEl.createEl('p', { text: 'Displays clock and duration edited in the status bar' });

new Setting(containerEl)
.setName('Enable emojis')
.setDesc('Show emojis in the status bar?')
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.showEmojiStatusBar)
.onChange(async (newValue) => {
this.plugin.settings.showEmojiStatusBar = newValue;
await this.plugin.saveSettings();
await this.display();
}),
);

new Setting(containerEl)
.setName('Enable status bar clock')
Expand All @@ -83,9 +104,10 @@ export class TimeThingsSettingsTab extends PluginSettingTab {
this.plugin.settings.enableClock = newValue;
await this.plugin.saveSettings();
await this.display();
}),
}),
);


if (this.plugin.settings.enableClock === true) {

new Setting(containerEl)
Expand Down

0 comments on commit d0dfd7d

Please sign in to comment.