mirror of https://github.com/vector-im/riot-web
Expose a getOrderedManagers() function for use elsewhere
parent
8493887ceb
commit
470295ad14
|
@ -144,10 +144,8 @@ export class IntegrationManagers {
|
|||
return this._managers.length > 0;
|
||||
}
|
||||
|
||||
getPrimaryManager(): IntegrationManagerInstance {
|
||||
if (this.hasManager()) {
|
||||
if (this._primaryManager) return this._primaryManager;
|
||||
|
||||
getOrderedManagers(): IntegrationManagerInstance[] {
|
||||
const ordered = [];
|
||||
for (const kind of KIND_PREFERENCE) {
|
||||
const managers = this._managers.filter(m => m.kind === kind);
|
||||
if (!managers || !managers.length) continue;
|
||||
|
@ -157,9 +155,17 @@ export class IntegrationManagers {
|
|||
managers.sort((a, b) => a.id.localeCompare(b.id));
|
||||
}
|
||||
|
||||
this._primaryManager = managers[0];
|
||||
return this._primaryManager;
|
||||
ordered.push(...managers);
|
||||
}
|
||||
return ordered;
|
||||
}
|
||||
|
||||
getPrimaryManager(): IntegrationManagerInstance {
|
||||
if (this.hasManager()) {
|
||||
if (this._primaryManager) return this._primaryManager;
|
||||
|
||||
this._primaryManager = this.getOrderedManagers()[0];
|
||||
return this._primaryManager;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue