You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-08 21:42:24 +03:00
Expose a getOrderedManagers() function for use elsewhere
This commit is contained in:
@@ -144,22 +144,28 @@ export class IntegrationManagers {
|
|||||||
return this._managers.length > 0;
|
return this._managers.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getOrderedManagers(): IntegrationManagerInstance[] {
|
||||||
|
const ordered = [];
|
||||||
|
for (const kind of KIND_PREFERENCE) {
|
||||||
|
const managers = this._managers.filter(m => m.kind === kind);
|
||||||
|
if (!managers || !managers.length) continue;
|
||||||
|
|
||||||
|
if (kind === KIND_ACCOUNT) {
|
||||||
|
// Order by state_keys (IDs)
|
||||||
|
managers.sort((a, b) => a.id.localeCompare(b.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
ordered.push(...managers);
|
||||||
|
}
|
||||||
|
return ordered;
|
||||||
|
}
|
||||||
|
|
||||||
getPrimaryManager(): IntegrationManagerInstance {
|
getPrimaryManager(): IntegrationManagerInstance {
|
||||||
if (this.hasManager()) {
|
if (this.hasManager()) {
|
||||||
if (this._primaryManager) return this._primaryManager;
|
if (this._primaryManager) return this._primaryManager;
|
||||||
|
|
||||||
for (const kind of KIND_PREFERENCE) {
|
this._primaryManager = this.getOrderedManagers()[0];
|
||||||
const managers = this._managers.filter(m => m.kind === kind);
|
return this._primaryManager;
|
||||||
if (!managers || !managers.length) continue;
|
|
||||||
|
|
||||||
if (kind === KIND_ACCOUNT) {
|
|
||||||
// Order by state_keys (IDs)
|
|
||||||
managers.sort((a, b) => a.id.localeCompare(b.id));
|
|
||||||
}
|
|
||||||
|
|
||||||
this._primaryManager = managers[0];
|
|
||||||
return this._primaryManager;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user