Skip to content

Commit 010d232

Browse files
authored
feat(web): initial update to vite (#157)
1 parent cf4b460 commit 010d232

14 files changed

+862
-566
lines changed

src/client/cl_events.ts

+17-13
Original file line numberDiff line numberDiff line change
@@ -44,55 +44,59 @@ const waitForNUILoaded = (checkInterval = 250): Promise<void> => {
4444
});
4545
};
4646

47-
const SendBankUIMessage = (data: object) => {
48-
SendNUIMessage(data);
47+
const SendBankUIMessage = (app: string, method: string, data: unknown) => {
48+
SendNUIMessage({
49+
app,
50+
method,
51+
data,
52+
});
4953

5054
if (GetResourceState('npwd') === 'started') {
51-
npwdExports.sendUIMessage(data);
55+
npwdExports.sendNPWDMessage(app, method, data);
5256
}
5357
};
5458

5559
onNet(Broadcasts.NewAccount, (payload: Account) => {
56-
SendBankUIMessage({ type: Broadcasts.NewAccount, payload });
60+
SendBankUIMessage('PEFCL', Broadcasts.NewAccount, payload);
5761
});
5862

5963
onNet(Broadcasts.NewAccountBalance, (balance: number) => {
60-
SendBankUIMessage({ type: Broadcasts.NewAccountBalance, payload: balance });
64+
SendBankUIMessage('PEFCL', Broadcasts.NewAccountBalance, balance);
6165
});
6266

6367
onNet(Broadcasts.NewTransaction, (payload: Transaction) => {
64-
SendBankUIMessage({ type: Broadcasts.NewTransaction, payload });
68+
SendBankUIMessage('PEFCL', Broadcasts.NewTransaction, payload);
6569
});
6670

6771
onNet(Broadcasts.UpdatedAccount, (payload: Account) => {
68-
SendBankUIMessage({ type: Broadcasts.UpdatedAccount, payload });
72+
SendBankUIMessage('PEFCL', Broadcasts.UpdatedAccount, payload);
6973
});
7074

7175
onNet(Broadcasts.NewInvoice, (payload: Invoice) => {
72-
SendBankUIMessage({ type: Broadcasts.NewInvoice, payload });
76+
SendBankUIMessage('PEFCL', Broadcasts.NewInvoice, payload);
7377
});
7478

7579
onNet(Broadcasts.NewSharedUser, () => {
76-
SendBankUIMessage({ type: Broadcasts.NewSharedUser });
80+
SendBankUIMessage('PEFCL', Broadcasts.NewSharedUser, {});
7781
});
7882

7983
onNet(Broadcasts.RemovedSharedUser, () => {
80-
SendBankUIMessage({ type: Broadcasts.RemovedSharedUser });
84+
SendBankUIMessage('PEFCL', Broadcasts.RemovedSharedUser, {});
8185
});
8286

8387
onNet(UserEvents.Loaded, async () => {
8488
console.debug('Waiting for NUI to load ..');
8589
await waitForNUILoaded();
8690
console.debug('Loaded. Emitting data to NUI.');
87-
SendBankUIMessage({ type: UserEvents.Loaded, payload: true });
91+
SendBankUIMessage('PEFCL', UserEvents.Loaded, true);
8892

8993
if (!useFrameworkIntegration) {
9094
StatSetInt(CASH_BAL_STAT, (await API.getMyCash()) ?? 0, true);
9195
}
9296
});
9397

9498
onNet(UserEvents.Unloaded, () => {
95-
SendBankUIMessage({ type: UserEvents.Unloaded });
99+
SendBankUIMessage('PEFCL', UserEvents.Unloaded, {});
96100
});
97101

98102
const CASH_BAL_STAT = GetHashKey('MP0_WALLET_BALANCE');
@@ -130,7 +134,7 @@ RegisterCommand(
130134
console.debug('Waiting for NUI to load ..');
131135
await waitForNUILoaded();
132136
console.debug('Loaded. Emitting data to NUI.');
133-
SendBankUIMessage({ type: UserEvents.Loaded, payload: true });
137+
SendBankUIMessage('PEFCL', UserEvents.Loaded, true);
134138
},
135139
false,
136140
);

src/client/client.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ export const setBankIsOpen = (bool: boolean) => {
1818
}
1919

2020
isBankOpen = bool;
21-
SendNUIMessage({ type: 'setVisible', payload: bool });
21+
SendNUIMessage({ app: 'PEFCL', method: 'setVisible', data: bool });
22+
23+
console.log('setBankIsOpen', bool);
24+
2225
SetNuiFocus(bool, bool);
2326
};
2427

@@ -28,7 +31,7 @@ export const setAtmIsOpen = (bool: boolean) => {
2831
}
2932

3033
isAtmOpen = bool;
31-
SendNUIMessage({ type: 'setVisibleATM', payload: bool });
34+
SendNUIMessage({ app: 'PEFCL', method: 'setVisibleATM', data: bool });
3235
SetNuiFocus(bool, bool);
3336
};
3437

@@ -63,7 +66,7 @@ if (!useFrameworkIntegration) {
6366
if (!config.atms?.props?.includes(model)) return console.log('not atm');
6467

6568
isAtmOpen = !isAtmOpen;
66-
SendNUIMessage({ type: 'setVisibleATM', payload: isAtmOpen });
69+
SendNUIMessage({ app: 'PEFCL', method: 'setVisibleATM', data: isAtmOpen });
6770

6871
if (isAtmOpen) {
6972
SetNuiFocus(true, true);

src/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"prettier": "^2.5.1",
6060
"reflect-metadata": "^0.1.13",
6161
"sequelize": "^6.17.0",
62-
"tedious": "^14.3.0",
6362
"tsyringe": "^4.6.0",
6463
"winston": "^3.4.0"
6564
}

0 commit comments

Comments
 (0)