mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
refactor(events): Events are now tied to a common enum typings (#167)
* chore(scripts/twitter): Refactored twitter to use event enums * chore(scripts/marketplace): Refactored marketplace to use event enums * chore(scripts/messages): Refactored messages to use event enums * chore(scripts/contacts): Refactored contacts to use event enums * chore(scripts/calls): Refactored calls to use event enums * chore(scripts/notes): Refactored notes to use event enums * chore(scripts/photos): Refactored photos to use event enums * chore(scripts/bank): Refactored bank to use event enums * chore(scripts/phone): Refactored phone to use event enums * chore(events): Removed old events object * refactor(phone/nui-events): Attached NUI events to respective enum * tweak(event-enums): Added npwd prefix to all events * tweak(phone/serve): Added craco to override CRA without eject Also bumped react-scripts to 4.0.1, with seemingly no issues * fix(typings/twitter): Fixed method enums for twitter
This commit is contained in:
62 files changed
+4734
-3470
No files matched your search
+11
-12
@@ -1,8 +1,7 @@
|
||||
import events from '../utils/events';
|
||||
import { ESX } from './server';
|
||||
import { getSource } from './functions';
|
||||
import { pool } from './db';
|
||||
import { Transfer, IBankCredentials } from '../../typings/bank';
|
||||
import { Transfer, IBankCredentials, BankEvents } from '../../typings/bank';
|
||||
import { getIdentifier } from './functions';
|
||||
import { mainLogger } from './sv_logger';
|
||||
|
||||
@@ -40,9 +39,9 @@ async function addTransfer(identifier: string, transfer: Transfer): Promise<any>
|
||||
const xTarget = ESX.GetPlayerFromId(transfer.targetID);
|
||||
|
||||
if (transfer.transferAmount > bankBalance) {
|
||||
emitNet(events.BANK_TRANSACTION_ALERT, getSource(), false);
|
||||
emitNet(BankEvents.TRANSACTION_ALERT, getSource(), false);
|
||||
} else if (transfer.transferAmount < bankBalance) {
|
||||
emitNet(events.BANK_TRANSACTION_ALERT, getSource(), true);
|
||||
emitNet(BankEvents.TRANSACTION_ALERT, getSource(), true);
|
||||
|
||||
xTarget.addAccountMoney('bank', transfer.transferAmount);
|
||||
xPlayer.removeAccountMoney('bank', transfer.transferAmount);
|
||||
@@ -75,13 +74,13 @@ async function getTransfer(transferId: number): Promise<Transfer> {
|
||||
return { ...transfer };
|
||||
}
|
||||
|
||||
onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
|
||||
onNet(BankEvents.FETCH_TRANSACTIONS, async () => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(_source);
|
||||
const transfer = await fetchAllTransactions(_identifier);
|
||||
|
||||
emitNet(events.BANK_SEND_TRANSFERS, _source, transfer);
|
||||
emitNet(BankEvents.SEND_TRANSFERS, _source, transfer);
|
||||
} catch (e) {
|
||||
bankLogger.error(`Failed to fetch transactions, ${e.message}`, {
|
||||
source: _source,
|
||||
@@ -89,7 +88,7 @@ onNet(events.BANK_FETCH_TRANSACTIONS, async () => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
||||
onNet(BankEvents.ADD_TRANSFER, async (transfer: Transfer) => {
|
||||
const _source = getSource();
|
||||
const xTarget = ESX.GetPlayerFromId(transfer.targetID);
|
||||
try {
|
||||
@@ -101,8 +100,8 @@ onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
||||
|
||||
//emitNet(events.BANK_TRANSACTION_NOTIFICATION, xTarget, transferNotify);
|
||||
|
||||
emitNet(events.BANK_ADD_TRANSFER_SUCCESS, _source);
|
||||
emitNet(events.BANK_TRANSACTION_ALERT, _source, {
|
||||
emitNet(BankEvents.ADD_TRANSFER_SUCCESS, _source);
|
||||
emitNet(BankEvents.TRANSACTION_ALERT, _source, {
|
||||
message: 'BANK_ALERT_TRANSFER_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
@@ -110,18 +109,18 @@ onNet(events.BANK_ADD_TRANSFER, async (transfer: Transfer) => {
|
||||
bankLogger.error(`Failed to add transaction, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
emitNet(events.BANK_TRANSACTION_ALERT, _source, {
|
||||
emitNet(BankEvents.TRANSACTION_ALERT, _source, {
|
||||
message: 'APPS_BANK_ALERT_TRANSFER_FAILURE',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.BANK_GET_CREDENTIALS, () => {
|
||||
onNet(BankEvents.GET_CREDENTIALS, () => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const credentials = fetchCredentials();
|
||||
emitNet(events.BANK_SEND_CREDENTIALS, _source, credentials);
|
||||
emitNet(BankEvents.SEND_CREDENTIALS, _source, credentials);
|
||||
} catch (e) {
|
||||
bankLogger.error(`Failed to fetch credentials, ${e.message}`, {
|
||||
source: _source,
|
||||
|
||||
Reference in new issue
Block a user