presence: Frontend implementation of the last_update_id API.

Note: This involves adding presence info of unknown users to the
presence data.
With some small tweaks, we can just add the info to the presence data
structures, just making sure the buddy list correctly skips those
entries and that we redraw the user in the case where the user creation
event arrives after the presence polling loop.
This commit is contained in:
Mateusz Mandera
2024-06-05 22:22:17 +02:00
committed by Tim Abbott
parent 3a680763bd
commit 3ded4c2a7d
11 changed files with 143 additions and 40 deletions

View File

@@ -78,6 +78,16 @@ export function redraw_user(user_id: number): void {
});
}
export function check_should_redraw_new_user(user_id: number): boolean {
if (realm.realm_presence_disabled) {
return false;
}
const user_is_in_presence_info = presence.presence_info.has(user_id);
const user_not_yet_known = people.maybe_get_user_by_id(user_id, true) === undefined;
return user_is_in_presence_info && user_not_yet_known;
}
export function searching(): boolean {
return user_filter?.searching() ?? false;
}