Fix editing permissions to use new request api

This commit is contained in:
boatbomber 2023-07-08 15:39:54 -07:00
parent dcfdf7fabd
commit a0b99317bc
2 changed files with 8 additions and 5 deletions

View file

@ -100,7 +100,7 @@ function PermissionsPage:render()
),
onClick = function()
self.props.onEdit(source, meta, self.props.headlessAPI._permissions[source] or {})
self.props.onEdit(self.props.headlessAPI._sourceToPlugin[source], source, meta, self.props.headlessAPI._permissions[source] or {})
end,
})
end

View file

@ -319,10 +319,10 @@ function App:requestPermission(plugin: Plugin, source: string, name: string, api
Log.info("The third-party plugin '{}' is requesting permission to use the API!", name)
local unloadProtection = plugin.Unloading:Connect(function()
local unloadProtection = if plugin then plugin.Unloading:Connect(function()
Log.warn("Cancelling API permission request for '{}' because the third-party plugin has been removed.", name)
responseEvent:Fire(initialState)
end)
end) else nil
self:setState(function(state)
state.popups[source .. " Permissions"] = {
@ -345,7 +345,9 @@ function App:requestPermission(plugin: Plugin, source: string, name: string, api
local response = responseEvent.Event:Wait()
responseEvent:Destroy()
unloadProtection:Disconnect()
if unloadProtection then
unloadProtection:Disconnect()
end
self:setState(function(state)
state.popups[source .. " Permissions"] = nil
@ -687,12 +689,13 @@ function App:render()
})
end,
onEdit = function(source, meta, apiMap)
onEdit = function(plugin, source, meta, apiMap)
local apiList = {}
for api in apiMap do
table.insert(apiList, api)
end
self:requestPermission(
plugin,
source,
meta.Name .. if meta.Creator then " by " .. meta.Creator else "",
apiList,