Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 78 additions & 1 deletion build/installer.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,82 @@
; `SetSilent silent` after its confirmation MessageBox, so we briefly restore
; the normal mode to show our own nsDialogs dialog.
!macro customUnInstall
; Placeholder; filled in the next commit.
; Do nothing on upgrades: the old uninstaller is invoked with --updated by
; the new installer and app data must survive the update.
${ifNot} ${isUpdated}
; Electron app data (caches, local storage, session state) are
; regenerable: always remove them. The user-facing configuration lives in
; the profile directory and is handled separately below.
RMDir /r "$APPDATA\Twake Desktop"
RMDir /r "$APPDATA\TwakeDesktop"

; Never show a dialog on silent uninstalls (/S), e.g. scripted removals.
${GetParameters} $R0
${GetOptions} $R0 "/S" $R1
${if} ${Errors}
; Offer to remove the configuration only if there is one to remove.
${ifNot} ${FileExists} "$PROFILE\.twake-desktop"
${andIfNot} ${FileExists} "$PROFILE\.cozy-desktop"
Goto no_config_to_remove
${endif}

SetSilent normal

; French users get a French dialog, everyone else English. Custom
; LangStrings cannot be merged into electron-builder's messages file,
; so strings are selected at runtime.
${if} $LANGUAGE == ${LANG_FRENCH}
StrCpy $R2 "Voulez-vous également supprimer la configuration de Twake Desktop (compte, paramètres et base de données locales) ?$\r$\n$\r$\nCochez la case pour tout supprimer. Laissez-la décochée pour conserver votre configuration en cas de réinstallation."
StrCpy $R3 "Supprimer la configuration"
StrCpy $R4 "Désinstallation de Twake Desktop"
StrCpy $R5 "Terminer"
${else}
StrCpy $R2 "Do you also want to remove the Twake Desktop configuration (account, settings and local database)?$\r$\n$\r$\nCheck the box to remove everything. Leave it unchecked to keep your configuration in case you reinstall."
StrCpy $R3 "Remove configuration"
StrCpy $R4 "Twake Desktop uninstallation"
StrCpy $R5 "Finish"
${endif}

nsDialogs::Create 1018
Pop $R6
${if} $R6 == "error"
Goto dialog_done
${endif}

${NSD_CreateLabel} 0 0 100% 60u "$R2"
Pop $R7

${NSD_CreateCheckbox} 0 70u 100% 12u "$R3"
Pop $R8
; Unchecked by default: the configuration is kept unless the user
; explicitly asks for its removal.

${NSD_CreateButton} 70u 95u 30% 14u "$R5"
Pop $R9
${NSD_OnClick} $R9 un.onRemoveConfigDialogOK

nsDialogs::Show

dialog_done:
SetSilent silent

no_config_to_remove:
${endif}
${endif}
!macroend

; Button click handler for the dialog above. The `un.` prefix is preserved
; when electron-builder generates the uninstaller script, and the
; BUILD_UNINSTALLER guard keeps it out of the main installer pass, where
; NSIS would flag it as unused uninstaller code (warning 6020, fatal with
; electron-builder's -WX).
!ifdef BUILD_UNINSTALLER
Function un.onRemoveConfigDialogOK
${NSD_GetState} $R8 $R0
${if} $R0 == ${BST_CHECKED}
RMDir /r "$PROFILE\.twake-desktop"
; Legacy directory from when the app was named Cozy Desktop
RMDir /r "$PROFILE\.cozy-desktop"
${endif}
FunctionEnd
!endif
Loading