From caf6fe4b18390ff9f4af302f370b9293d0839a45 Mon Sep 17 00:00:00 2001 From: dank074 Date: Thu, 25 Nov 2021 23:16:00 -0600 Subject: [PATCH] add constants --- src/api/utils/PlaySound.ts | 7 +++++++ src/layout/mini-camera/NitroLayoutMiniCameraView.tsx | 4 ++-- src/views/camera/views/capture/CameraWidgetCaptureView.tsx | 4 ++-- src/views/catalog/CatalogView.tsx | 4 ++-- src/views/friends/views/messenger/FriendsMessengerView.tsx | 6 +++--- src/views/mod-tools/ModToolsMessageHandler.tsx | 4 ++-- src/views/purse/PurseMessageHandler.tsx | 6 +++--- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/api/utils/PlaySound.ts b/src/api/utils/PlaySound.ts index 6dddb915..96bc8fc5 100644 --- a/src/api/utils/PlaySound.ts +++ b/src/api/utils/PlaySound.ts @@ -5,3 +5,10 @@ export function PlaySound(sampleCode: string): void { dispatchMainEvent(new NitroSoundEvent(NitroSoundEvent.PLAY_SOUND, sampleCode)); } + +export const CAMERA_SHUTTER = 'camera_shutter'; +export const CREDITS = 'credits'; +export const DUCKETS = 'duckets'; +export const MESSENGER_NEW_THREAD = 'messenger_new_thread'; +export const MESSENGER_MESSAGE_RECEIVED = 'messenger_message_received'; +export const MODTOOLS_NEW_TICKET = 'modtools_new_ticket'; diff --git a/src/layout/mini-camera/NitroLayoutMiniCameraView.tsx b/src/layout/mini-camera/NitroLayoutMiniCameraView.tsx index 7bca0e0f..261eebb3 100644 --- a/src/layout/mini-camera/NitroLayoutMiniCameraView.tsx +++ b/src/layout/mini-camera/NitroLayoutMiniCameraView.tsx @@ -1,7 +1,7 @@ import { NitroRectangle } from '@nitrots/nitro-renderer'; import { FC, useCallback, useRef } from 'react'; import { GetRoomEngine, LocalizeText } from '../../api'; -import { PlaySound } from '../../api/utils/PlaySound'; +import { CAMERA_SHUTTER, PlaySound } from '../../api/utils/PlaySound'; import { DraggableWindow } from '../draggable-window'; import { NitroLayoutMiniCameraViewProps } from './NitroLayoutMiniCameraView.types'; @@ -21,7 +21,7 @@ export const NitroLayoutMiniCameraView: FC = pro const takePicture = useCallback(() => { - PlaySound('camera_shutter'); + PlaySound(CAMERA_SHUTTER); textureReceiver(GetRoomEngine().createTextureFromRoom(roomId, 1, getCameraBounds())); }, [ roomId, getCameraBounds, textureReceiver ]); diff --git a/src/views/camera/views/capture/CameraWidgetCaptureView.tsx b/src/views/camera/views/capture/CameraWidgetCaptureView.tsx index c24e936d..1c369a78 100644 --- a/src/views/camera/views/capture/CameraWidgetCaptureView.tsx +++ b/src/views/camera/views/capture/CameraWidgetCaptureView.tsx @@ -1,7 +1,7 @@ import { NitroRectangle, TextureUtils } from '@nitrots/nitro-renderer'; import { FC, useCallback, useRef } from 'react'; import { GetRoomEngine, GetRoomSession, LocalizeText } from '../../../../api'; -import { PlaySound } from '../../../../api/utils/PlaySound'; +import { CAMERA_SHUTTER, PlaySound } from '../../../../api/utils/PlaySound'; import { DraggableWindow } from '../../../../layout'; import { CameraPicture } from '../../common/CameraPicture'; import { useCameraWidgetContext } from '../../context/CameraWidgetContext'; @@ -45,7 +45,7 @@ export const CameraWidgetCaptureView: FC = props = clone.pop(); } - PlaySound('camera_shutter'); + PlaySound(CAMERA_SHUTTER); clone.push(new CameraPicture(texture, TextureUtils.generateImageUrl(texture))); setCameraRoll(clone); diff --git a/src/views/catalog/CatalogView.tsx b/src/views/catalog/CatalogView.tsx index d1d9142d..d45ed9e3 100644 --- a/src/views/catalog/CatalogView.tsx +++ b/src/views/catalog/CatalogView.tsx @@ -1,7 +1,7 @@ import { GetCatalogIndexComposer, GetCatalogPageComposer, GetGiftWrappingConfigurationComposer, ILinkEventTracker, INodeData, RoomPreviewer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useReducer, useState } from 'react'; import { AddEventLinkTracker, GetRoomEngine, LocalizeText, RemoveLinkEventTracker } from '../../api'; -import { PlaySound } from '../../api/utils/PlaySound'; +import { CREDITS, PlaySound } from '../../api/utils/PlaySound'; import { CatalogEvent } from '../../events'; import { useUiEvent } from '../../hooks/events/ui/ui-event'; import { SendMessageHook } from '../../hooks/messages/message-event'; @@ -49,7 +49,7 @@ export const CatalogView: FC = props => setIsVisible(value => !value); return; case CatalogEvent.PURCHASE_SUCCESS: - PlaySound('credits'); + PlaySound(CREDITS); return; } diff --git a/src/views/friends/views/messenger/FriendsMessengerView.tsx b/src/views/friends/views/messenger/FriendsMessengerView.tsx index 5709f56a..0d5ad76c 100644 --- a/src/views/friends/views/messenger/FriendsMessengerView.tsx +++ b/src/views/friends/views/messenger/FriendsMessengerView.tsx @@ -1,7 +1,7 @@ import { FollowFriendMessageComposer, ILinkEventTracker, NewConsoleMessageEvent, SendMessageComposer } from '@nitrots/nitro-renderer'; import { FC, KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { AddEventLinkTracker, GetUserProfile, LocalizeText, RemoveLinkEventTracker } from '../../../../api'; -import { PlaySound } from '../../../../api/utils/PlaySound'; +import { MESSENGER_MESSAGE_RECEIVED, MESSENGER_NEW_THREAD, PlaySound } from '../../../../api/utils/PlaySound'; import { FriendsMessengerIconEvent } from '../../../../events'; import { BatchUpdates, CreateMessageHook, dispatchUiEvent, SendMessageHook } from '../../../../hooks'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView, NitroLayoutButton, NitroLayoutButtonGroup, NitroLayoutFlex, NitroLayoutFlexColumn } from '../../../../layout'; @@ -115,7 +115,7 @@ export const FriendsMessengerView: FC<{}> = props => SendMessageHook(new SendMessageComposer(thread.participant.id, messageText)); - if(messageThreads.length === 1 && thread.groups.length === 1) PlaySound('messenger_new_thread'); + if(messageThreads.length === 1 && thread.groups.length === 1) PlaySound(MESSENGER_NEW_THREAD); thread.addMessage(0, messageText, 0, null, MessengerThreadChat.CHAT); @@ -230,7 +230,7 @@ export const FriendsMessengerView: FC<{}> = props => } } - if(isUnread) PlaySound('messenger_message_received'); + if(isUnread) PlaySound(MESSENGER_MESSAGE_RECEIVED); dispatchUiEvent(new FriendsMessengerIconEvent(FriendsMessengerIconEvent.UPDATE_ICON, isUnread ? FriendsMessengerIconEvent.UNREAD_ICON : FriendsMessengerIconEvent.SHOW_ICON)); }, [ visibleThreads, updateValue ]); diff --git a/src/views/mod-tools/ModToolsMessageHandler.tsx b/src/views/mod-tools/ModToolsMessageHandler.tsx index acf55120..3357aef8 100644 --- a/src/views/mod-tools/ModToolsMessageHandler.tsx +++ b/src/views/mod-tools/ModToolsMessageHandler.tsx @@ -1,6 +1,6 @@ import { CfhSanctionMessageEvent, CfhTopicsInitEvent, IssueDeletedMessageEvent, IssueInfoMessageEvent, IssuePickFailedMessageEvent, ModeratorActionResultMessageEvent, ModeratorInitMessageEvent, ModeratorToolPreferencesEvent, RoomEngineEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { PlaySound } from '../../api/utils/PlaySound'; +import { MODTOOLS_NEW_TICKET, PlaySound } from '../../api/utils/PlaySound'; import { NotificationAlertEvent } from '../../events'; import { ModToolsEvent } from '../../events/mod-tools/ModToolsEvent'; import { ModToolsOpenRoomChatlogEvent } from '../../events/mod-tools/ModToolsOpenRoomChatlogEvent'; @@ -58,7 +58,7 @@ export const ModToolsMessageHandler: FC<{}> = props => else { newTickets.push(parser.issueData); - PlaySound('modtools_new_ticket'); + PlaySound(MODTOOLS_NEW_TICKET); } dispatchModToolsState({ diff --git a/src/views/purse/PurseMessageHandler.tsx b/src/views/purse/PurseMessageHandler.tsx index 56941ae3..07ca8f09 100644 --- a/src/views/purse/PurseMessageHandler.tsx +++ b/src/views/purse/PurseMessageHandler.tsx @@ -1,6 +1,6 @@ import { ActivityPointNotificationMessageEvent, UserCreditsEvent, UserCurrencyEvent, UserSubscriptionEvent, UserSubscriptionParser } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { PlaySound } from '../../api/utils/PlaySound'; +import { CREDITS, DUCKETS, PlaySound } from '../../api/utils/PlaySound'; import { CreateMessageHook } from '../../hooks/messages/message-event'; import { usePurseContext } from './context/PurseContext'; import { PurseMessageHandlerProps } from './PurseMessageHandler.types'; @@ -13,7 +13,7 @@ export const PurseMessageHandler: FC = props => { const parser = event.getParser(); - if(purse.credits && purse.credits !== parseFloat(parser.credits)) PlaySound('credits'); + if(purse.credits && purse.credits !== parseFloat(parser.credits)) PlaySound(CREDITS); purse.credits = parseFloat(parser.credits); @@ -35,7 +35,7 @@ export const PurseMessageHandler: FC = props => purse.activityPoints.set(parser.type, parser.amount); - if(parser.type === 0) PlaySound('duckets'); + if(parser.type === 0) PlaySound(DUCKETS); purse.notify(); }, [ purse ]);