Skip to content

Commit

Permalink
Fixes issue where realtime updates isn't working.
Browse files Browse the repository at this point in the history
  • Loading branch information
mntone committed Jun 22, 2024
1 parent da611e0 commit bf1c518
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/modules/overlay/middlewares/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ import { addTelemetry } from '@/telemetry/slicers'
import type { RootState } from 'app/store'

const overlay = (store: MiddlewareAPI<Dispatch, RootState>) => (next: Dispatch) => (action: UnknownAction) => {
next(action)

const result = next(action)
const state = store.getState()

// Return when match is not selected
const matchId = state.overlay.match
if (matchId === undefined) {
return
return result
}

// Return when match is not found
const currentSession = state.telemetry[matchId]
const currentSession = state.telemetry.entities[matchId]
if (currentSession === undefined) {
return
return result
}

// Show powered-by and return if closed when realtime,
Expand All @@ -31,7 +30,7 @@ const overlay = (store: MiddlewareAPI<Dispatch, RootState>) => (next: Dispatch)
if (inAddTelemetry) {
store.dispatch(showPoweredby() as any)
}
return
return result
}

if (!state.overlay.wave) {
Expand All @@ -43,8 +42,9 @@ const overlay = (store: MiddlewareAPI<Dispatch, RootState>) => (next: Dispatch)

const notify = notifyOnQuotaMet || notifyOnWaveFinished
if (notify && inAddTelemetry) {
const latestWave = currentSession?.waves.findLast((w): w is ShakeDefaultWave => w.wave !== 'extra')
if (latestWave) {
const latestWaveKey = currentSession.waveKeys.findLast(waveKey => waveKey !== 'extra')
if (latestWaveKey) {
const latestWave = currentSession.waves[latestWaveKey] as ShakeDefaultWave
const latestUpdate = forceLast(latestWave.updates)

// Notify upon quota met or wave finished
Expand Down Expand Up @@ -80,6 +80,7 @@ const overlay = (store: MiddlewareAPI<Dispatch, RootState>) => (next: Dispatch)
}
}
}
return result
}

export default overlay

0 comments on commit bf1c518

Please sign in to comment.