fix(navigator): restore useNotification() inside useNavigatorStore

Commit 8ab0021a introduced an unjustified deviation: it removed the
useNotification() call from inside useNavigatorStore and replaced it
with a module-level _simpleAlert ref + _injectSimpleAlert() exported
function, on the theory that nested useBetween calls corrupt
use-between's state.

That diagnosis is wrong. Production proof:
- useCatalog.ts:56 calls useNotification() inside useCatalogStore
- useWiredToolsStore.ts:131 calls useNotification() inside its store
- The original useNavigator.ts:32 calls useNotification() inside its
  state closure
All three have been in production for ages without issue. Nested
useBetween calls work fine.

The smoke-test failure that prompted the workaround was a mock issue,
not a real bug. Reverting to the standard pattern — useNotification()
direct inside the useBetween store closure. Production alerts work
again immediately without requiring an explicit injection call from
consumers.

Mock additions (src/nitro-renderer.mock.ts):
- Added 23 notification MessageEvent subclasses (AchievementNotification-
  MessageEvent, ActivityPoint..., BadgeReceived, ClubGiftNotification,
  ClubGiftSelected, ConnectionError, HabboBroadcast, HotelClosedAndOpens,
  HotelClosesAndWillOpenAt, HotelWillCloseInMinutes, InfoFeedEnable,
  MaintenanceStatus, ModeratorCaution, ModeratorMessage, MOTD,
  NotificationDialog, PetLevel, PetReceived, RespectReceived, RoomEnter,
  SimpleAlert, UserBanned, WiredRewardResult) so useNotificationStore
  can register its listeners without throwing.
- Added RoomEnterEffect stub (isRunning: false, totalRunningTime: 0).
- Added WiredRewardResultMessageEvent static constants.
This commit is contained in:
simoleo89
2026-05-27 18:50:40 +02:00
parent 8ab0021af6
commit 3c10ccdaee
2 changed files with 44 additions and 8 deletions
+2 -8
View File
@@ -17,15 +17,9 @@ import { CreateRoomSession, GetConfigurationValue, INavigatorData,
LocalizeText, NotificationAlertType, SendMessageComposer,
TryVisitRoom, VisitDesktop } from '../../api';
import { useMessageEvent, useNitroEvent } from '../events';
import { useNotification } from '../notification';
import { useNavigatorUiStore } from './navigatorUiStore';
// Module-level reference to simpleAlert, injected by useNavigatorActions
// (which runs in a real React dispatcher context, outside useBetween).
// Avoids nested useBetween calls that corrupt use-between's module-level state.
type SimpleAlertFn = (message: string, type?: string, clickUrl?: string, clickUrlText?: string, title?: string, imageUrl?: string) => void;
let _simpleAlert: SimpleAlertFn | null = null;
export const _injectSimpleAlert = (fn: SimpleAlertFn | null) => { _simpleAlert = fn; };
export const useNavigatorStore = () =>
{
const [ categories, setCategories ] = useState<NavigatorCategoryDataParser[]>(null);
@@ -58,7 +52,7 @@ export const useNavigatorStore = () =>
const searchResultRef = useRef(searchResult);
searchResultRef.current = searchResult;
const simpleAlert = _simpleAlert;
const { simpleAlert = null } = useNotification();
const sendSearch = useCallback((searchValue: string, contextCode: string) =>
{