Lint plugin
This commit is contained in:
parent
4af8f3b23f
commit
a2b1a83663
6 changed files with 20 additions and 23 deletions
|
|
@ -1,12 +1,8 @@
|
||||||
import type { TAbstractFile } from "obsidian";
|
import type { TAbstractFile } from "obsidian";
|
||||||
import { TFile } from "obsidian";
|
import { TFile } from "obsidian";
|
||||||
import type { FileEventHandler } from "./file-event-handler";
|
import type { FileEventHandler } from "./file-event-handler";
|
||||||
import type { SyncService } from "src/services/sync-service";
|
|
||||||
import type { Database } from "src/database/database";
|
|
||||||
import type { FileOperations } from "src/file-operations/file-operations";
|
|
||||||
import { Logger } from "src/tracing/logger";
|
import { Logger } from "src/tracing/logger";
|
||||||
import type { SyncHistory } from "src/tracing/sync-history";
|
import type { Syncer } from "src/sync-operations/syncer";
|
||||||
import { Syncer } from "src/sync-operations/syncer";
|
|
||||||
|
|
||||||
export class ObsidianFileEventHandler implements FileEventHandler {
|
export class ObsidianFileEventHandler implements FileEventHandler {
|
||||||
public constructor(private readonly syncer: Syncer) {}
|
public constructor(private readonly syncer: Syncer) {}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
import type { Database } from "src/database/database";
|
import type { Database } from "src/database/database";
|
||||||
import type { FileOperations } from "src/file-operations/file-operations";
|
|
||||||
import type { SyncService } from "src/services/sync-service";
|
import type { SyncService } from "src/services/sync-service";
|
||||||
import { Logger } from "src/tracing/logger";
|
import { Logger } from "src/tracing/logger";
|
||||||
import type { SyncHistory } from "src/tracing/sync-history";
|
import type { Syncer } from "./syncer";
|
||||||
import { Syncer } from "./syncer";
|
|
||||||
|
|
||||||
let isRunning = false;
|
let isRunning = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,14 +33,14 @@ export class Logger {
|
||||||
|
|
||||||
public debug(message: string): void {
|
public debug(message: string): void {
|
||||||
if (process.env.NODE_ENV !== "production") {
|
if (process.env.NODE_ENV !== "production") {
|
||||||
console.debug(`${message}`);
|
console.debug(message);
|
||||||
}
|
}
|
||||||
this.pushMessage(message, LogLevel.DEBUG);
|
this.pushMessage(message, LogLevel.DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public info(message: string): void {
|
public info(message: string): void {
|
||||||
if (process.env.NODE_ENV !== "production") {
|
if (process.env.NODE_ENV !== "production") {
|
||||||
console.info(`${message}`);
|
console.info(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pushMessage(message, LogLevel.INFO);
|
this.pushMessage(message, LogLevel.INFO);
|
||||||
|
|
@ -48,7 +48,7 @@ export class Logger {
|
||||||
|
|
||||||
public warn(message: string): void {
|
public warn(message: string): void {
|
||||||
if (process.env.NODE_ENV !== "production") {
|
if (process.env.NODE_ENV !== "production") {
|
||||||
console.warn(`${message}`);
|
console.warn(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pushMessage(message, LogLevel.WARNING);
|
this.pushMessage(message, LogLevel.WARNING);
|
||||||
|
|
@ -56,7 +56,7 @@ export class Logger {
|
||||||
|
|
||||||
public error(message: string): void {
|
public error(message: string): void {
|
||||||
if (process.env.NODE_ENV !== "production") {
|
if (process.env.NODE_ENV !== "production") {
|
||||||
console.error(`${message}`);
|
console.error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pushMessage(message, LogLevel.ERROR);
|
this.pushMessage(message, LogLevel.ERROR);
|
||||||
|
|
@ -77,7 +77,7 @@ export class Logger {
|
||||||
|
|
||||||
public reset(): void {
|
public reset(): void {
|
||||||
this.messages.length = 0;
|
this.messages.length = 0;
|
||||||
this.onMessageListeners.forEach((listener) => listener(undefined));
|
this.onMessageListeners.forEach((listener) => { listener(undefined); });
|
||||||
}
|
}
|
||||||
|
|
||||||
private pushMessage(message: string, level: LogLevel): void {
|
private pushMessage(message: string, level: LogLevel): void {
|
||||||
|
|
@ -88,6 +88,6 @@ export class Logger {
|
||||||
this.messages.shift();
|
this.messages.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onMessageListeners.forEach((listener) => listener(logLine));
|
this.onMessageListeners.forEach((listener) => { listener(logLine); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { ItemView } from "obsidian";
|
||||||
import type { SyncHistory } from "src/tracing/sync-history";
|
import type { SyncHistory } from "src/tracing/sync-history";
|
||||||
import { SyncSource, SyncStatus } from "src/tracing/sync-history";
|
import { SyncSource, SyncStatus } from "src/tracing/sync-history";
|
||||||
import { intlFormatDistance } from "date-fns";
|
import { intlFormatDistance } from "date-fns";
|
||||||
import { Database } from "src/database/database";
|
import type { Database } from "src/database/database";
|
||||||
|
|
||||||
export class HistoryView extends ItemView {
|
export class HistoryView extends ItemView {
|
||||||
public static readonly TYPE = "history-view";
|
public static readonly TYPE = "history-view";
|
||||||
|
|
@ -30,6 +30,7 @@ export class HistoryView extends ItemView {
|
||||||
return " ⤴️";
|
return " ⤴️";
|
||||||
case SyncSource.PULL:
|
case SyncSource.PULL:
|
||||||
return " ⤵️";
|
return " ⤵️";
|
||||||
|
case undefined:
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,13 @@ export class LogsView extends ItemView {
|
||||||
public constructor(leaf: WorkspaceLeaf) {
|
public constructor(leaf: WorkspaceLeaf) {
|
||||||
super(leaf);
|
super(leaf);
|
||||||
this.icon = LogsView.ICON;
|
this.icon = LogsView.ICON;
|
||||||
Logger.getInstance().addOnMessageListener(() => this.updateView());
|
Logger.getInstance().addOnMessageListener(() => {
|
||||||
|
this.updateView();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static formatTimestamp(timestamp: Date): string {
|
||||||
|
return timestamp.toTimeString().split(" ")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public getViewType(): string {
|
public getViewType(): string {
|
||||||
|
|
@ -21,10 +27,10 @@ export class LogsView extends ItemView {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async onOpen(): Promise<void> {
|
public async onOpen(): Promise<void> {
|
||||||
await this.updateView();
|
this.updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateView(): Promise<void> {
|
private updateView(): void {
|
||||||
const container = this.containerEl.children[1];
|
const container = this.containerEl.children[1];
|
||||||
container.empty();
|
container.empty();
|
||||||
|
|
||||||
|
|
@ -44,8 +50,4 @@ export class LogsView extends ItemView {
|
||||||
messageContainer.createEl("span", { text: message.message });
|
messageContainer.createEl("span", { text: message.message });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static formatTimestamp(timestamp: Date): string {
|
|
||||||
return timestamp.toTimeString().split(" ")[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import type { Plugin } from "obsidian";
|
import type { Plugin } from "obsidian";
|
||||||
import { Syncer } from "src/sync-operations/syncer";
|
import type { Syncer } from "src/sync-operations/syncer";
|
||||||
import type { HistoryStats, SyncHistory } from "src/tracing/sync-history";
|
import type { HistoryStats, SyncHistory } from "src/tracing/sync-history";
|
||||||
|
|
||||||
export class StatusBar {
|
export class StatusBar {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue