cleaning up tuning and untuning keeping it simple

This commit is contained in:
talksik
2022-05-14 11:08:37 -05:00
parent 7c66a6a4f3
commit 723427b7cc
3 changed files with 32 additions and 14 deletions
@@ -25,11 +25,29 @@ import { useAsyncFn } from 'react-use';
import { updateLineMemberState } from '../api/NirvanaApi';
import UpdateLineMemberState from '@nirvana/core/requests/updateLineMemberState.request';
import useAuth from './AuthProvider';
import { User } from '@nirvana/core/models/user.model';
type LineIdToMasterLine = {
[lineId: string]: MasterLineData;
};
// TODO: implement the below to save renders
type TunedMembersMap = {
[lineId: string]: string[];
};
type ConnectedMembesMap = {
[lineId: string]: string[];
};
type UserMap = {
[userId: string]: User;
};
type BroadcastersMap = {
[lineId: string]: string[];
};
interface IRealTimeRoomProvider {
roomsMap: LineIdToMasterLine;
@@ -103,11 +121,7 @@ export function RealTimeRoomProvider({ children }: { children: React.ReactChild
return;
}
if (draft[res.lineId].connectedMemberIds) {
draft[res.lineId].connectedMemberIds.push(res.userId);
} else {
draft[res.lineId].connectedMemberIds = [res.userId];
}
draft[res.lineId].connectedMemberIds = res.allUsers;
});
});
@@ -121,11 +135,7 @@ export function RealTimeRoomProvider({ children }: { children: React.ReactChild
return;
}
if (draft[res.lineId].tunedInMemberIds) {
draft[res.lineId].tunedInMemberIds.push(res.userId);
} else {
draft[res.lineId].tunedInMemberIds = [res.userId];
}
draft[res.lineId].tunedInMemberIds = res.allUsers;
});
});