VNOX-Client/src/ui/state/default.rs
loki5512344 eed3e28c63
feat(client): synthesized notification sounds with settings
Short tones for joining and leaving a voice room, other participants
joining and leaving, new messages outside the viewed chat, mentions,
microphone mute and unmute, deafen and undeafen, server connection and
loss, and errors. The tones are generated at runtime (rising motifs for
arrival or enable, falling for leave or disable) with an attack and a
fade-out so they never click; no third-party audio is bundled.

Inside a voice room the sound is mixed into the open playback stream,
otherwise a short one-shot stream is opened on the selected output device
off the UI thread, capped at two at a time. While deafened nothing plays
except the undeafen sound. Settings: master switch, volume and separate
switches for voice room, messages and mentions, stored with the audio
preferences, with a new settings section and a test button.
2026-10-25 10:03:21 +01:00

88 lines
2.7 KiB
Rust

use std::collections::HashMap;
use super::models::default_bookmarks;
use super::types::{ConnState, UiState, VoiceUiState};
impl Default for UiState {
fn default() -> Self {
Self {
appearance: crate::ui::appearance::AppearancePreferences::default(),
conn: ConnState::Disconnected,
connect_input: "127.0.0.1:7600".into(),
bookmarks: default_bookmarks(),
selected_bookmark: 0,
status_msg: None,
trust_prompt: None,
channels: Vec::new(),
active_channel: None,
messages: Default::default(),
chat_input: String::new(),
drafts: HashMap::new(),
browsing_dms: false,
showing_voice: false,
voice_target: None,
pending_voice_join: None,
vault_enabled: false,
scroll_bottom: false,
voice: VoiceUiState::Off,
voice_joined_at: None,
user_names: Default::default(),
rtt_ms: None,
settings_open: false,
mic_enabled: true,
ptt_held: false,
deafen: false,
vad_mode: crate::ui::state::DEFAULT_VOICE_MODE,
voice_bitrate: 64.0,
packet_interval: 1,
mic_device: 0,
mic_device_id: String::new(),
output_device: 0,
output_device_id: String::new(),
output_volume: 90.0,
sounds: Default::default(),
device_lists: Default::default(),
vad_mode_chosen: false,
auto_reconnect: true,
guilds: Vec::new(),
active_guild_id: None,
presences: Default::default(),
friends: Vec::new(),
pending_friend_requests: Vec::new(),
blocked_users: Vec::new(),
dm_conversations: Vec::new(),
dm_messages: Default::default(),
active_dm_id: None,
new_dm_input: None,
user_colors: HashMap::new(),
private_mode: false,
typing_users: HashMap::new(),
read_receipts: HashMap::new(),
friends_tab: "all".into(),
local_speaking: false,
remote_speaking: false,
last_remote_speaker_id: String::new(),
last_voice_packet_ms: 0,
replying_to_message: None,
replying_to_sender: String::new(),
replying_to_content: String::new(),
editing_message_id: None,
settings_passphrase_error: None,
settings_export_output: None,
settings_export_error: None,
settings_import_error: None,
}
}
}