mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -04:00

Doing this BEFORE the merge prevents a lot of merge conflicts. Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
24 lines
671 B
TypeScript
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
|
|
}
|
|
}
|
|
}
|