mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: Add idle detection to collaboration feature (#2877)
* Start idle detection implementation * First working version * Add screen state * Add type safety * Better rendering, enum types, localization * Add origin trial token * Fix * Refactor idle detection to no longer use IdleDetector API * Cleanup some leftovers * Fix * Apply suggestions from code review * Three state: active 🟢, idle 💤, away ⚫️ * Address feedback from code review Thanks, @lipis * Deal with unmount Co-authored-by: Panayiotis Lipiridis <lipiridis@gmail.com>
This commit is contained in:
parent
15f698dc21
commit
1837147c55
11 changed files with 156 additions and 6 deletions
|
@ -882,6 +882,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
const pointerViewportCoords: SceneState["remotePointerViewportCoords"] = {};
|
||||
const remoteSelectedElementIds: SceneState["remoteSelectedElementIds"] = {};
|
||||
const pointerUsernames: { [id: string]: string } = {};
|
||||
const pointerUserStates: { [id: string]: string } = {};
|
||||
this.state.collaborators.forEach((user, socketId) => {
|
||||
if (user.selectedElementIds) {
|
||||
for (const id of Object.keys(user.selectedElementIds)) {
|
||||
|
@ -897,6 +898,9 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
if (user.username) {
|
||||
pointerUsernames[socketId] = user.username;
|
||||
}
|
||||
if (user.userState) {
|
||||
pointerUserStates[socketId] = user.userState;
|
||||
}
|
||||
pointerViewportCoords[socketId] = sceneCoordsToViewportCoords(
|
||||
{
|
||||
sceneX: user.pointer.x,
|
||||
|
@ -931,6 +935,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
remotePointerButton: cursorButton,
|
||||
remoteSelectedElementIds,
|
||||
remotePointerUsernames: pointerUsernames,
|
||||
remotePointerUserStates: pointerUserStates,
|
||||
shouldCacheIgnoreZoom: this.state.shouldCacheIgnoreZoom,
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue