Skip to content

Commit

Permalink
Fix old shortcuts + NSIS build
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Sep 10, 2024
1 parent 6e17750 commit 99839a4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 33 deletions.
50 changes: 19 additions & 31 deletions apps/app/nsis/hooks.nsi
Original file line number Diff line number Diff line change
@@ -1,53 +1,41 @@
!macro NSIS_HOOK_POSTINSTALL
; Check if theseus_gui.exe exists
${IfFileExists} "$LOCALAPPDATA\Modrinth App\theseus_gui.exe"
SetShellVarContext current

Delete "$LOCALAPPDATA\Modrinth App\theseus_gui.exe"
IfFileExists "$LOCALAPPDATA${PRODUCTNAME}\theseus_gui.exe" file_found file_not_found
file_found:
Delete "$LOCALAPPDATA${PRODUCTNAME}\theseus_gui.exe"

{{#each file_associations as |association| ~}}
{{#each association.ext as |ext| ~}}
!insertmacro APP_UNASSOCIATE "{{ext}}" "{{or association.name ext}}"
{{/each}}
{{/each}}

{{#each deep_link_protocols as |protocol| ~}}
ReadRegStr $R7 SHCTX "Software\Classes\\{{protocol}}\shell\open\command" ""
${If} $R7 == "$\"$LOCALAPPDATA\Modrinth App\theseus_gui.exe$\" $\"%1$\""
DeleteRegKey SHCTX "Software\Classes\\{{protocol}}"
${EndIf}
{{/each}}

Delete "$LOCALAPPDATA\Modrinth App\uninstall.exe"
RMDir "$LOCALAPPDATA\Modrinth App"
Delete "$LOCALAPPDATA${PRODUCTNAME}\uninstall.exe"
RMDir "$LOCALAPPDATA${PRODUCTNAME}"

!insertmacro DeleteAppUserModelId

; Remove start menu shortcut
!insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder
!insertmacro IsShortcutTarget "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$LOCALAPPDATA\Modrinth App\theseus_gui.exe"
!insertmacro IsShortcutTarget "$SMPROGRAMS$AppStartMenuFolder${PRODUCTNAME}.lnk" "$LOCALAPPDATA${PRODUCTNAME}\theseus_gui.exe"
Pop $0
${If} $0 = 1
!insertmacro UnpinShortcut "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk"
Delete "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk"
RMDir "$SMPROGRAMS\$AppStartMenuFolder"
!insertmacro UnpinShortcut "$SMPROGRAMS$AppStartMenuFolder${PRODUCTNAME}.lnk"
Delete "$SMPROGRAMS$AppStartMenuFolder${PRODUCTNAME}.lnk"
RMDir "$SMPROGRAMS$AppStartMenuFolder"
${EndIf}
!insertmacro IsShortcutTarget "$SMPROGRAMS\${PRODUCTNAME}.lnk" "$LOCALAPPDATA\Modrinth App\theseus_gui.exe"
!insertmacro IsShortcutTarget "$SMPROGRAMS${PRODUCTNAME}.lnk" "$LOCALAPPDATA${PRODUCTNAME}\theseus_gui.exe"
Pop $0
${If} $0 = 1
!insertmacro UnpinShortcut "$SMPROGRAMS\${PRODUCTNAME}.lnk"
Delete "$SMPROGRAMS\${PRODUCTNAME}.lnk"
!insertmacro UnpinShortcut "$SMPROGRAMS${PRODUCTNAME}.lnk"
Delete "$SMPROGRAMS${PRODUCTNAME}.lnk"
${EndIf}

; Remove desktop shortcuts
!insertmacro IsShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$LOCALAPPDATA\Modrinth App\theseus_gui.exe"
!insertmacro IsShortcutTarget "$DESKTOP${PRODUCTNAME}.lnk" "$LOCALAPPDATA${PRODUCTNAME}\theseus_gui.exe"
Pop $0
${If} $0 = 1
!insertmacro UnpinShortcut "$DESKTOP\${PRODUCTNAME}.lnk"
Delete "$DESKTOP\${PRODUCTNAME}.lnk"
!insertmacro UnpinShortcut "$DESKTOP${PRODUCTNAME}.lnk"
Delete "$DESKTOP${PRODUCTNAME}.lnk"
${EndIf}

DeleteRegKey HKCU "${UNINSTKEY}"

${EndIfFileExists} ; End of file existence check

goto end_of_test ;<== important for not continuing on the else branch
file_not_found:
end_of_test:
!macroend
8 changes: 7 additions & 1 deletion apps/frontend/src/public/promo-frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,19 @@
]);
});

let lastUrl = null
window.addEventListener(
"message",
(event) => {
if (event.data.modrinthOpenUrl && window.__TAURI_INTERNALS__) {
if (event.data.modrinthOpenUrl && window.__TAURI_INTERNALS__ && lastUrl !== event.data.modrinthOpenUrl) {
lastUrl = event.data.modrinthOpenUrl
window.__TAURI_INTERNALS__.invoke("plugin:shell|open", {
path: event.data.modrinthOpenUrl,
});

setTimeout(() => {
lastUrl = null
}, 500)
}
},
false,
Expand Down
2 changes: 1 addition & 1 deletion packages/app-lib/src/util/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn os_rule(
if minecraft_updated
&& (name != &Os::LinuxArm64 || name != &Os::LinuxArm32)
{
rule_match &= &Os::native() == &name.get_os()
rule_match &= Os::native() == name.get_os()
|| &Os::native_arch(java_arch) == name;
} else {
rule_match &= &Os::native_arch(java_arch) == name;
Expand Down

0 comments on commit 99839a4

Please sign in to comment.