[MM-50485] Migrate app to ServerManager, remove view names and replace with IDs (#2672)
* Migrate app to ServerManager, remove view names and replace with IDs * Fixed a test * Fixed a bug when adding the initial server * Merge'd * Bug fixes and PR feedback
This commit is contained in:
@@ -145,9 +145,9 @@ export class ServerManager extends EventEmitter {
|
||||
}
|
||||
const tabs = this.getOrderedTabsForServer(server.id);
|
||||
|
||||
let selectedTab = tabs.find((tab) => tab && tab.name === TAB_MESSAGING);
|
||||
let selectedTab = tabs.find((tab) => tab && tab.type === TAB_MESSAGING);
|
||||
tabs.
|
||||
filter((tab) => tab && tab.name !== TAB_MESSAGING).
|
||||
filter((tab) => tab && tab.type !== TAB_MESSAGING).
|
||||
forEach((tab) => {
|
||||
if (parsedURL.pathname.match(new RegExp(`^${tab.url.pathname}(/(.+))?`))) {
|
||||
selectedTab = tab;
|
||||
@@ -187,6 +187,10 @@ export class ServerManager extends EventEmitter {
|
||||
});
|
||||
this.tabOrder.set(newServer.id, tabOrder);
|
||||
|
||||
if (!this.currentServerId) {
|
||||
this.currentServerId = newServer.id;
|
||||
}
|
||||
|
||||
// Emit this event whenever we update a server URL to ensure remote info is fetched
|
||||
this.emit(SERVERS_URL_MODIFIED, [newServer.id]);
|
||||
this.persistServers();
|
||||
@@ -230,6 +234,10 @@ export class ServerManager extends EventEmitter {
|
||||
this.remoteInfo.delete(serverId);
|
||||
this.servers.delete(serverId);
|
||||
|
||||
if (this.currentServerId === serverId && this.hasServers()) {
|
||||
this.currentServerId = this.serverOrder[0];
|
||||
}
|
||||
|
||||
this.persistServers();
|
||||
}
|
||||
|
||||
@@ -274,7 +282,7 @@ export class ServerManager extends EventEmitter {
|
||||
}
|
||||
this.filterOutDuplicateTeams();
|
||||
this.serverOrder = serverOrder;
|
||||
if (Config.lastActiveTeam) {
|
||||
if (Config.lastActiveTeam && this.serverOrder[Config.lastActiveTeam]) {
|
||||
this.currentServerId = this.serverOrder[Config.lastActiveTeam];
|
||||
} else {
|
||||
this.currentServerId = this.serverOrder[0];
|
||||
@@ -417,13 +425,13 @@ export class ServerManager extends EventEmitter {
|
||||
tabOrder.forEach((tabId) => {
|
||||
const tab = this.tabs.get(tabId);
|
||||
if (tab) {
|
||||
if (tab.name === TAB_PLAYBOOKS && remoteInfo.hasPlaybooks && typeof tab.isOpen === 'undefined') {
|
||||
if (tab.type === TAB_PLAYBOOKS && remoteInfo.hasPlaybooks && typeof tab.isOpen === 'undefined') {
|
||||
log.withPrefix(tab.id).verbose('opening Playbooks');
|
||||
tab.isOpen = true;
|
||||
this.tabs.set(tabId, tab);
|
||||
hasUpdates = true;
|
||||
}
|
||||
if (tab.name === TAB_FOCALBOARD && remoteInfo.hasFocalboard && typeof tab.isOpen === 'undefined') {
|
||||
if (tab.type === TAB_FOCALBOARD && remoteInfo.hasFocalboard && typeof tab.isOpen === 'undefined') {
|
||||
log.withPrefix(tab.id).verbose('opening Boards');
|
||||
tab.isOpen = true;
|
||||
this.tabs.set(tabId, tab);
|
||||
@@ -453,7 +461,7 @@ export class ServerManager extends EventEmitter {
|
||||
if (!view) {
|
||||
return new Logger(viewId);
|
||||
}
|
||||
return new Logger(...additionalPrefixes, ...this.includeId(viewId, view.server.name, view.name));
|
||||
return new Logger(...additionalPrefixes, ...this.includeId(viewId, view.server.name, view.type));
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user