Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 70f3804

Browse files
committed
move room directory logic over from riot-web
1 parent 178fb64 commit 70f3804

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/utils/DirectoryUtils.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Find a protocol 'instance' with a given instance_id
2+
// in the supplied protocols dict
3+
export function instanceForInstanceId(protocols, instance_id) {
4+
if (!instance_id) return null;
5+
for (const proto of Object.keys(protocols)) {
6+
if (!protocols[proto].instances && protocols[proto].instances instanceof Array) continue;
7+
for (const instance of protocols[proto].instances) {
8+
if (instance.instance_id == instance_id) return instance;
9+
}
10+
}
11+
}
12+
13+
// given an instance_id, return the name of the protocol for
14+
// that instance ID in the supplied protocols dict
15+
export function protocolNameForInstanceId(protocols, instance_id) {
16+
if (!instance_id) return null;
17+
for (const proto of Object.keys(protocols)) {
18+
if (!protocols[proto].instances && protocols[proto].instances instanceof Array) continue;
19+
for (const instance of protocols[proto].instances) {
20+
if (instance.instance_id == instance_id) return proto;
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)