hedgedoc/frontend/src/redux/realtime/reducers/build-state-from-add-user.ts
Tilman Vatteroth 762a0a850e
fix: Move content into to frontend directory
Doing this BEFORE the merge prevents a lot of merge conflicts.

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
2022-11-20 19:48:40 +01:00

24 lines
671 B
TypeScript

/*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { OnlineUser, RealtimeState } from '../types'
/**
* Builds a new {@link RealtimeState} with a new client id that is shown as online.
*
* @param oldState The old state that will be copied
* @param clientId The identifier of the new client
* @param user The information about the new user
* @return the generated state
*/
export const buildStateFromAddUser = (oldState: RealtimeState, clientId: number, user: OnlineUser): RealtimeState => {
return {
users: {
...oldState.users,
[clientId]: user
}
}
}