@@ -838,6 +838,8 @@ export class InvioSettingTab extends PluginSettingTab {
838
838
text : t ( "settings_importexport" ) ,
839
839
} ) ;
840
840
841
+ const settingsPrefix = `Invio-Settings>` ;
842
+ const settingsSuffix = `<&`
841
843
new Setting ( importExportDiv )
842
844
. setName ( t ( "settings_export" ) )
843
845
. setDesc ( t ( "settings_export_desc" ) )
@@ -846,7 +848,7 @@ export class InvioSettingTab extends PluginSettingTab {
846
848
button . onClick ( async ( ) => {
847
849
// new ExportSettingsQrCodeModal(this.app, this.plugin).open();
848
850
const data = await this . plugin . loadData ( ) ;
849
- await navigator . clipboard . writeText ( data . d ) ;
851
+ await navigator . clipboard . writeText ( ` ${ settingsPrefix } ${ data . d } ${ settingsSuffix } ` ) ;
850
852
new Notice ( t ( "settings_export_msg" ) ) ;
851
853
} ) ;
852
854
} ) ;
@@ -870,11 +872,21 @@ export class InvioSettingTab extends PluginSettingTab {
870
872
new Notice ( t ( "settings_import_err" ) ) ;
871
873
return ;
872
874
}
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 ( ) ) ;
874
881
// Create dir if necessary.
875
882
const dir = this . plugin . settings . localWatchDir ;
876
883
if ( dir && ( typeof dir === 'string' ) ) {
877
884
await mkdirpInVault ( dir , this . plugin . app . vault ) ;
885
+ await this . plugin . switchWorkingDir ( dir ) ;
886
+
887
+ setTimeout ( ( ) => {
888
+ this . plugin . syncRun ( 'auto' ) ;
889
+ } , 100 )
878
890
} else {
879
891
log . error ( 'Imported settings not configured correctly.' )
880
892
}
0 commit comments