mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-19 07:56:02 +01:00
refactor(client/interface): default notify backwards compat
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
---@alias NotificationPosition 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left'
|
---@alias NotificationPosition 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' | 'center-right' | 'center-left'
|
||||||
---@alias NotificationType 'inform' | 'error' | 'success'
|
---@alias NotificationType 'inform' | 'error' | 'success'
|
||||||
|
|
||||||
---@class NotifyProps
|
---@class NotifyProps
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
---@param data NotifyProps
|
---@param data NotifyProps
|
||||||
function lib.notify(data)
|
function lib.notify(data)
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'customNotify',
|
action = 'notify',
|
||||||
data = data
|
data = data
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@@ -30,10 +30,10 @@ end
|
|||||||
|
|
||||||
---@param data DefaultNotifyProps
|
---@param data DefaultNotifyProps
|
||||||
function lib.defaultNotify(data)
|
function lib.defaultNotify(data)
|
||||||
SendNUIMessage({
|
-- Backwards compat for v3
|
||||||
action = 'notify',
|
data.type = data.status
|
||||||
data = data
|
if data.type == 'info' or data.type == 'warning' then data.type = 'inform' end
|
||||||
})
|
return lib.notify(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterNetEvent('ox_lib:notify', lib.notify)
|
RegisterNetEvent('ox_lib:notify', lib.notify)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { debugData } from '../../../utils/debugData';
|
|||||||
export const debugCustomNotification = () => {
|
export const debugCustomNotification = () => {
|
||||||
debugData<CustomNotificationProps>([
|
debugData<CustomNotificationProps>([
|
||||||
{
|
{
|
||||||
action: 'customNotify',
|
action: 'notify',
|
||||||
data: {
|
data: {
|
||||||
title: 'Success',
|
title: 'Success',
|
||||||
description: 'Notification description',
|
description: 'Notification description',
|
||||||
@@ -14,7 +14,7 @@ export const debugCustomNotification = () => {
|
|||||||
]);
|
]);
|
||||||
debugData<CustomNotificationProps>([
|
debugData<CustomNotificationProps>([
|
||||||
{
|
{
|
||||||
action: 'customNotify',
|
action: 'notify',
|
||||||
data: {
|
data: {
|
||||||
title: 'Info',
|
title: 'Info',
|
||||||
description: 'Notification description',
|
description: 'Notification description',
|
||||||
@@ -24,7 +24,7 @@ export const debugCustomNotification = () => {
|
|||||||
]);
|
]);
|
||||||
debugData<CustomNotificationProps>([
|
debugData<CustomNotificationProps>([
|
||||||
{
|
{
|
||||||
action: 'customNotify',
|
action: 'notify',
|
||||||
data: {
|
data: {
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
description: 'Notification description',
|
description: 'Notification description',
|
||||||
@@ -34,7 +34,7 @@ export const debugCustomNotification = () => {
|
|||||||
]);
|
]);
|
||||||
debugData<CustomNotificationProps>([
|
debugData<CustomNotificationProps>([
|
||||||
{
|
{
|
||||||
action: 'customNotify',
|
action: 'notify',
|
||||||
data: {
|
data: {
|
||||||
title: 'Custom icon success',
|
title: 'Custom icon success',
|
||||||
description: 'Notification description',
|
description: 'Notification description',
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ const exitAnimationBottom = keyframes({
|
|||||||
const Notifications: React.FC = () => {
|
const Notifications: React.FC = () => {
|
||||||
const { classes } = useStyles();
|
const { classes } = useStyles();
|
||||||
|
|
||||||
useNuiEvent<CustomNotificationProps>('customNotify', (data) => {
|
useNuiEvent<CustomNotificationProps>('notify', (data) => {
|
||||||
if (!data.title && !data.description) return;
|
if (!data.title && !data.description) return;
|
||||||
// Backwards compat with old notifications
|
// Backwards compat with old notifications
|
||||||
let position = data.position;
|
let position = data.position;
|
||||||
|
|||||||
Reference in New Issue
Block a user