forked from rojo-rbx/rojo
Use singleton settings outside the Roact tree (#576)
* Use singleton settings outside the Roact tree * Cleanup listener on unmount * Refactor setting page components * Fix willUnmount being added to the wrong table * Remove bindings in favor of state
This commit is contained in:
@@ -7,6 +7,7 @@ local Log = require(Rojo.Log)
|
||||
local Assets = require(Plugin.Assets)
|
||||
local Version = require(Plugin.Version)
|
||||
local Config = require(Plugin.Config)
|
||||
local Settings = require(Plugin.Settings)
|
||||
local strict = require(Plugin.strict)
|
||||
local Dictionary = require(Plugin.Dictionary)
|
||||
local ServeSession = require(Plugin.ServeSession)
|
||||
@@ -14,7 +15,6 @@ local ApiContext = require(Plugin.ApiContext)
|
||||
local preloadAssets = require(Plugin.preloadAssets)
|
||||
local soundPlayer = require(Plugin.soundPlayer)
|
||||
local Theme = require(script.Theme)
|
||||
local PluginSettings = require(script.PluginSettings)
|
||||
|
||||
local Page = require(script.Page)
|
||||
local Notifications = require(script.Notifications)
|
||||
@@ -52,7 +52,7 @@ function App:init()
|
||||
end
|
||||
|
||||
function App:addNotification(text: string, timeout: number?)
|
||||
if not self.props.settings:get("showNotifications") then
|
||||
if not Settings:get("showNotifications") then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -91,8 +91,8 @@ function App:startSession()
|
||||
local host, port = self:getHostAndPort()
|
||||
|
||||
local sessionOptions = {
|
||||
openScriptsExternally = self.props.settings:get("openScriptsExternally"),
|
||||
twoWaySync = self.props.settings:get("twoWaySync"),
|
||||
openScriptsExternally = Settings:get("openScriptsExternally"),
|
||||
twoWaySync = Settings:get("twoWaySync"),
|
||||
}
|
||||
|
||||
local baseUrl = ("http://%s:%s"):format(host, port)
|
||||
@@ -345,15 +345,9 @@ function App:render()
|
||||
end
|
||||
|
||||
return function(props)
|
||||
return e(PluginSettings.StudioProvider, {
|
||||
plugin = props.plugin,
|
||||
}, {
|
||||
App = PluginSettings.with(function(settings)
|
||||
local mergedProps = Dictionary.merge(props, {
|
||||
settings = settings,
|
||||
soundPlayer = soundPlayer.new(settings),
|
||||
})
|
||||
return e(App, mergedProps)
|
||||
end),
|
||||
local mergedProps = Dictionary.merge(props, {
|
||||
soundPlayer = soundPlayer.new(Settings),
|
||||
})
|
||||
|
||||
return e(App, mergedProps)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user