mirror of
https://github.com/williamsjack/pairwise-glicko-ranking.git
synced 2026-07-22 06:44:09 +00:00
Refresh cohort list in settings tab after creation
This commit is contained in:
parent
41e0bb5542
commit
de665718fb
1 changed files with 30 additions and 23 deletions
53
src/main.ts
53
src/main.ts
|
|
@ -28,6 +28,7 @@ import { debugWarn, setDebugLogging } from './utils/logger';
|
|||
export default class GlickoPlugin extends Plugin {
|
||||
dataStore: PluginDataStore;
|
||||
settings: GlickoSettings;
|
||||
private settingTab!: GlickoSettingsTab;
|
||||
|
||||
private currentSession?: ArenaSession;
|
||||
|
||||
|
|
@ -110,7 +111,8 @@ export default class GlickoPlugin extends Plugin {
|
|||
}),
|
||||
);
|
||||
|
||||
this.addSettingTab(new GlickoSettingsTab(this.app, this));
|
||||
this.settingTab = new GlickoSettingsTab(this.app, this);
|
||||
this.addSettingTab(this.settingTab);
|
||||
}
|
||||
|
||||
onunload(): void {
|
||||
|
|
@ -124,33 +126,38 @@ export default class GlickoPlugin extends Plugin {
|
|||
}
|
||||
|
||||
private async selectCohortAndStart() {
|
||||
const picker = new CohortPicker(this.app, this);
|
||||
let def = await picker.openAndGetSelection();
|
||||
if (!def) return;
|
||||
try {
|
||||
const picker = new CohortPicker(this.app, this);
|
||||
let def = await picker.openAndGetSelection();
|
||||
if (!def) return;
|
||||
|
||||
// Recover folder for folder-based cohorts if missing
|
||||
def = await ensureFolderCohortPath(this.app, this.dataStore, def);
|
||||
if (!def) return;
|
||||
// Recover folder for folder-based cohorts if missing
|
||||
def = await ensureFolderCohortPath(this.app, this.dataStore, def);
|
||||
if (!def) return;
|
||||
|
||||
// Recover base/view for base-based cohorts if missing
|
||||
def = await ensureBaseCohortTarget(this.app, this.dataStore, def);
|
||||
if (!def) return;
|
||||
// Recover base/view for base-based cohorts if missing
|
||||
def = await ensureBaseCohortTarget(this.app, this.dataStore, def);
|
||||
if (!def) return;
|
||||
|
||||
const files = await resolveFilesForCohort(this.app, def, {
|
||||
excludeFolderPath: this.settings.templatesFolderPath,
|
||||
});
|
||||
const files = await resolveFilesForCohort(this.app, def, {
|
||||
excludeFolderPath: this.settings.templatesFolderPath,
|
||||
});
|
||||
|
||||
if (files.length < 2) {
|
||||
new Notice('Need at least two Markdown notes to compare.');
|
||||
return;
|
||||
if (files.length < 2) {
|
||||
new Notice('Need at least two Markdown notes to compare.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.dataStore.getCohortDef(def.key)) {
|
||||
this.dataStore.upsertCohortDef(def);
|
||||
await this.dataStore.saveStore();
|
||||
}
|
||||
|
||||
await this.startSessionForCohort(def, files, { saveDef: false });
|
||||
} finally {
|
||||
// Refresh the declarative settings tab so the Cohorts list is current.
|
||||
this.settingTab.update();
|
||||
}
|
||||
|
||||
if (!this.dataStore.getCohortDef(def.key)) {
|
||||
this.dataStore.upsertCohortDef(def);
|
||||
await this.dataStore.saveStore();
|
||||
}
|
||||
|
||||
await this.startSessionForCohort(def, files, { saveDef: false });
|
||||
}
|
||||
|
||||
private async startSessionForCohort(
|
||||
|
|
|
|||
Loading…
Reference in a new issue