fix: teleport was prepopulating prior wisper
This commit is contained in:
parent
41ea9d13cb
commit
864cfaec54
2 changed files with 19 additions and 9 deletions
|
|
@ -128,8 +128,9 @@ pub fn ChatInput(
|
|||
#[prop(optional)]
|
||||
on_open_log: Option<Callback<()>>,
|
||||
/// Signal containing the display name to whisper to. When set, pre-fills the input.
|
||||
#[prop(optional, into)]
|
||||
whisper_target: Option<Signal<Option<String>>>,
|
||||
/// Uses RwSignal so the component can clear it after consuming.
|
||||
#[prop(optional)]
|
||||
whisper_target: Option<RwSignal<Option<String>>>,
|
||||
/// List of available scenes for teleport command.
|
||||
#[prop(optional, into)]
|
||||
scenes: Option<Signal<Vec<SceneSummary>>>,
|
||||
|
|
@ -240,6 +241,9 @@ pub fn ChatInput(
|
|||
let _ = input.focus();
|
||||
let len = whisper_prefix.len() as u32;
|
||||
let _ = input.set_selection_range(len, len);
|
||||
|
||||
// Clear the whisper target so it doesn't re-trigger on re-render
|
||||
whisper_signal.set(None);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ pub fn RealmPage() -> impl IntoView {
|
|||
let (is_guest, set_is_guest) = signal(false);
|
||||
|
||||
// Whisper target - when set, triggers pre-fill in ChatInput
|
||||
let (whisper_target, set_whisper_target) = signal(Option::<String>::None);
|
||||
let whisper_target = RwSignal::new(Option::<String>::None);
|
||||
|
||||
// Notification state for cross-scene whispers
|
||||
let (current_notification, set_current_notification) =
|
||||
|
|
@ -852,10 +852,17 @@ pub fn RealmPage() -> impl IntoView {
|
|||
*closure_holder_clone.borrow_mut() = Some(closure);
|
||||
|
||||
// Add keyup handler for releasing '?' (hotkey help)
|
||||
// We hide on any keyup when visible, since ? = Shift+/ and releasing
|
||||
// either key means the user is no longer holding '?'
|
||||
let keyup_closure = Closure::<dyn Fn(web_sys::KeyboardEvent)>::new(
|
||||
move |ev: web_sys::KeyboardEvent| {
|
||||
if ev.key() == "?" {
|
||||
let key = ev.key();
|
||||
// Hide if releasing ?, /, or Shift while help is visible
|
||||
if hotkey_help_visible.get_untracked()
|
||||
&& (key == "?" || key == "/" || key == "Shift")
|
||||
{
|
||||
set_hotkey_help_visible.set(false);
|
||||
ev.prevent_default();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
@ -1024,9 +1031,8 @@ pub fn RealmPage() -> impl IntoView {
|
|||
let on_open_log_cb = Callback::new(move |_: ()| {
|
||||
set_log_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));
|
||||
whisper_target.set(Some(target));
|
||||
});
|
||||
let scenes_signal = Signal::derive(move || available_scenes.get());
|
||||
let teleport_enabled_signal = Signal::derive(move || allow_user_teleport.get());
|
||||
|
|
@ -1074,7 +1080,7 @@ pub fn RealmPage() -> impl IntoView {
|
|||
on_open_settings=on_open_settings_cb
|
||||
on_open_inventory=on_open_inventory_cb
|
||||
on_open_log=on_open_log_cb
|
||||
whisper_target=whisper_target_signal
|
||||
whisper_target=whisper_target
|
||||
scenes=scenes_signal
|
||||
allow_user_teleport=teleport_enabled_signal
|
||||
on_teleport=on_teleport_cb
|
||||
|
|
@ -1179,7 +1185,7 @@ pub fn RealmPage() -> impl IntoView {
|
|||
<NotificationToast
|
||||
notification=Signal::derive(move || current_notification.get())
|
||||
on_reply=Callback::new(move |name: String| {
|
||||
set_whisper_target.set(Some(name));
|
||||
whisper_target.set(Some(name));
|
||||
})
|
||||
on_context=Callback::new(move |name: String| {
|
||||
set_conversation_partner.set(name);
|
||||
|
|
@ -1222,7 +1228,7 @@ pub fn RealmPage() -> impl IntoView {
|
|||
open=Signal::derive(move || history_modal_open.get())
|
||||
on_close=Callback::new(move |_: ()| set_history_modal_open.set(false))
|
||||
on_reply=Callback::new(move |name: String| {
|
||||
set_whisper_target.set(Some(name));
|
||||
whisper_target.set(Some(name));
|
||||
})
|
||||
on_context=Callback::new(move |name: String| {
|
||||
set_conversation_partner.set(name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue