From c6ab88508fef9836c510efb4e24ec96aa3a550b0 Mon Sep 17 00:00:00 2001
From: David Baker <dave@matrix.org>
Date: Tue, 28 Jul 2020 15:56:05 +0100
Subject: [PATCH] Remove the Element (Riot) shortcuts too

---
 src/squirrelhooks.js | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/squirrelhooks.js b/src/squirrelhooks.js
index 1a95f171..317a974a 100644
--- a/src/squirrelhooks.js
+++ b/src/squirrelhooks.js
@@ -51,6 +51,19 @@ function checkSquirrelHooks() {
                 appDataDir, 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'New Vector Ltd',
             );
             return fsProm.rmdir(startMenuDir, { recursive: true });
+        }).then(() => {
+            // same for 'Element (Riot) which is old now too (we have to try to delete both because
+            // we don't know what version we're updating from, but of course we do know this version
+            // is 'Element' so the two old ones are all safe to delete).
+            const appDataDir = process.env.APPDATA;
+            if (!appDataDir) return;
+            const oldStartMenuLink = path.join(
+                appDataDir, 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Element', 'Element (Riot).lnk',
+            );
+            return fsProm.unlink(oldStartMenuLink).catch(() => {});
+        }).then(() => {
+            const oldDesktopShortcut = path.join(app.getPath('desktop'), 'Element (Riot).lnk');
+            return fsProm.unlink(oldDesktopShortcut).catch(() => {});
         }).then(() => {
             const oldDesktopShortcut = path.join(app.getPath('desktop'), 'Riot.lnk');
             return fsProm.unlink(oldDesktopShortcut).catch(() => {});