mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-07 06:42:39 +02:00
feat: update status handling and connection indicator in SurfSense plugin
- Changed initial status to "needs-setup" to prompt user configuration. - Added a refreshStatus method to SyncEngine for immediate status updates after settings changes. - Enhanced connection indicator logic in the settings tab to reflect the new status. - Introduced "needs-setup" status visual for improved user feedback on configuration requirements.
This commit is contained in:
parent
68156d2e74
commit
4f1c870987
5 changed files with 51 additions and 5 deletions
|
|
@ -46,6 +46,7 @@ export interface SyncEngineDeps {
|
|||
|
||||
export interface SyncEngineSettings {
|
||||
vaultId: string;
|
||||
apiToken: string;
|
||||
connectorId: number | null;
|
||||
searchSpaceId: number | null;
|
||||
includeFolders: string[];
|
||||
|
|
@ -103,7 +104,7 @@ export class SyncEngine {
|
|||
this.handleStartupError(err);
|
||||
return;
|
||||
}
|
||||
this.setStatus("idle", "Pick a search space in settings to start syncing.");
|
||||
this.setStatus("idle");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +124,7 @@ export class SyncEngine {
|
|||
async ensureConnected(): Promise<boolean> {
|
||||
const settings = this.deps.getSettings();
|
||||
if (!settings.searchSpaceId) {
|
||||
this.setStatus("idle", "Pick a search space in settings.");
|
||||
this.setStatus("idle");
|
||||
return false;
|
||||
}
|
||||
this.setStatus("syncing", "Connecting to SurfSense");
|
||||
|
|
@ -500,10 +501,34 @@ export class SyncEngine {
|
|||
|
||||
// ---- status helpers ---------------------------------------------------
|
||||
|
||||
/**
|
||||
* Recomputes status from settings + queue depth. Call from main.ts after
|
||||
* settings change so the indicator reacts to token paste / search-space
|
||||
* pick without waiting for the next sync trigger.
|
||||
*/
|
||||
refreshStatus(): void {
|
||||
this.setStatus(this.queueStatusKind(), this.statusDetail());
|
||||
}
|
||||
|
||||
private setStatus(kind: StatusKind, detail?: string): void {
|
||||
// Errors carry meaningful signal; only "happy" kinds get downgraded
|
||||
// to needs-setup when prerequisites are missing.
|
||||
if (kind !== "auth-error" && kind !== "offline" && kind !== "error") {
|
||||
const s = this.deps.getSettings();
|
||||
if (!s.apiToken || !s.searchSpaceId || !s.connectorId) {
|
||||
kind = "needs-setup";
|
||||
detail = this.setupHint(s);
|
||||
}
|
||||
}
|
||||
this.deps.setStatus({ kind, detail, queueDepth: this.deps.queue.size });
|
||||
}
|
||||
|
||||
private setupHint(s: SyncEngineSettings): string {
|
||||
if (!s.apiToken) return "Paste your API token in settings.";
|
||||
if (!s.searchSpaceId) return "Pick a search space in settings.";
|
||||
return "Connecting…";
|
||||
}
|
||||
|
||||
private queueStatusKind(): StatusKind {
|
||||
if (this.deps.queue.size > 0) return "queued";
|
||||
return "idle";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue