mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
refactor(phone/marketplace): Refactor state management and fetching
This commit is contained in:
1 parent
2d1e192892
commit
4afa9c691b
12 files changed
+211
-87
No files matched your search
@@ -1,37 +1,47 @@
|
||||
import { MarketplaceEvents, MarketplaceListing } from '../../typings/marketplace';
|
||||
import { IAlertProps } from '../../typings/alerts';
|
||||
import { MarketplaceEvents, MarketplaceListingBroadcast } from '../../typings/marketplace';
|
||||
import { RegisterNuiProxy } from './cl_utils';
|
||||
import { sendMarketplaceEvent } from '../utils/messages';
|
||||
|
||||
onNet(MarketplaceEvents.SEND_LISTING, (listings: MarketplaceListing[]) => {
|
||||
sendMarketplaceEvent(MarketplaceEvents.SEND_LISTING, listings);
|
||||
// onNet(MarketplaceEvents.SEND_LISTING, (listings: MarketplaceListing[]) => {
|
||||
// sendMarketplaceEvent(MarketplaceEvents.SEND_LISTING, listings);
|
||||
// });
|
||||
|
||||
RegisterNuiProxy(MarketplaceEvents.FETCH_LISTING);
|
||||
RegisterNuiProxy(MarketplaceEvents.ADD_LISTING);
|
||||
|
||||
// RegisterNuiCallbackType(MarketplaceEvents.ADD_LISTING);
|
||||
// on(`__cfx_nui:${MarketplaceEvents.ADD_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||
// emitNet(MarketplaceEvents.ADD_LISTING, data);
|
||||
// cb();
|
||||
// });
|
||||
|
||||
RegisterNuiProxy(MarketplaceEvents.DELETE_LISTING);
|
||||
RegisterNuiProxy(MarketplaceEvents.REPORT_LISTING);
|
||||
|
||||
onNet(MarketplaceEvents.BROADCAST_EVENT, (broadcastEvent: MarketplaceListingBroadcast) => {
|
||||
sendMarketplaceEvent(MarketplaceEvents.BROADCAST_EVENT, broadcastEvent);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(MarketplaceEvents.ADD_LISTING);
|
||||
on(`__cfx_nui:${MarketplaceEvents.ADD_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||
emitNet(MarketplaceEvents.ADD_LISTING, data);
|
||||
cb();
|
||||
});
|
||||
// RegisterNuiCallbackType(MarketplaceEvents.DELETE_LISTING);
|
||||
// on(`__cfx_nui:${MarketplaceEvents.DELETE_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||
// emitNet(MarketplaceEvents.DELETE_LISTING, data.id);
|
||||
// cb();
|
||||
// });
|
||||
|
||||
RegisterNuiCallbackType(MarketplaceEvents.DELETE_LISTING);
|
||||
on(`__cfx_nui:${MarketplaceEvents.DELETE_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||
emitNet(MarketplaceEvents.DELETE_LISTING, data.id);
|
||||
cb();
|
||||
});
|
||||
// RegisterNuiCallbackType(MarketplaceEvents.REPORT_LISTING);
|
||||
// on(`__cfx_nui:${MarketplaceEvents.REPORT_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||
// emitNet(MarketplaceEvents.REPORT_LISTING, data);
|
||||
// cb();
|
||||
// });
|
||||
|
||||
RegisterNuiCallbackType(MarketplaceEvents.REPORT_LISTING);
|
||||
on(`__cfx_nui:${MarketplaceEvents.REPORT_LISTING}`, (data: MarketplaceListing, cb: Function) => {
|
||||
emitNet(MarketplaceEvents.REPORT_LISTING, data);
|
||||
cb();
|
||||
});
|
||||
// onNet(MarketplaceEvents.ADD_LISTING_SUCCESS, () => {
|
||||
// emitNet(MarketplaceEvents.FETCH_LISTING);
|
||||
// });
|
||||
|
||||
onNet(MarketplaceEvents.ADD_LISTING_SUCCESS, () => {
|
||||
emitNet(MarketplaceEvents.FETCH_LISTING);
|
||||
});
|
||||
// onNet(MarketplaceEvents.DELETE_LISTING_SUCCESS, () => {
|
||||
// emitNet(MarketplaceEvents.FETCH_LISTING);
|
||||
// });
|
||||
|
||||
onNet(MarketplaceEvents.DELETE_LISTING_SUCCESS, () => {
|
||||
emitNet(MarketplaceEvents.FETCH_LISTING);
|
||||
});
|
||||
|
||||
onNet(MarketplaceEvents.ACTION_RESULT, (alert: IAlertProps) => {
|
||||
sendMarketplaceEvent(MarketplaceEvents.SEND_ALERT, alert);
|
||||
});
|
||||
// onNet(MarketplaceEvents.ACTION_RESULT, (alert: IAlertProps) => {
|
||||
// sendMarketplaceEvent(MarketplaceEvents.SEND_ALERT, alert);
|
||||
// });
|
||||
Reference in new issue
Block a user