fix: guests
* make guest status a flag on users * add logout handlers * add logout notification for other users
This commit is contained in:
parent
23630b19b2
commit
60a6680eaf
21 changed files with 523 additions and 601 deletions
|
|
@ -37,7 +37,7 @@ pub fn RealmSceneViewer(
|
|||
scene: Scene,
|
||||
realm_slug: String,
|
||||
#[prop(into)] members: Signal<Vec<ChannelMemberWithAvatar>>,
|
||||
#[prop(into)] active_bubbles: Signal<HashMap<(Option<Uuid>, Option<Uuid>), ActiveBubble>>,
|
||||
#[prop(into)] active_bubbles: Signal<HashMap<Uuid, ActiveBubble>>,
|
||||
#[prop(into)] loose_props: Signal<Vec<LooseProp>>,
|
||||
#[prop(into)] on_move: Callback<(f64, f64)>,
|
||||
#[prop(into)] on_prop_click: Callback<Uuid>,
|
||||
|
|
@ -51,11 +51,9 @@ pub fn RealmSceneViewer(
|
|||
#[prop(optional, into)]
|
||||
fading_members: Option<Signal<Vec<FadingMember>>>,
|
||||
/// Current user's user_id (for context menu filtering).
|
||||
/// Note: Guests are now regular users with the 'guest' tag.
|
||||
#[prop(optional, into)]
|
||||
current_user_id: Option<Signal<Option<Uuid>>>,
|
||||
/// Current user's guest_session_id (for context menu filtering).
|
||||
#[prop(optional, into)]
|
||||
current_guest_session_id: Option<Signal<Option<Uuid>>>,
|
||||
/// Whether the current user is a guest (guests cannot use context menu).
|
||||
#[prop(optional, into)]
|
||||
is_guest: Option<Signal<bool>>,
|
||||
|
|
@ -183,7 +181,6 @@ pub fn RealmSceneViewer(
|
|||
#[cfg(feature = "hydrate")]
|
||||
let on_overlay_contextmenu = {
|
||||
let current_user_id = current_user_id.clone();
|
||||
let current_guest_session_id = current_guest_session_id.clone();
|
||||
move |ev: web_sys::MouseEvent| {
|
||||
use wasm_bindgen::JsCast;
|
||||
|
||||
|
|
@ -194,7 +191,6 @@ pub fn RealmSceneViewer(
|
|||
|
||||
// Get current user identity for filtering
|
||||
let my_user_id = current_user_id.map(|s| s.get()).flatten();
|
||||
let my_guest_session_id = current_guest_session_id.map(|s| s.get()).flatten();
|
||||
|
||||
// Get click position
|
||||
let client_x = ev.client_x() as f64;
|
||||
|
|
@ -215,22 +211,17 @@ pub fn RealmSceneViewer(
|
|||
if let Some(member_id_str) = canvas.get_attribute("data-member-id") {
|
||||
// Check if click hits a non-transparent pixel
|
||||
if hit_test_canvas(&canvas, client_x, client_y) {
|
||||
// Parse the member ID to determine if it's a user_id or guest_session_id
|
||||
// Parse the member ID (now always user_id since guests are users)
|
||||
if let Ok(member_id) = member_id_str.parse::<Uuid>() {
|
||||
// Check if this is the current user's avatar
|
||||
let is_current_user = my_user_id == Some(member_id)
|
||||
|| my_guest_session_id == Some(member_id);
|
||||
let is_current_user = my_user_id == Some(member_id);
|
||||
|
||||
if !is_current_user {
|
||||
// Find the display name for this member
|
||||
let display_name = members
|
||||
.get()
|
||||
.iter()
|
||||
.find(|m| {
|
||||
m.member.user_id == Some(member_id)
|
||||
|| m.member.guest_session_id
|
||||
== Some(member_id)
|
||||
})
|
||||
.find(|m| m.member.user_id == member_id)
|
||||
.map(|m| m.member.display_name.clone());
|
||||
|
||||
if let Some(name) = display_name {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue