Skip to content

Commit 049d816

Browse files
committed
feat(ex/import): Allow users to share newly created working directories with their teammates
1 parent a232c87 commit 049d816

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,11 @@ export default class InvioPlugin extends Plugin {
337337
resolve('skip');
338338
return;
339339
}
340-
340+
// silent mode
341+
if (triggerSource === 'auto') {
342+
resolve('skip');
343+
return;
344+
}
341345
const touchedPlanModel = new TouchedPlanModel(this.app, this, touchedFileMap, (pub: boolean) => {
342346
log.info('user confirmed: ', pub);
343347
pub ? resolve('ok') : reject('cancelled')

src/settings.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,8 @@ export class InvioSettingTab extends PluginSettingTab {
838838
text: t("settings_importexport"),
839839
});
840840

841+
const settingsPrefix = `Invio-Settings>`;
842+
const settingsSuffix = `<&`
841843
new Setting(importExportDiv)
842844
.setName(t("settings_export"))
843845
.setDesc(t("settings_export_desc"))
@@ -846,7 +848,7 @@ export class InvioSettingTab extends PluginSettingTab {
846848
button.onClick(async () => {
847849
// new ExportSettingsQrCodeModal(this.app, this.plugin).open();
848850
const data = await this.plugin.loadData();
849-
await navigator.clipboard.writeText(data.d);
851+
await navigator.clipboard.writeText(`${settingsPrefix} ${data.d} ${settingsSuffix}`);
850852
new Notice(t("settings_export_msg"));
851853
});
852854
});
@@ -870,11 +872,21 @@ export class InvioSettingTab extends PluginSettingTab {
870872
new Notice(t("settings_import_err"));
871873
return;
872874
}
873-
await this.plugin.loadSettings(restoredStr);
875+
if (!(restoredStr.startsWith(settingsPrefix) && restoredStr.endsWith(settingsSuffix))) {
876+
new Notice(t("settings_import_err"));
877+
return;
878+
}
879+
880+
await this.plugin.loadSettings(restoredStr.replace(settingsPrefix, '').replace(settingsSuffix, '').trim());
874881
// Create dir if necessary.
875882
const dir = this.plugin.settings.localWatchDir;
876883
if (dir && (typeof dir === 'string')) {
877884
await mkdirpInVault(dir, this.plugin.app.vault);
885+
await this.plugin.switchWorkingDir(dir);
886+
887+
setTimeout(() => {
888+
this.plugin.syncRun('auto');
889+
}, 100)
878890
} else {
879891
log.error('Imported settings not configured correctly.')
880892
}

0 commit comments

Comments
 (0)