mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 01:35:49 +03:00
move room directory logic over from riot-web
This commit is contained in:
parent
178fb647ad
commit
70f3804227
1 changed files with 23 additions and 0 deletions
23
src/utils/DirectoryUtils.js
Normal file
23
src/utils/DirectoryUtils.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Find a protocol 'instance' with a given instance_id
|
||||
// in the supplied protocols dict
|
||||
export function instanceForInstanceId(protocols, instance_id) {
|
||||
if (!instance_id) return null;
|
||||
for (const proto of Object.keys(protocols)) {
|
||||
if (!protocols[proto].instances && protocols[proto].instances instanceof Array) continue;
|
||||
for (const instance of protocols[proto].instances) {
|
||||
if (instance.instance_id == instance_id) return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// given an instance_id, return the name of the protocol for
|
||||
// that instance ID in the supplied protocols dict
|
||||
export function protocolNameForInstanceId(protocols, instance_id) {
|
||||
if (!instance_id) return null;
|
||||
for (const proto of Object.keys(protocols)) {
|
||||
if (!protocols[proto].instances && protocols[proto].instances instanceof Array) continue;
|
||||
for (const instance of protocols[proto].instances) {
|
||||
if (instance.instance_id == instance_id) return proto;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue