mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-01-31 10:22:36 +01:00
Add more notifications
This commit is contained in:
parent
0355d7113d
commit
aa9f87fbb5
@ -1,4 +1,4 @@
|
||||
import { AchievementNotificationMessageEvent, ActivityPointNotificationMessageEvent, ClubGiftNotificationEvent, HabboBroadcastMessageEvent, HotelClosesAndWillOpenAtEvent, HotelWillShutdownEvent, ModeratorMessageEvent, MOTDNotificationEvent, NotificationDialogMessageEvent, PetAddedToInventoryEvent, RespectReceivedEvent, Vector3d } from '@nitrots/nitro-renderer';
|
||||
import { AchievementNotificationMessageEvent, ActivityPointNotificationMessageEvent, ClubGiftNotificationEvent, HabboBroadcastMessageEvent, HotelClosesAndWillOpenAtEvent, HotelWillShutdownEvent, ModeratorMessageEvent, MOTDNotificationEvent, NotificationDialogMessageEvent, PetAddedToInventoryEvent, RespectReceivedEvent, RoomEnterEvent, Vector3d } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback } from 'react';
|
||||
import { GetRoomEngine, GetSessionDataManager, LocalizeBadgeName, LocalizeText } from '../../api';
|
||||
import { NotificationCenterAlertEvent } from '../../events';
|
||||
@ -106,6 +106,15 @@ export const NotificationCenterMessageHandler: FC<INotificationCenterMessageHand
|
||||
|
||||
CreateMessageHook(PetAddedToInventoryEvent, onPetAddedToInventoryEvent);
|
||||
|
||||
const onRoomEnterEvent = useCallback((event: RoomEnterEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
NotificationUtilities.showModerationDisclaimer();
|
||||
}, []);
|
||||
|
||||
CreateMessageHook(RoomEnterEvent, onRoomEnterEvent);
|
||||
|
||||
const onMOTDNotificationEvent = useCallback((event: MOTDNotificationEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
@ -113,6 +122,8 @@ export const NotificationCenterMessageHandler: FC<INotificationCenterMessageHand
|
||||
dispatchUiEvent(new NotificationCenterAlertEvent(NotificationCenterAlertEvent.HOTEL_ALERT, parser.messages));
|
||||
}, []);
|
||||
|
||||
CreateMessageHook(MOTDNotificationEvent, onMOTDNotificationEvent);
|
||||
|
||||
const onHotelWillShutdownEvent = useCallback((event: HotelWillShutdownEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
@ -125,6 +136,8 @@ export const NotificationCenterMessageHandler: FC<INotificationCenterMessageHand
|
||||
});
|
||||
}, [ dispatchNotificationCenterState ]);
|
||||
|
||||
CreateMessageHook(HotelWillShutdownEvent, onHotelWillShutdownEvent);
|
||||
|
||||
const onNotificationDialogMessageEvent = useCallback((event: NotificationDialogMessageEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
@ -132,8 +145,6 @@ export const NotificationCenterMessageHandler: FC<INotificationCenterMessageHand
|
||||
NotificationUtilities.showNotification(parser.type, parser.parameters);
|
||||
}, []);
|
||||
|
||||
CreateMessageHook(MOTDNotificationEvent, onMOTDNotificationEvent);
|
||||
CreateMessageHook(HotelWillShutdownEvent, onHotelWillShutdownEvent);
|
||||
CreateMessageHook(NotificationDialogMessageEvent, onNotificationDialogMessageEvent);
|
||||
|
||||
return null;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { HabboWebTools } from '@nitrots/nitro-renderer';
|
||||
import { HabboWebTools, RoomEnterEffect } from '@nitrots/nitro-renderer';
|
||||
import { CreateLinkEvent, GetConfiguration, GetNitroInstance, LocalizeText } from '../../../api';
|
||||
import { SimpleAlertUIEvent } from '../../../events';
|
||||
import { NotificationBubbleEvent } from '../../../events/notification-center/NotificationBubbleEvent';
|
||||
@ -8,6 +8,10 @@ import { NotificationType } from './NotificationType';
|
||||
|
||||
export class NotificationUtilities
|
||||
{
|
||||
private static MODERATION_DISCLAIMER_SHOWN: boolean = false;
|
||||
private static MODERATION_DISCLAIMER_DELAY_MS: number = 5000;
|
||||
private static MODERATION_DISCLAIMER_TIMEOUT: ReturnType<typeof setTimeout> = null;
|
||||
|
||||
private static cleanText(text: string): string
|
||||
{
|
||||
return text.replace(/\\r/g, '\r')
|
||||
@ -133,4 +137,25 @@ export class NotificationUtilities
|
||||
CreateLinkEvent(url);
|
||||
}
|
||||
}
|
||||
|
||||
public static showModerationDisclaimer(): void
|
||||
{
|
||||
if(RoomEnterEffect.isRunning())
|
||||
{
|
||||
if(this.MODERATION_DISCLAIMER_TIMEOUT) return;
|
||||
|
||||
this.MODERATION_DISCLAIMER_TIMEOUT = setTimeout(() =>
|
||||
{
|
||||
this.showModerationDisclaimer();
|
||||
}, (RoomEnterEffect.totalRunningTime + this.MODERATION_DISCLAIMER_DELAY_MS));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.MODERATION_DISCLAIMER_SHOWN) return;
|
||||
|
||||
this.showSingleBubble(LocalizeText('mod.chatdisclaimer'), NotificationType.INFO);
|
||||
|
||||
this.MODERATION_DISCLAIMER_SHOWN = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user