From 5f91a8fdfe4204db34e40a47cf68087e3efac951 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Thu, 10 Jan 2019 16:12:52 -0800 Subject: [PATCH] Fix bug where HTTP being disabled would cause stickiness --- plugin/src/ApiContext.lua | 2 +- plugin/src/Components/App.lua | 11 +++++++---- plugin/src/Http.lua | 2 +- plugin/src/HttpError.lua | 9 +-------- plugin/src/Session.lua | 6 +++++- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugin/src/ApiContext.lua b/plugin/src/ApiContext.lua index aba7f53d..c16535d0 100644 --- a/plugin/src/ApiContext.lua +++ b/plugin/src/ApiContext.lua @@ -97,10 +97,10 @@ function ApiContext:connect() end self.serverId = body.serverId - self.connected = true self.partitionRoutes = body.partitions self.rootInstanceId = body.rootInstanceId self.instanceMetadataMap = body.instanceMetadataMap + self.connected = true end) end diff --git a/plugin/src/Components/App.lua b/plugin/src/Components/App.lua index eebcfa29..bf90b1cc 100644 --- a/plugin/src/Components/App.lua +++ b/plugin/src/Components/App.lua @@ -87,7 +87,7 @@ function App:render() startSession = function(address, port) Logging.trace("Starting new session") - self.currentSession = Session.new({ + local success, session = Session.new({ address = address, port = port, onError = function() @@ -100,9 +100,12 @@ function App:render() end }) - self:setState({ - sessionStatus = SessionStatus.Connected, - }) + if success then + self.currentSession = session + self:setState({ + sessionStatus = SessionStatus.Connected, + }) + end end, cancel = function() Logging.trace("Canceling session configuration") diff --git a/plugin/src/Http.lua b/plugin/src/Http.lua index eda12b05..03b26658 100644 --- a/plugin/src/Http.lua +++ b/plugin/src/Http.lua @@ -72,4 +72,4 @@ function Http.jsonDecode(source) return HttpService:JSONDecode(source) end -return Http +return Http \ No newline at end of file diff --git a/plugin/src/HttpError.lua b/plugin/src/HttpError.lua index f1b06fc2..e1ef9b7a 100644 --- a/plugin/src/HttpError.lua +++ b/plugin/src/HttpError.lua @@ -1,6 +1,3 @@ -local Selection = game:GetService("Selection") -local HttpService = game:GetService("HttpService") - local Logging = require(script.Parent.Logging) local HttpError = {} @@ -70,10 +67,6 @@ end function HttpError:report() Logging.warn(self.message) - - if self.type == HttpError.Error.HttpNotEnabled then - Selection:Set(HttpService) - end end -return HttpError +return HttpError \ No newline at end of file diff --git a/plugin/src/Session.lua b/plugin/src/Session.lua index fd086ff7..5e1d15df 100644 --- a/plugin/src/Session.lua +++ b/plugin/src/Session.lua @@ -10,6 +10,8 @@ function Session.new(config) self.onError = config.onError + local hasErrors = false + local reconciler local remoteUrl = ("http://%s:%s"):format(config.address, config.port) @@ -36,6 +38,7 @@ function Session.new(config) return reconciler:applyUpdate(requestedIds, response.instances) end) :catch(function(message) + hasErrors = true Logging.warn("%s", tostring(message)) self.onError() end) @@ -52,11 +55,12 @@ function Session.new(config) return api:retrieveMessages() end) :catch(function(message) + hasErrors = true Logging.warn("%s", tostring(message)) self.onError() end) - return setmetatable(self, Session) + return not hasErrors, setmetatable(self, Session) end return Session \ No newline at end of file