mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
Revert "fix(web/radial): go back to correct more page when going back from sub"
This reverts commit 709d512422.
This commit is contained in:
@@ -24,9 +24,6 @@ local menuHistory = {}
|
|||||||
---@type RadialMenuProps?
|
---@type RadialMenuProps?
|
||||||
local currentRadial = nil
|
local currentRadial = nil
|
||||||
|
|
||||||
---@type number | nil
|
|
||||||
local menuPage = nil
|
|
||||||
|
|
||||||
---Open a the global radial menu or a registered radial submenu with the given id.
|
---Open a the global radial menu or a registered radial submenu with the given id.
|
||||||
---@param id string?
|
---@param id string?
|
||||||
local function showRadial(id)
|
local function showRadial(id)
|
||||||
@@ -116,7 +113,7 @@ function lib.hideRadial()
|
|||||||
|
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'openRadialMenu',
|
action = 'openRadialMenu',
|
||||||
data = menuPage or false
|
data = false
|
||||||
})
|
})
|
||||||
|
|
||||||
SetNuiFocus(false, false)
|
SetNuiFocus(false, false)
|
||||||
@@ -244,12 +241,9 @@ lib.addKeybind({
|
|||||||
defaultKey = 'z',
|
defaultKey = 'z',
|
||||||
onPressed = function()
|
onPressed = function()
|
||||||
if isOpen then
|
if isOpen then
|
||||||
menuPage = 1
|
|
||||||
return lib.hideRadial()
|
return lib.hideRadial()
|
||||||
end
|
end
|
||||||
|
|
||||||
menuPage = nil
|
|
||||||
|
|
||||||
if #menuItems == 0 or IsNuiFocused() or IsPauseMenuActive() then return end
|
if #menuItems == 0 or IsNuiFocused() or IsPauseMenuActive() then return end
|
||||||
|
|
||||||
isOpen = true
|
isOpen = true
|
||||||
|
|||||||
@@ -87,19 +87,11 @@ const RadialMenu: React.FC = () => {
|
|||||||
setMenuItems(items);
|
setMenuItems(items);
|
||||||
}, [menu.items, menu.page]);
|
}, [menu.items, menu.page]);
|
||||||
|
|
||||||
useNuiEvent(
|
useNuiEvent('openRadialMenu', async (data: { items: RadialMenuItem[]; sub?: boolean } | false) => {
|
||||||
'openRadialMenu',
|
if (!data) return setVisible(false);
|
||||||
async (data: { items: RadialMenuItem[]; sub?: boolean; page?: number } | false | number) => {
|
setMenu({ ...data, page: 1 });
|
||||||
if (!data || typeof data === 'number') {
|
setVisible(true);
|
||||||
setVisible(false);
|
});
|
||||||
if (typeof data === 'number') setMenu((ps) => ({ ...ps, page: data }));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// data.page currently unused but might need later?
|
|
||||||
setMenu((state) => ({ ...data, page: data.page || state.page }));
|
|
||||||
setVisible(true);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
useNuiEvent('refreshItems', (data: RadialMenuItem[]) => {
|
useNuiEvent('refreshItems', (data: RadialMenuItem[]) => {
|
||||||
setMenu({ ...menu, items: data });
|
setMenu({ ...menu, items: data });
|
||||||
@@ -110,8 +102,8 @@ const RadialMenu: React.FC = () => {
|
|||||||
<Box
|
<Box
|
||||||
className={classes.wrapper}
|
className={classes.wrapper}
|
||||||
onContextMenu={async () => {
|
onContextMenu={async () => {
|
||||||
if (menu.sub) fetchNui('radialBack');
|
if (menu.page > 1) await changePage();
|
||||||
else if (menu.page > 1) await changePage();
|
else if (menu.sub) fetchNui('radialBack');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ScaleFade visible={visible}>
|
<ScaleFade visible={visible}>
|
||||||
@@ -169,11 +161,13 @@ const RadialMenu: React.FC = () => {
|
|||||||
<g
|
<g
|
||||||
transform={`translate(175, 175)`}
|
transform={`translate(175, 175)`}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
if (menu.sub) fetchNui('radialBack');
|
if (menu.page > 1) await changePage();
|
||||||
else if (menu.page > 1) await changePage();
|
|
||||||
else {
|
else {
|
||||||
setVisible(false);
|
if (menu.sub) fetchNui('radialBack');
|
||||||
fetchNui('radialClose');
|
else {
|
||||||
|
setVisible(false);
|
||||||
|
fetchNui('radialClose');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user