Simplify popup handling

This commit is contained in:
boatbomber 2023-01-04 18:59:53 -05:00
parent de33cf0e55
commit d158ccb2eb

View file

@ -213,10 +213,7 @@ function App:requestPermission(source: string, name: string, apis: {string}, ini
self:setState(function(state) self:setState(function(state)
state.popups[source] = { state.popups[source] = {
responseEvent = responseEvent,
initialState = initialState,
name = name, name = name,
apis = apis,
content = e(PermissionPopup, { content = e(PermissionPopup, {
responseEvent = responseEvent, responseEvent = responseEvent,
initialState = initialState, initialState = initialState,
@ -226,6 +223,10 @@ function App:requestPermission(source: string, name: string, apis: {string}, ini
apiDescriptions = self.headlessAPI._apiDescriptions, apiDescriptions = self.headlessAPI._apiDescriptions,
transparency = Roact.createBinding(0), transparency = Roact.createBinding(0),
}), }),
onClose = function()
responseEvent:Fire(initialState)
responseEvent:Destroy()
end,
} }
return state return state
end) end)
@ -418,15 +419,7 @@ function App:render()
zIndexBehavior = Enum.ZIndexBehavior.Sibling, zIndexBehavior = Enum.ZIndexBehavior.Sibling,
onClose = function() onClose = popup.onClose,
popup.responseEvent:Fire(popup.initialState)
popup.responseEvent:Destroy()
self:setState(function(state)
state.popups[id] = nil
return state
end)
end,
}, { }, {
Content = popup.content, Content = popup.content,