feat: add helper method to lookup default channel

This commit is contained in:
Paul Makles
2023-02-20 20:18:34 +01:00
parent 0065ca790f
commit 0fbb3d4eb9
+11 -4
View File
@@ -102,9 +102,8 @@ export class Server {
channels,
};
if (cat.id === 'default') {
if (channels.length === 0)
continue;
if (cat.id === "default") {
if (channels.length === 0) continue;
defaultCategory = cat;
}
@@ -121,7 +120,7 @@ export class Server {
if (defaultCategory) {
defaultCategory.channels = [
...defaultCategory.channels,
...channels
...channels,
];
} else {
elements.unshift({
@@ -135,6 +134,14 @@ export class Server {
return elements;
}
/**
* Get the default channel for this server
*/
@computed get defaultChannel(): Channel | undefined {
return this.orderedChannels.find((cat) => cat.channels.length)
?.channels[0];
}
/**
* Get an ordered array of roles with their IDs attached.
* The highest ranking roles will be first followed by lower