- Rename methods for automatic binging checking.

- Add automatic binging checks.
This commit is contained in:
vorotamoroz
2025-10-06 10:40:25 +01:00
parent cccff21ecc
commit 4808876968
16 changed files with 83 additions and 248 deletions

View File

@@ -34,7 +34,7 @@ export class ModuleObsidianAPI extends AbstractObsidianModule {
return !this.last_successful_post;
}
async _fetchByAPI(url: string, authHeader: string, opts?: RequestInit): Promise<Response> {
async __fetchByAPI(url: string, authHeader: string, opts?: RequestInit): Promise<Response> {
const body = opts?.body as string;
const transformedHeaders = { ...(opts?.headers as Record<string, string>) };
@@ -69,7 +69,7 @@ export class ModuleObsidianAPI extends AbstractObsidianModule {
const body = opts?.body as string;
const size = body ? ` (${body.length})` : "";
try {
const r = await this._fetchByAPI(url, authHeader, opts);
const r = await this.__fetchByAPI(url, authHeader, opts);
this.plugin.requestCount.value = this.plugin.requestCount.value + 1;
if (method == "POST" || method == "PUT") {
this.last_successful_post = r.status - (r.status % 100) == 200;
@@ -149,7 +149,7 @@ export class ModuleObsidianAPI extends AbstractObsidianModule {
try {
this.plugin.requestCount.value = this.plugin.requestCount.value + 1;
const response: Response = await (useRequestAPI
? this._fetchByAPI(url.toString(), authHeader, { ...opts, headers })
? this.__fetchByAPI(url.toString(), authHeader, { ...opts, headers })
: fetch(url, { ...opts, headers }));
if (method == "POST" || method == "PUT") {
this.last_successful_post = response.ok;

View File

@@ -32,10 +32,10 @@ export class ModuleObsidianEvents extends AbstractObsidianModule {
}
private _performRestart(): void {
this._performAppReload();
this.__performAppReload();
}
_performAppReload() {
__performAppReload() {
//@ts-ignore
this.app.commands.executeCommandById("app:reload");
}
@@ -182,7 +182,7 @@ export class ModuleObsidianEvents extends AbstractObsidianModule {
{ defaultAction: RETRY_LATER }
);
if (ret == RESTART_NOW) {
this._performAppReload();
this.__performAppReload();
} else if (ret == RESTART_AFTER_STABLE) {
this.services.appLifecycle.scheduleRestart();
}
@@ -225,7 +225,7 @@ export class ModuleObsidianEvents extends AbstractObsidianModule {
this.core._totalProcessingCount.onChanged((e) => {
if (e.value == 0) {
if (stableCheck-- <= 0) {
this._performAppReload();
this.__performAppReload();
}
this._log(
`Obsidian will be restarted soon! (Within ${stableCheck} seconds)`,

View File

@@ -105,11 +105,11 @@ export class ModuleObsidianMenu extends AbstractObsidianModule {
});
return Promise.resolve(true);
}
_onWorkspaceReady() {
private __onWorkspaceReady() {
void this.services.appLifecycle.onReady();
}
private _everyOnload(): Promise<boolean> {
this.app.workspace.onLayoutReady(this._onWorkspaceReady.bind(this));
this.app.workspace.onLayoutReady(this.__onWorkspaceReady.bind(this));
return Promise.resolve(true);
}