Add the right-click ability on avatars
This commit is contained in:
parent
d1cbb3ba34
commit
0492043625
7 changed files with 438 additions and 2 deletions
|
|
@ -17,7 +17,7 @@ use crate::components::{
|
|||
ViewerSettings,
|
||||
};
|
||||
#[cfg(feature = "hydrate")]
|
||||
use crate::components::{use_channel_websocket, ChatMessage, DEFAULT_BUBBLE_TIMEOUT_MS, FADE_DURATION_MS};
|
||||
use crate::components::{use_channel_websocket, ChannelMemberInfo, ChatMessage, DEFAULT_BUBBLE_TIMEOUT_MS, FADE_DURATION_MS};
|
||||
use crate::utils::LocalStoragePersist;
|
||||
#[cfg(feature = "hydrate")]
|
||||
use crate::utils::parse_bounds_dimensions;
|
||||
|
|
@ -90,6 +90,13 @@ pub fn RealmPage() -> impl IntoView {
|
|||
// Track user's current position for saving on beforeunload
|
||||
let (current_position, set_current_position) = signal((400.0_f64, 300.0_f64));
|
||||
|
||||
// Current user identity (received from WebSocket Welcome message)
|
||||
let (current_user_id, set_current_user_id) = signal(Option::<Uuid>::None);
|
||||
let (current_guest_session_id, set_current_guest_session_id) = signal(Option::<Uuid>::None);
|
||||
|
||||
// Whisper target - when set, triggers pre-fill in ChatInput
|
||||
let (whisper_target, set_whisper_target) = signal(Option::<String>::None);
|
||||
|
||||
let realm_data = LocalResource::new(move || {
|
||||
let slug = slug.get();
|
||||
async move {
|
||||
|
|
@ -244,6 +251,13 @@ pub fn RealmPage() -> impl IntoView {
|
|||
});
|
||||
});
|
||||
|
||||
// Callback to capture current user identity from Welcome message
|
||||
#[cfg(feature = "hydrate")]
|
||||
let on_welcome = Callback::new(move |info: ChannelMemberInfo| {
|
||||
set_current_user_id.set(info.user_id);
|
||||
set_current_guest_session_id.set(info.guest_session_id);
|
||||
});
|
||||
|
||||
#[cfg(feature = "hydrate")]
|
||||
let (_ws_state, ws_sender) = use_channel_websocket(
|
||||
slug,
|
||||
|
|
@ -254,6 +268,7 @@ pub fn RealmPage() -> impl IntoView {
|
|||
on_prop_dropped,
|
||||
on_prop_picked_up,
|
||||
on_member_fading,
|
||||
Some(on_welcome),
|
||||
);
|
||||
|
||||
// Set channel ID and scene dimensions when scene loads
|
||||
|
|
@ -654,6 +669,10 @@ pub fn RealmPage() -> impl IntoView {
|
|||
let on_open_inventory_cb = Callback::new(move |_: ()| {
|
||||
set_inventory_open.set(true);
|
||||
});
|
||||
let whisper_target_signal = Signal::derive(move || whisper_target.get());
|
||||
let on_whisper_request_cb = Callback::new(move |target: String| {
|
||||
set_whisper_target.set(Some(target));
|
||||
});
|
||||
view! {
|
||||
<div class="relative w-full">
|
||||
<RealmSceneViewer
|
||||
|
|
@ -672,6 +691,9 @@ pub fn RealmPage() -> impl IntoView {
|
|||
});
|
||||
})
|
||||
fading_members=Signal::derive(move || fading_members.get())
|
||||
current_user_id=Signal::derive(move || current_user_id.get())
|
||||
current_guest_session_id=Signal::derive(move || current_guest_session_id.get())
|
||||
on_whisper_request=on_whisper_request_cb
|
||||
/>
|
||||
<div class="absolute bottom-0 left-0 right-0 z-10 pb-4 px-4 pointer-events-none">
|
||||
<ChatInput
|
||||
|
|
@ -683,6 +705,7 @@ pub fn RealmPage() -> impl IntoView {
|
|||
on_focus_change=on_chat_focus_change.clone()
|
||||
on_open_settings=on_open_settings_cb
|
||||
on_open_inventory=on_open_inventory_cb
|
||||
whisper_target=whisper_target_signal
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue