99 lines
2.8 KiB
Lua
99 lines
2.8 KiB
Lua
local UserInputService = game:GetService("UserInputService")
|
|
|
|
local Modules = game:GetService("CoreGui").RobloxGui.Modules
|
|
local LuaApp = Modules.LuaApp
|
|
local LuaChat = Modules.LuaChat
|
|
|
|
local BaseScreen = require(LuaChat.Views.Phone.BaseScreen)
|
|
local Create = require(LuaChat.Create)
|
|
|
|
local ConversationHubComponent = require(LuaChat.Components.ConversationHub)
|
|
|
|
local DialogInfo = require(LuaChat.DialogInfo)
|
|
local Constants = require(LuaChat.Constants)
|
|
local ConversationActions = require(LuaChat.Actions.ConversationActions)
|
|
|
|
local SetRoute = require(LuaChat.Actions.SetRoute)
|
|
local SetTabBarVisible = require(LuaApp.Actions.SetTabBarVisible)
|
|
|
|
local Intent = DialogInfo.Intent
|
|
|
|
local ConversationHub = BaseScreen:Template()
|
|
|
|
ConversationHub.__index = ConversationHub
|
|
|
|
function ConversationHub.new(appState, route)
|
|
local self = {}
|
|
|
|
setmetatable(self, ConversationHub)
|
|
|
|
self.appState = appState
|
|
self.route = route
|
|
|
|
self.ConversationHubComponent = ConversationHubComponent.new(appState)
|
|
self.rbx = self.ConversationHubComponent.rbx
|
|
|
|
local spacer = Create.new "Frame" {
|
|
Name = "Spacer",
|
|
Size = UDim2.new(1, 0, 0, UserInputService.BottomBarSize.Y),
|
|
BackgroundColor3 = Constants.Color.WHITE,
|
|
BorderColor3 = Constants.Color.WHITE,
|
|
BackgroundTransparency = 0,
|
|
LayoutOrder = 3,
|
|
}
|
|
spacer.Parent = self.rbx
|
|
|
|
self.ConversationHubComponent.ConversationTapped:connect(function(convoId)
|
|
if self.appState.screenManager:GetCurrentView() ~= self then
|
|
return
|
|
end
|
|
|
|
local conversation = self.appState.store:getState().ChatAppReducer.Conversations[convoId]
|
|
|
|
if conversation == nil then
|
|
return
|
|
end
|
|
|
|
if conversation.serverState == Constants.ServerState.NONE then
|
|
self.appState.store:dispatch(ConversationActions.StartOneToOneConversation(conversation, function(id)
|
|
self.appState.store:dispatch(SetRoute(Intent.Conversation, {conversationId = id}))
|
|
end))
|
|
else
|
|
self.appState.store:dispatch(SetRoute(Intent.Conversation, {conversationId = convoId}))
|
|
end
|
|
end)
|
|
|
|
self.ConversationHubComponent.CreateChatButtonPressed:connect(function()
|
|
self.appState.store:dispatch(SetRoute(Intent.CreateChat, {}))
|
|
end)
|
|
|
|
return self
|
|
end
|
|
|
|
function ConversationHub:Start()
|
|
BaseScreen.Start(self)
|
|
self.ConversationHubComponent:Start()
|
|
self.appState.store:dispatch(SetTabBarVisible(true))
|
|
end
|
|
|
|
function ConversationHub:Stop()
|
|
BaseScreen.Stop(self)
|
|
self.ConversationHubComponent:Stop()
|
|
self.appState.store:dispatch(SetTabBarVisible(false))
|
|
end
|
|
|
|
function ConversationHub:Resume()
|
|
BaseScreen.Resume(self)
|
|
self.appState.store:dispatch(SetTabBarVisible(true))
|
|
end
|
|
|
|
function ConversationHub:Pause()
|
|
BaseScreen.Pause(self)
|
|
self.appState.store:dispatch(SetTabBarVisible(false))
|
|
end
|
|
|
|
function ConversationHub:Update(state, oldState)
|
|
self.ConversationHubComponent:Update(state, oldState)
|
|
end
|
|
|
|
return ConversationHub |