Skip to content

Commit

Permalink
Task: tidy customEvents object expression
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdools-whereby committed Jan 3, 2024
1 parent 0211b1a commit f13ba90
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/lib/core/redux/slices/rtcConnection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,24 +309,23 @@ export const selectIsAcceptingStreams = (state: RootState) => state.rtcConnectio
*/
startAppListening({
predicate: (_action) => {
return (
Object.entries(rtcAnalyticsCustomEvents)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.map(([_, value]) => value.actionType)
.includes(_action.type)
);
const rtcCustomEventActions = Object.values(rtcAnalyticsCustomEvents).map(({ actionType }) => actionType);

const isRtcEvent = rtcCustomEventActions.includes(_action.type);

return isRtcEvent;
},
effect: ({ type }, { getState }) => {
const state: RootState = getState();
const rtcManager = selectRtcConnectionRaw(state).rtcManager;

const rtcCustomEvent = Object.entries(rtcAnalyticsCustomEvents).find(([_, value]) => value.actionType === type);
const rtcCustomEvent = Object.values(rtcAnalyticsCustomEvents).find(({ actionType }) => actionType === type);

if (!rtcCustomEvent) {
throw new Error("No rtc custom event");
}

const { getValue, getOutput, rtcEventName } = rtcCustomEvent[1];
const { getValue, getOutput, rtcEventName } = rtcCustomEvent;
const value = getValue(state);
const output = { ...(getOutput(value) as Record<string, unknown>), _time: Date.now() };

Expand Down

0 comments on commit f13ba90

Please sign in to comment.