Add more notifications

This commit is contained in:
Bill 2021-08-27 23:31:22 -04:00
parent 0355d7113d
commit aa9f87fbb5
2 changed files with 40 additions and 4 deletions

View File

@ -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;

View File

@ -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;
}
}
}