From 5654e1f46f21df90a63a9dd02bf0a7b36e9a0e3c Mon Sep 17 00:00:00 2001 From: Christopher Date: Mon, 22 Mar 2021 23:05:39 +0100 Subject: [PATCH 1/7] feat(bank): update usage of enums --- phone/src/apps/bank/hooks/useBankService.ts | 5 +++-- resources/client/cl_bank.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/phone/src/apps/bank/hooks/useBankService.ts b/phone/src/apps/bank/hooks/useBankService.ts index 0f21beb..669de28 100644 --- a/phone/src/apps/bank/hooks/useBankService.ts +++ b/phone/src/apps/bank/hooks/useBankService.ts @@ -6,6 +6,7 @@ import { useSetRecoilState } from 'recoil'; import { useBankNotification } from './useBankNotification'; import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar'; import { useTranslation } from 'react-i18next'; +import { BankEvents } from '../../../../../typings/bank'; export const useBankService = () => { const setTransaction = useSetRecoilState(bankState.transactions); @@ -21,8 +22,8 @@ export const useBankService = () => { }); }; - useNuiEvent('BANK', 'setTransaction', setTransaction); - useNuiEvent('BANK', 'setCredentials', setCredentials); + useNuiEvent('BANK', BankEvents.SEND_TRANSFERS, setTransaction); + useNuiEvent('BANK', BankEvents.SEND_CREDENTIALS, setCredentials); useNuiEvent('BANK', 'setAlert', handleAddAlert); useNuiEvent('BANK', 'setNotification', setNotification); return { useTransactions, useCredentials, useBankNotification }; diff --git a/resources/client/cl_bank.ts b/resources/client/cl_bank.ts index 3749d72..7644988 100644 --- a/resources/client/cl_bank.ts +++ b/resources/client/cl_bank.ts @@ -5,7 +5,7 @@ onNet(BankEvents.SEND_TRANSFERS, (transfer: any) => { SendNuiMessage( JSON.stringify({ app: 'BANK', - method: 'setTransaction', + method: BankEvents.SEND_TRANSFERS, data: transfer, }), ); @@ -15,7 +15,7 @@ onNet(BankEvents.SEND_CREDENTIALS, (credentials: any) => { SendNuiMessage( JSON.stringify({ app: 'BANK', - method: 'setCredentials', + method: BankEvents.SEND_CREDENTIALS, data: credentials, }), ); From de10ce92b28d85cf5f90b18a9895d1001aef9e5f Mon Sep 17 00:00:00 2001 From: Christopher Date: Mon, 22 Mar 2021 23:15:02 +0100 Subject: [PATCH 2/7] fix(bank): update all events --- phone/src/apps/bank/hooks/useBankService.ts | 5 +++-- resources/client/cl_bank.ts | 5 +++-- typings/phone.ts | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/phone/src/apps/bank/hooks/useBankService.ts b/phone/src/apps/bank/hooks/useBankService.ts index 669de28..75ab4b9 100644 --- a/phone/src/apps/bank/hooks/useBankService.ts +++ b/phone/src/apps/bank/hooks/useBankService.ts @@ -7,6 +7,7 @@ import { useBankNotification } from './useBankNotification'; import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar'; import { useTranslation } from 'react-i18next'; import { BankEvents } from '../../../../../typings/bank'; +import { PhoneEvents } from '../../../../../typings/phone'; export const useBankService = () => { const setTransaction = useSetRecoilState(bankState.transactions); @@ -24,7 +25,7 @@ export const useBankService = () => { useNuiEvent('BANK', BankEvents.SEND_TRANSFERS, setTransaction); useNuiEvent('BANK', BankEvents.SEND_CREDENTIALS, setCredentials); - useNuiEvent('BANK', 'setAlert', handleAddAlert); - useNuiEvent('BANK', 'setNotification', setNotification); + useNuiEvent('BANK', PhoneEvents.SET_ALERT, handleAddAlert); + useNuiEvent('BANK', PhoneEvents.SET_NOTIFICATION, setNotification); return { useTransactions, useCredentials, useBankNotification }; }; diff --git a/resources/client/cl_bank.ts b/resources/client/cl_bank.ts index 7644988..63c9c5a 100644 --- a/resources/client/cl_bank.ts +++ b/resources/client/cl_bank.ts @@ -1,5 +1,6 @@ import { IAlertProps } from '../../typings/alerts'; import { BankEvents } from '../../typings/bank'; +import { PhoneEvents } from '../../typings/phone'; onNet(BankEvents.SEND_TRANSFERS, (transfer: any) => { SendNuiMessage( @@ -35,7 +36,7 @@ onNet(BankEvents.TRANSACTION_ALERT, (result: IAlertProps) => { SendNuiMessage( JSON.stringify({ app: 'BANK', - method: 'setAlert', + method: PhoneEvents.SET_ALERT, data: result, }), ); @@ -45,7 +46,7 @@ onNet(BankEvents.TRANSACTION_NOTIFICATION, (transfer: any) => { SendNuiMessage( JSON.stringify({ app: 'BANK', - method: 'setNotification', + method: PhoneEvents.SET_NOTIFICATION, data: transfer, }), ); diff --git a/typings/phone.ts b/typings/phone.ts index 46f4c05..2b818ef 100644 --- a/typings/phone.ts +++ b/typings/phone.ts @@ -8,4 +8,6 @@ export enum PhoneEvents { OPEN_APP_DAILER = 'npwd:app:DIALER', OPEN_PHONE = 'npwd:open', CLOSE_PHONE = 'npwd:close', + SET_ALERT = 'npwd:setAlert', + SET_NOTIFICATION = 'npwd:setNotification', } From 98efed4e6438110ca96648b5bbd563ed59bb9852 Mon Sep 17 00:00:00 2001 From: Christopher Date: Wed, 24 Mar 2021 19:02:02 +0100 Subject: [PATCH 3/7] fix bank enums --- phone/src/apps/bank/hooks/useBankService.ts | 4 ++-- resources/client/cl_bank.ts | 4 ++-- typings/bank.ts | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/phone/src/apps/bank/hooks/useBankService.ts b/phone/src/apps/bank/hooks/useBankService.ts index 75ab4b9..b31cb0a 100644 --- a/phone/src/apps/bank/hooks/useBankService.ts +++ b/phone/src/apps/bank/hooks/useBankService.ts @@ -25,7 +25,7 @@ export const useBankService = () => { useNuiEvent('BANK', BankEvents.SEND_TRANSFERS, setTransaction); useNuiEvent('BANK', BankEvents.SEND_CREDENTIALS, setCredentials); - useNuiEvent('BANK', PhoneEvents.SET_ALERT, handleAddAlert); - useNuiEvent('BANK', PhoneEvents.SET_NOTIFICATION, setNotification); + useNuiEvent('BANK', BankEvents.SEND_ALERT, handleAddAlert); + useNuiEvent('BANK', BankEvents.SEND_NOTIFICATION, setNotification); return { useTransactions, useCredentials, useBankNotification }; }; diff --git a/resources/client/cl_bank.ts b/resources/client/cl_bank.ts index 63c9c5a..495fdd6 100644 --- a/resources/client/cl_bank.ts +++ b/resources/client/cl_bank.ts @@ -36,7 +36,7 @@ onNet(BankEvents.TRANSACTION_ALERT, (result: IAlertProps) => { SendNuiMessage( JSON.stringify({ app: 'BANK', - method: PhoneEvents.SET_ALERT, + method: BankEvents.SEND_ALERT, data: result, }), ); @@ -46,7 +46,7 @@ onNet(BankEvents.TRANSACTION_NOTIFICATION, (transfer: any) => { SendNuiMessage( JSON.stringify({ app: 'BANK', - method: PhoneEvents.SET_NOTIFICATION, + method: BankEvents.SEND_NOTIFICATION, data: transfer, }), ); diff --git a/typings/bank.ts b/typings/bank.ts index adcad62..328ca9a 100644 --- a/typings/bank.ts +++ b/typings/bank.ts @@ -27,4 +27,6 @@ export enum BankEvents { TRANSACTION_NOTIFICATION = 'npwd:bankTransactionNotification', SEND_CREDENTIALS = 'npwd:sendBankCredentials', GET_CREDENTIALS = 'npwd:getBankCredentials', + SEND_ALERT = 'npwd:sendBankAlert', + SEND_NOTIFICATION = 'npwd:sendBankNotification', } From 2cd3e9e93d4c1506ac6c6eef709929a947bc109e Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 25 Mar 2021 11:31:05 +0100 Subject: [PATCH 4/7] update dial events --- phone/src/apps/dialer/hooks/useDialService.ts | 3 ++- phone/src/os/call/hooks/useCallService.tsx | 6 +++--- resources/client/cl_call.ts | 12 ++++++------ typings/call.ts | 3 +++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/phone/src/apps/dialer/hooks/useDialService.ts b/phone/src/apps/dialer/hooks/useDialService.ts index 4e352e3..0bf2f2f 100644 --- a/phone/src/apps/dialer/hooks/useDialService.ts +++ b/phone/src/apps/dialer/hooks/useDialService.ts @@ -1,8 +1,9 @@ import { useSetRecoilState } from 'recoil'; import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent'; import { dialState } from './state'; +import { CallEvents } from '../../../../../typings/call'; export const useDialService = () => { const setHistory = useSetRecoilState(dialState.history); - useNuiEvent('DIALER', 'setHistory', setHistory); + useNuiEvent('DIALER', CallEvents.SET_CALL_HISTORY, setHistory); }; diff --git a/phone/src/os/call/hooks/useCallService.tsx b/phone/src/os/call/hooks/useCallService.tsx index a1085a3..3f307e8 100644 --- a/phone/src/os/call/hooks/useCallService.tsx +++ b/phone/src/os/call/hooks/useCallService.tsx @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent'; import { useSetRecoilState } from 'recoil'; import { useCall } from './useCall'; -import { CallProps } from '../../../../../typings/call'; +import { CallEvents, CallProps } from '../../../../../typings/call'; import InjectDebugData from '../../debug/InjectDebugData'; import { useCallModal } from './useCallModal'; import { useHistory, useLocation } from 'react-router-dom'; @@ -61,6 +61,6 @@ export const useCallService = () => { setCall(_call); setNotification(_call); }; - useNuiEvent('CALL', 'setCaller', _setCall, call); - useNuiEvent('CALL', 'callModal', setModal); + useNuiEvent('CALL', CallEvents.SET_CALLER, _setCall, call); + useNuiEvent('CALL', CallEvents.SET_CALL_MODAL, setModal); }; diff --git a/resources/client/cl_call.ts b/resources/client/cl_call.ts index 199e12a..671e550 100644 --- a/resources/client/cl_call.ts +++ b/resources/client/cl_call.ts @@ -16,7 +16,7 @@ onNet(CallEvents.START_CALL, (transmitter: string, receiver: string, isTransmitt SendNuiMessage( JSON.stringify({ app: 'CALL', - method: 'setCaller', + method: CallEvents.SET_CALLER, data: { active: true, transmitter: transmitter, @@ -40,7 +40,7 @@ onNet(CallEvents.WAS_ACCEPTED, (channelId: number, currentCall: ICall, isTransmi SendNuiMessage( JSON.stringify({ app: 'CALL', - method: 'setCaller', + method: CallEvents.SET_CALLER, data: { active: true, transmitter: currentCall.transmitter, @@ -63,7 +63,7 @@ onNet(CallEvents.WAS_REJECTED, () => { SendNuiMessage( JSON.stringify({ app: 'CALL', - method: 'setCaller', + method: CallEvents.SET_CALLER, data: { transmitter: null, receiver: null, @@ -93,7 +93,7 @@ onNet(CallEvents.WAS_ENDED, () => { SendNuiMessage( JSON.stringify({ app: 'CALL', - method: 'setCaller', + method: CallEvents.SET_CALLER, data: { transmitter: null, receiver: null, @@ -109,7 +109,7 @@ function openCallModal(show: boolean) { SendNuiMessage( JSON.stringify({ app: 'CALL', - method: 'callModal', + method: CallEvents.SET_CALL_MODAL, data: show, }), ); @@ -119,7 +119,7 @@ onNet(CallEvents.SEND_HISTORY, (calls: ICall) => { SendNuiMessage( JSON.stringify({ app: 'DIALER', - method: 'setHistory', + method: CallEvents.SET_CALL_HISTORY, data: calls, }), ); diff --git a/typings/call.ts b/typings/call.ts index 39f3f14..111c2a2 100644 --- a/typings/call.ts +++ b/typings/call.ts @@ -37,4 +37,7 @@ export enum CallEvents { FETCH_CALLS = 'npwd:fetchCalls', SEND_HISTORY = 'npwd:sendCallHistory', SEND_HANGUP_ANIM = 'npwd:sendHangupAnim', + SET_CALLER = 'npwd:setCaller', + SET_CALL_MODAL = 'npwd:callModal', + SET_CALL_HISTORY = 'npwd:setCallHistory', } From 2e4d752cd356a77008e1bc2fa746602504e7d367 Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 25 Mar 2021 11:42:44 +0100 Subject: [PATCH 5/7] update conatct enums --- phone/src/apps/contacts/hooks/useContactsService.ts | 5 +++-- resources/client/cl_contacts.ts | 4 ++-- typings/contact.ts | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/phone/src/apps/contacts/hooks/useContactsService.ts b/phone/src/apps/contacts/hooks/useContactsService.ts index bbdff6b..21f5899 100644 --- a/phone/src/apps/contacts/hooks/useContactsService.ts +++ b/phone/src/apps/contacts/hooks/useContactsService.ts @@ -4,6 +4,7 @@ import { contactsState } from './state'; import { useContacts } from './useContacts'; import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar'; import { useTranslation } from 'react-i18next'; +import { ContactEvents } from '../../../../../typings/contact'; export const useContactsService = () => { const setContacts = useSetRecoilState(contactsState.contacts); @@ -17,7 +18,7 @@ export const useContactsService = () => { }); }; - useNuiEvent('CONTACTS', 'setContacts', setContacts); - useNuiEvent('CONTACTS', 'setAlert', handleAddAlert); + useNuiEvent('CONTACTS', ContactEvents.SEND_CONTACTS, setContacts); + useNuiEvent('CONTACTS', ContactEvents.SEND_ALERT, handleAddAlert); return useContacts(); }; diff --git a/resources/client/cl_contacts.ts b/resources/client/cl_contacts.ts index c5ef672..796eb16 100644 --- a/resources/client/cl_contacts.ts +++ b/resources/client/cl_contacts.ts @@ -2,7 +2,7 @@ import { ContactEvents } from '../../typings/contact'; import { sendContactsEvent } from '../utils/messages'; onNet(ContactEvents.SEND_CONTACTS, (contacts: any) => { - sendContactsEvent('setContacts', contacts); + sendContactsEvent(ContactEvents.SEND_CONTACTS, contacts); }); RegisterNuiCallbackType(ContactEvents.ADD_CONTACT); @@ -36,5 +36,5 @@ onNet(ContactEvents.DELETE_CONTACT_SUCCESS, () => { }); onNet(ContactEvents.ACTION_RESULT, (alert: any) => { - sendContactsEvent('setAlert', alert); + sendContactsEvent(ContactEvents.SEND_ALERT, alert); }); diff --git a/typings/contact.ts b/typings/contact.ts index 4a0c0f2..ffbe230 100644 --- a/typings/contact.ts +++ b/typings/contact.ts @@ -28,4 +28,5 @@ export enum ContactEvents { DELETE_CONTACT_SUCCESS = 'npwd:deleteSuccess', UPDATE_CONTACT_SUCCESS = 'npwd:updateContactSuccess', ACTION_RESULT = 'npwd:contactActionResult', + SEND_ALERT = 'npwd:contactSetAlert', } From 5ce6cf2d4afbc19d0b7fd1196a2c5ab49ab12a3f Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 25 Mar 2021 12:53:18 +0100 Subject: [PATCH 6/7] update notes enums --- phone/src/apps/notes/hooks/useNotesService.ts | 5 +++-- resources/client/cl_notes.ts | 4 ++-- typings/notes.ts | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/phone/src/apps/notes/hooks/useNotesService.ts b/phone/src/apps/notes/hooks/useNotesService.ts index 79220b8..304dbb8 100644 --- a/phone/src/apps/notes/hooks/useNotesService.ts +++ b/phone/src/apps/notes/hooks/useNotesService.ts @@ -3,6 +3,7 @@ import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent'; import { noteStates } from './state'; import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar'; import { useTranslation } from 'react-i18next'; +import { NotesEvents } from '../../../../../typings/notes'; export const useNotesService = () => { const { addAlert } = useSnackbar(); @@ -16,6 +17,6 @@ export const useNotesService = () => { }); }; - useNuiEvent('NOTES', 'setNotes', setNotes); - useNuiEvent('NOTES', 'setAlert', handleAddAlert); + useNuiEvent('NOTES', NotesEvents.SEND_NOTE, setNotes); + useNuiEvent('NOTES', NotesEvents.SEND_ALERT, handleAddAlert); }; diff --git a/resources/client/cl_notes.ts b/resources/client/cl_notes.ts index 4e07d89..425c9bb 100644 --- a/resources/client/cl_notes.ts +++ b/resources/client/cl_notes.ts @@ -2,7 +2,7 @@ import { NotesEvents } from '../../typings/notes'; import { sendNotesEvent } from '../utils/messages'; onNet(NotesEvents.SEND_NOTE, (notes: any) => { - sendNotesEvent('setNotes', notes); + sendNotesEvent(NotesEvents.SEND_NOTE, notes); }); RegisterNuiCallbackType(NotesEvents.ADD_NOTE); @@ -35,5 +35,5 @@ onNet(NotesEvents.UPDATE_NOTE_SUCCESS, () => { }); onNet(NotesEvents.ACTION_RESULT, (alert: any) => { - sendNotesEvent('setAlert', alert); + sendNotesEvent(NotesEvents.SEND_ALERT, alert); }); diff --git a/typings/notes.ts b/typings/notes.ts index 7f718d8..33373dd 100644 --- a/typings/notes.ts +++ b/typings/notes.ts @@ -32,4 +32,5 @@ export enum NotesEvents { UPDATE_NOTE_SUCCESS = 'npwd:updateNoteSuccess', UPDATE_NOTE_FAILURE = 'npwd:updateNoteFailure', ACTION_RESULT = 'npwd:notesActionResult', + SEND_ALERT = 'npwd:notesSetAlert', } From a6f98d7ac00d378b37e9aeabd8dfe4ed41eef6ec Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 25 Mar 2021 13:07:07 +0100 Subject: [PATCH 7/7] update marketplace enums --- phone/src/apps/sellout/hooks/useSelloutService.ts | 5 +++-- resources/client/cl_sellout.ts | 4 ++-- typings/marketplace.ts | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/phone/src/apps/sellout/hooks/useSelloutService.ts b/phone/src/apps/sellout/hooks/useSelloutService.ts index b5cbc0b..bd25ae8 100644 --- a/phone/src/apps/sellout/hooks/useSelloutService.ts +++ b/phone/src/apps/sellout/hooks/useSelloutService.ts @@ -4,6 +4,7 @@ import { useListing } from './useListing'; import { useSetRecoilState } from 'recoil'; import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar'; import { useTranslation } from 'react-i18next'; +import { MarketplaceEvents } from '../../../../../typings/marketplace'; export const useSelloutService = () => { const setSellout = useSetRecoilState(selloutState.listing); @@ -17,7 +18,7 @@ export const useSelloutService = () => { }); }; - useNuiEvent('SELLOUT', 'setAlert', handleAddAlert); - useNuiEvent('SELLOUT', 'setListings', setSellout); + useNuiEvent('SELLOUT', MarketplaceEvents.SEND_ALERT, handleAddAlert); + useNuiEvent('SELLOUT', MarketplaceEvents.SEND_LISTING, setSellout); return useListing(); }; diff --git a/resources/client/cl_sellout.ts b/resources/client/cl_sellout.ts index 1699827..964485d 100644 --- a/resources/client/cl_sellout.ts +++ b/resources/client/cl_sellout.ts @@ -3,7 +3,7 @@ import { IAlertProps } from '../../typings/alerts'; import { sendMarketplaceEvent } from '../utils/messages'; onNet(MarketplaceEvents.SEND_LISTING, (listings: MarketplaceListing[]) => { - sendMarketplaceEvent('setListings', listings); + sendMarketplaceEvent(MarketplaceEvents.SEND_LISTING, listings); }); RegisterNuiCallbackType(MarketplaceEvents.ADD_LISTING); @@ -33,5 +33,5 @@ onNet(MarketplaceEvents.DELETE_LISTING_SUCCESS, () => { }); onNet(MarketplaceEvents.ACTION_RESULT, (alert: IAlertProps) => { - sendMarketplaceEvent('setAlert', alert); + sendMarketplaceEvent(MarketplaceEvents.SEND_ALERT, alert); }); diff --git a/typings/marketplace.ts b/typings/marketplace.ts index 64c02ec..94099a4 100644 --- a/typings/marketplace.ts +++ b/typings/marketplace.ts @@ -20,4 +20,5 @@ export enum MarketplaceEvents { REPORT_LISTING = 'npwd:reportListing', REPORT_LISTING_SUCCESS = 'npwd:reportListingSuccess', REPORT_LISTING_SUCESS = 'npwd:reportListingFailed', + SEND_ALERT = 'nwpd:sendListingAlert', }