[MIRROR] Chat history prototype (#10278)

Co-authored-by: Selis <12716288+ItsSelis@users.noreply.github.com>
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-03-02 09:22:34 -07:00
committed by GitHub
parent 36231619db
commit 09bb0e61b3
33 changed files with 746 additions and 235 deletions

View File

@@ -4,16 +4,21 @@
* @license MIT
*/
import { connectionLost } from './actions';
import { connectionLost, updateExportData } from './actions';
import { connectionRestored, dismissWarning } from './actions';
import type { gameState } from './types';
const initialState = {
const initialState: gameState = {
// TODO: This is where round info should be.
roundId: null,
roundTime: null,
roundRestartedAt: null,
connectionLostAt: null,
dismissedConnectionWarning: false,
databaseBackendEnabled: false,
chatlogApiEndpoint: '',
databaseStoredRounds: [],
userData: { ckey: '', token: '' },
};
export const gameReducer = (state = initialState, action) => {
@@ -29,6 +34,9 @@ export const gameReducer = (state = initialState, action) => {
return {
...state,
roundId: payload.round_id,
databaseBackendEnabled: payload.chatlog_db_backend,
chatlogApiEndpoint: payload.chatlog_api_endpoint,
databaseStoredRounds: payload.chatlog_stored_rounds,
};
}
}
@@ -51,5 +59,11 @@ export const gameReducer = (state = initialState, action) => {
dismissedConnectionWarning: true,
};
}
if (type === updateExportData.type) {
return {
...state,
userData: payload,
};
}
return state;
};