Refactor GetChannelId out of FindOrJoinChannel
No reason for it to be nested
This commit is contained in:
@@ -13,18 +13,18 @@ function shared.Messenger.Init()
|
|||||||
---@type table<string, number>
|
---@type table<string, number>
|
||||||
local channelIdMap = {}
|
local channelIdMap = {}
|
||||||
|
|
||||||
local function FindOrJoinChannel(channelName, password)
|
local function GetChannelId(channelName)
|
||||||
local function GetChannelId(channelName)
|
local channels = { GetChannelList() }
|
||||||
local channels = { GetChannelList() }
|
for i = 1, #channels, 2 do
|
||||||
for i = 1, #channels, 2 do
|
local id = channels[i]
|
||||||
local id = channels[i]
|
local name = channels[i + 1]
|
||||||
local name = channels[i + 1]
|
if name == channelName then
|
||||||
if name == channelName then
|
return id
|
||||||
return id
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function FindOrJoinChannel(channelName, password)
|
||||||
local channelId = GetChannelId(channelName)
|
local channelId = GetChannelId(channelName)
|
||||||
if not channelId then
|
if not channelId then
|
||||||
print("Channel", tostring(channelName), "not found, joining")
|
print("Channel", tostring(channelName), "not found, joining")
|
||||||
@@ -48,7 +48,7 @@ function shared.Messenger.Init()
|
|||||||
end
|
end
|
||||||
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 then shared.messenger = {} end
|
||||||
if not shared.messenger.queue then shared.messenger.queue = {} end
|
if not shared.messenger.queue then shared.messenger.queue = {} end
|
||||||
if not shared.messenger.ticker then
|
if not shared.messenger.ticker then
|
||||||
|
Reference in New Issue
Block a user