From 0fbb3d4eb93ba758295eeadd8d3aa22d400dd76a Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Mon, 20 Feb 2023 20:18:34 +0100 Subject: [PATCH] feat: add helper method to lookup default channel --- src/maps/Servers.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/maps/Servers.ts b/src/maps/Servers.ts index 5d917a05..fcdb4427 100644 --- a/src/maps/Servers.ts +++ b/src/maps/Servers.ts @@ -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