Prechádzať zdrojové kódy

Added remove account function to config manager.

Daniel Scalzi 7 rokov pred
rodič
commit
8d682b15b3
2 zmenil súbory, kde vykonal 26 pridanie a 3 odobranie
  1. 25 0
      app/assets/js/configmanager.js
  2. 1 3
      package.json

+ 25 - 0
app/assets/js/configmanager.js

@@ -194,6 +194,31 @@ exports.addAuthAccount = function(uuid, accessToken, username, displayName){
     return config.authenticationDatabase[uuid]
 }
 
+/**
+ * Remove an authenticated account from the database. If the account
+ * was also the selected account, a new one will be selected. If there
+ * are no accounts, the selected account will be null.
+ * 
+ * @param {string} uuid The uuid of the authenticated account.
+ * 
+ * @returns {boolean} True if the account was removed, false if it never existed.
+ */
+exports.removeAuthAccount = function(uuid){
+    if(config.authenticationDatabase[uuid] != null){
+        delete config.authenticationDatabase[uuid]
+        if(config.selectedAccount === uuid){
+            const keys = Object.keys(config.authenticationDatabase)
+            if(keys.length > 0){
+                config.selectedAccount = keys[0]
+            } else {
+                config.selectedAccount = null
+            }
+        }
+        return true
+    }
+    return false
+}
+
 /**
  * Get the currently selected authenticated account.
  * 

+ 1 - 3
package.json

@@ -67,9 +67,7 @@
       "perMachine": true,
       "allowElevation": true,
       "installerIcon": "build/icon.ico",
-      "uninstallerIcon": "build/icon.ico",
-      "installerHeader": "build/icon.ico",
-      "installerHeaderIcon": "build/icon.ico"
+      "uninstallerIcon": "build/icon.ico"
     },
     "mac": {
       "target": "dmg",