From f76ef718ede400e49707f019812b63a1a017e69c Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Thu, 2 Jan 2025 14:11:12 +0100 Subject: [PATCH] Refactor GetChannelId out of FindOrJoinChannel No reason for it to be nested --- Modules/Messenger.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Modules/Messenger.lua b/Modules/Messenger.lua index a40a590..035e8e7 100644 --- a/Modules/Messenger.lua +++ b/Modules/Messenger.lua @@ -13,18 +13,18 @@ function shared.Messenger.Init() ---@type table local channelIdMap = {} - local function FindOrJoinChannel(channelName, password) - local function GetChannelId(channelName) - local channels = { GetChannelList() } - for i = 1, #channels, 2 do - local id = channels[i] - local name = channels[i + 1] - if name == channelName then - return id - end + local function GetChannelId(channelName) + local channels = { GetChannelList() } + for i = 1, #channels, 2 do + local id = channels[i] + local name = channels[i + 1] + if name == channelName then + return id end end + end + local function FindOrJoinChannel(channelName, password) local channelId = GetChannelId(channelName) if not channelId then print("Channel", tostring(channelName), "not found, joining") @@ -48,7 +48,7 @@ function shared.Messenger.Init() end end ----@diagnostic disable-next-line: missing-fields + ---@diagnostic disable-next-line: missing-fields if not shared.messenger then shared.messenger = {} end if not shared.messenger.queue then shared.messenger.queue = {} end if not shared.messenger.ticker then