Fix regression of avoiding duplicated servers.

This commit is contained in:
Zhongyi Tong
2017-08-16 12:48:31 -04:00
parent 48b829b771
commit 965b55ba5f
2 changed files with 7 additions and 6 deletions

View File

@@ -49,7 +49,7 @@ class ServerManagerView {
if (servers.length > 0) {
for (let i = 0; i < servers.length; i++) {
this.initServer(servers[i], i);
DomainUtil.updateSavedServer(servers[i].url, i);
DomainUtil.updateSavedServer(servers[i].url, i);
}
this.activateTab(0);
} else {

View File

@@ -90,8 +90,9 @@ class DomainUtil {
}
checkDomain(domain, silent = false) {
if (silent && this.duplicateDomain(domain)) {
alert('This Server Address already exists.');
if (!silent && this.duplicateDomain(domain)) {
// Do not check duplicate in silent mode
alert('This server has been added.');
return;
}
@@ -200,7 +201,7 @@ class DomainUtil {
updateSavedServer(url, index) {
// Does not promise successful update
this.checkDomain(url, false).then(newServerConf => {
this.checkDomain(url, true).then(newServerConf => {
this.saveServerIcon(newServerConf.icon).then(localIconUrl => {
newServerConf.icon = localIconUrl;
this.updateDomain(index, newServerConf);
@@ -220,8 +221,8 @@ class DomainUtil {
let hash = 5381;
let len = url.length;
while(len) {
hash = (hash * 33) ^ url.charCodeAt(--len)
while (len) {
hash = (hash * 33) ^ url.charCodeAt(--len);
}
// Create 'server-icons' directory if not existed