refactor(client/interface): default notify backwards compat

This commit is contained in:
Luke
2023-01-11 20:38:58 +01:00
parent e68d8d311c
commit 9a3cff864e
3 changed files with 11 additions and 11 deletions

View File

@@ -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'
---@class NotifyProps
@@ -15,7 +15,7 @@
---@param data NotifyProps
function lib.notify(data)
SendNUIMessage({
action = 'customNotify',
action = 'notify',
data = data
})
end
@@ -30,10 +30,10 @@ end
---@param data DefaultNotifyProps
function lib.defaultNotify(data)
SendNUIMessage({
action = 'notify',
data = data
})
-- Backwards compat for v3
data.type = data.status
if data.type == 'info' or data.type == 'warning' then data.type = 'inform' end
return lib.notify(data)
end
RegisterNetEvent('ox_lib:notify', lib.notify)

View File

@@ -4,7 +4,7 @@ import { debugData } from '../../../utils/debugData';
export const debugCustomNotification = () => {
debugData<CustomNotificationProps>([
{
action: 'customNotify',
action: 'notify',
data: {
title: 'Success',
description: 'Notification description',
@@ -14,7 +14,7 @@ export const debugCustomNotification = () => {
]);
debugData<CustomNotificationProps>([
{
action: 'customNotify',
action: 'notify',
data: {
title: 'Info',
description: 'Notification description',
@@ -24,7 +24,7 @@ export const debugCustomNotification = () => {
]);
debugData<CustomNotificationProps>([
{
action: 'customNotify',
action: 'notify',
data: {
title: 'Error',
description: 'Notification description',
@@ -34,7 +34,7 @@ export const debugCustomNotification = () => {
]);
debugData<CustomNotificationProps>([
{
action: 'customNotify',
action: 'notify',
data: {
title: 'Custom icon success',
description: 'Notification description',

View File

@@ -119,7 +119,7 @@ const exitAnimationBottom = keyframes({
const Notifications: React.FC = () => {
const { classes } = useStyles();
useNuiEvent<CustomNotificationProps>('customNotify', (data) => {
useNuiEvent<CustomNotificationProps>('notify', (data) => {
if (!data.title && !data.description) return;
// Backwards compat with old notifications
let position = data.position;