@@ -25,7 +25,10 @@ const {
2525 Signedprekeyrecord,
2626 getDB,
2727 Table,
28- deleteAccountNotSignalRelatedData
28+ deleteAccountNotSignalRelatedData,
29+ getSettings,
30+ updateSettings,
31+ updateAccount
2932} = require ( './DBEmanager' ) ;
3033const myAccount = require ( './../Account' ) ;
3134const systemLabels = require ( './../systemLabels' ) ;
@@ -37,6 +40,7 @@ const {
3740 replaceEmailsWithCopy,
3841 saveEmailBody
3942} = require ( './../utils/FileUtils' ) ;
43+ const { getShowPreview, setShowPreview } = require ( '../windows/mailbox' ) ;
4044
4145const CIPHER_ALGORITHM = 'aes-128-cbc' ;
4246const STREAM_SIZE = 512 * 1024 ;
@@ -844,10 +848,28 @@ const exportEncryptDatabaseToFile = async ({
844848 ? accountObj . recipientId . split ( '@' )
845849 : myAccount . recipientId . split ( '@' ) ;
846850 const accountId = accountObj ? accountObj . id : myAccount . id ;
851+ const signature =
852+ accountObj && accountObj . signature !== undefined
853+ ? accountObj . signature
854+ : myAccount . signature ;
855+
856+ const hasCriptextFooter =
857+ accountObj && accountObj . signFooter !== undefined
858+ ? accountObj . signFooter
859+ : myAccount . signFooter ;
860+ const showPreview = await getShowPreview ( ) ;
861+
862+ const { language, theme } = await getSettings ( ) ;
863+
847864 const fileInformation = JSON . stringify ( {
848865 fileVersion : LINK_DEVICES_FILE_VERSION ,
849866 recipientId : recipientId ,
850- domain : domain || APP_DOMAIN
867+ domain : domain || APP_DOMAIN ,
868+ signature : signature ,
869+ hasCriptextFooter : hasCriptextFooter ,
870+ language : language ,
871+ darkTheme : theme === 'dark' ,
872+ showPreview : showPreview
851873 } ) ;
852874
853875 exportProgress += 100 / PROGRESS_TOTAL_STEPS ;
@@ -947,6 +969,10 @@ const importDatabaseFromFile = async ({
947969 let signedprekeyrecords = [ ] ;
948970 let aliases = [ ] ;
949971 let customDomains = [ ] ;
972+ // eslint-disable-next-line prefer-const
973+ let accountObject = { } ;
974+ // eslint-disable-next-line prefer-const
975+ let settingsObject = { } ;
950976
951977 const sequelize = getDB ( ) ;
952978
@@ -959,12 +985,19 @@ const importDatabaseFromFile = async ({
959985 }
960986
961987 if ( isStrict ) {
962- getCustomLinesByStream ( filepath , 1 , ( err , lines ) => {
988+ getCustomLinesByStream ( filepath , 1 , async ( err , lines ) => {
963989 if ( err ) throw new Error ( 'Failed to read file information' ) ;
964990 const fileInformation = lines [ 0 ] ;
965- const { fileVersion, recipientId, domain } = JSON . parse (
966- fileInformation
967- ) ;
991+ const {
992+ fileVersion,
993+ recipientId,
994+ domain,
995+ signature,
996+ hasCriptextFooter,
997+ language,
998+ darkTheme,
999+ showPreview
1000+ } = JSON . parse ( fileInformation ) ;
9681001
9691002 if ( recipientId && domain ) {
9701003 const fileOwner = `${ recipientId } @${ domain } ` ;
@@ -976,6 +1009,32 @@ const importDatabaseFromFile = async ({
9761009 const currentVersion = Number ( LINK_DEVICES_FILE_VERSION ) ;
9771010 if ( version !== currentVersion ) return ;
9781011 }
1012+
1013+ if ( signature !== undefined ) {
1014+ accountObject . signature = signature ;
1015+ }
1016+
1017+ if ( hasCriptextFooter !== undefined ) {
1018+ accountObject . signFooter = hasCriptextFooter ;
1019+ }
1020+
1021+ if ( language ) {
1022+ settingsObject . language = language ;
1023+ }
1024+
1025+ if ( darkTheme !== undefined ) {
1026+ settingsObject . theme = darkTheme ? 'dark' : 'light' ;
1027+ }
1028+
1029+ if ( showPreview !== undefined ) {
1030+ await setShowPreview ( showPreview ) ;
1031+ }
1032+ if ( Object . keys ( settingsObject ) . length !== 0 ) {
1033+ await updateSettings ( settingsObject , trx ) ;
1034+ }
1035+ if ( Object . keys ( accountObj ) . length !== 0 ) {
1036+ await updateAccount ( accountObj , trx ) ;
1037+ }
9791038 } ) ;
9801039
9811040 if ( accountId ) {
0 commit comments