mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-21 04:25:27 -04:00
feat: add helper method to lookup default channel
This commit is contained in:
+11
-4
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user