fix dumb event

This commit is contained in:
dank074 2021-08-18 22:12:40 -05:00
parent 1bdcfd5cdf
commit a7e31afefc
4 changed files with 21 additions and 38 deletions

View File

@ -20,7 +20,6 @@ export default class RoomSettingsData
public allowPetsEat: boolean;
public usersWithRights: Map<number, string>;
public friends: Map<number, string>;
public hideWalls: boolean;
public wallThickness: number;
@ -59,7 +58,6 @@ export default class RoomSettingsData
this.allowPetsEat = parser.allowPetsEat;
this.usersWithRights = new Map<number, string>();
this.friends = new Map<number, string>();
this.hideWalls = parser.hideWalls;
this.wallThickness = parser.thicknessWall;
@ -74,26 +72,5 @@ export default class RoomSettingsData
this.kickState = parser.moderationSettings.allowKick;
this.banState = parser.moderationSettings.allowBan;
this.bannedUsers = new Map<number, string>();
this.selectedUserToUnban = 0;
}
public selectUserToUnban(userId: number): void
{
if(this.selectedUserToUnban === userId)
{
this.selectedUserToUnban = 0;
}
else
{
this.selectedUserToUnban = userId;
}
}
public get selectedUsernameToUnban(): string
{
if(this.selectedUserToUnban > 0)
return this.bannedUsers.get(this.selectedUserToUnban);
return null;
}
}

View File

@ -1,5 +1,5 @@
import { RoomBannedUsersComposer, RoomBannedUsersEvent, RoomSettingsEvent, RoomUsersWithRightsComposer, RoomUsersWithRightsEvent, SaveRoomSettingsComposer } from '@nitrots/nitro-renderer';
import { FC, useCallback, useState } from 'react';
import { FC, useCallback, useEffect, useState } from 'react';
import { LocalizeText } from '../../../../api';
import { FriendListEvent } from '../../../../events';
import { FriendListContentEvent } from '../../../../events/friend-list/FriendListContentEvent';
@ -25,6 +25,7 @@ export const NavigatorRoomSettingsView: FC<{}> = props =>
{
const [ roomSettingsData, setRoomSettingsData ] = useState<RoomSettingsData>(null);
const [ currentTab, setCurrentTab ] = useState(TABS[0]);
const [ friends, setFriends ] = useState<Map<number, string>>(new Map());
const updateSettings = useCallback((roomSettings: RoomSettingsData) =>
{
@ -55,8 +56,6 @@ export const NavigatorRoomSettingsView: FC<{}> = props =>
data.usersWithRights = new Map(parser.users);
setRoomSettingsData(data);
dispatchUiEvent(new FriendListEvent(FriendListEvent.REQUEST_FRIEND_LIST));
}, [roomSettingsData]);
const onRoomBannedUsersEvent = useCallback((event: RoomBannedUsersEvent) =>
@ -76,13 +75,9 @@ export const NavigatorRoomSettingsView: FC<{}> = props =>
const onFriendsListContentEvent = useCallback((event: FriendListContentEvent) =>
{
if(!roomSettingsData) return;
if(!roomSettingsData || !event.friends) return;
const clone = Object.assign({}, roomSettingsData);
clone.friends = event.friends;
setRoomSettingsData(clone);
setFriends(event.friends);
}, [roomSettingsData]);
CreateMessageHook(RoomSettingsEvent, onRoomSettingsEvent);
@ -90,6 +85,11 @@ export const NavigatorRoomSettingsView: FC<{}> = props =>
CreateMessageHook(RoomBannedUsersEvent, onRoomBannedUsersEvent);
useUiEvent(FriendListContentEvent.FRIEND_LIST_CONTENT, onFriendsListContentEvent);
useEffect(() =>
{
if(roomSettingsData) dispatchUiEvent(new FriendListEvent(FriendListEvent.REQUEST_FRIEND_LIST));
}, [roomSettingsData])
const save = useCallback((data: RoomSettingsData) =>
{
SendMessageHook(
@ -146,7 +146,7 @@ export const NavigatorRoomSettingsView: FC<{}> = props =>
<NitroCardContentView className="text-black px-4">
{ currentTab === TABS[0] && <NavigatorRoomSettingsBasicTabView roomSettingsData={ roomSettingsData } setRoomSettingsData={ updateSettings } onSave={ save } /> }
{ currentTab === TABS[1] && <NavigatorRoomSettingsAccessTabView roomSettingsData={ roomSettingsData } setRoomSettingsData={ updateSettings } onSave={ save } /> }
{ currentTab === TABS[2] && <NavigatorRoomSettingsRightsTabView roomSettingsData= {roomSettingsData } setRoomSettingsData={ updateSettings } onSave={ save } /> }
{ currentTab === TABS[2] && <NavigatorRoomSettingsRightsTabView roomSettingsData= {roomSettingsData } setRoomSettingsData={ updateSettings } onSave={ save } friends={friends} /> }
{ currentTab === TABS[3] && <NavigatorRoomSettingsVipChatTabView roomSettingsData={ roomSettingsData } setRoomSettingsData={ updateSettings } onSave={ save } /> }
{ currentTab === TABS[4] && <NavigatorRoomSettingsModTabView roomSettingsData={ roomSettingsData } setRoomSettingsData={ updateSettings } onSave={ save } /> }
</NitroCardContentView>

View File

@ -3,11 +3,11 @@ import { FC, useCallback, useMemo } from 'react';
import { LocalizeText } from '../../../../../../api';
import { SendMessageHook } from '../../../../../../hooks';
import { UserProfileIconView } from '../../../../../shared/user-profile-icon/UserProfileIconView';
import { NavigatorRoomSettingsTabViewProps } from '../../NavigatorRoomSettingsView.types';
import { NavigatorRoomSettingsRightsTabViewProps } from './NavigatorRoomSettingsRightsTabView.types';
export const NavigatorRoomSettingsRightsTabView: FC<NavigatorRoomSettingsTabViewProps> = props =>
export const NavigatorRoomSettingsRightsTabView: FC<NavigatorRoomSettingsRightsTabViewProps> = props =>
{
const { roomSettingsData = null, setRoomSettingsData = null, onSave = null } = props;
const { roomSettingsData = null, setRoomSettingsData = null, onSave = null, friends = null } = props;
const removeUserRights = useCallback( (userId: number) =>
{
@ -43,14 +43,14 @@ export const NavigatorRoomSettingsRightsTabView: FC<NavigatorRoomSettingsTabView
{
const map = new Map<number, string>();
roomSettingsData.friends.forEach((name, id) =>
friends.forEach((name, id) =>
{
if(!roomSettingsData.usersWithRights.has(id))
map.set(id, name);
});
return map;
}, [roomSettingsData]);
}, [friends, roomSettingsData]);
return (
<div className="d-flex flex-column h-100 overflow-hidden user-rights">

View File

@ -0,0 +1,6 @@
import { NavigatorRoomSettingsTabViewProps } from '../../NavigatorRoomSettingsView.types';
export interface NavigatorRoomSettingsRightsTabViewProps extends NavigatorRoomSettingsTabViewProps
{
friends: Map<number, string>;
}