Typing indicators
Each channel has a typing mode (see Typing indicators):
named (the default) shows who is typing, anonymous only how many, and off nothing at all.
The client knows each channel’s mode and does the right thing.
Sending
Section titled “Sending”// Call on keystrokes; it sends at most what the host accepts, and nothing where typing is off.const sent = channel.startTyping(); // false: typing is off here, nothing was sentlet sent = channel.start_typing()?; // false: typing is off here, nothing was sentShowing
Section titled “Showing”client.on("typingStart", ({ channel, anonymous, count, members }) => { const text = anonymous ? count === 1 ? "Someone is typing…" : count === 2 ? "2 people are typing…" : "Several people are typing…" : `${members.map((m) => m.displayName).join(", ")} typing…`; showTyping(channel, text);});
channel.typing; // now: { kind: "named", member_ids } | { kind: "anonymous", count } | nulluse zaun_client::{Event, TypingNow};
if let Event::TypingStart { channel, typing } = event { match typing { TypingNow::Named { member_ids } => { /* show names */ } TypingNow::Anonymous { count } => { /* 1, 2, or 3 meaning "three or more" */ } }}let now = channel.typing(); // Option<TypingNow>In an anonymous channel the count is capped: 1, 2, or 3 meaning “three or more”, and your own typing is never counted. A typing state lasts a few seconds unless it’s repeated.
Setting a channel’s mode
Section titled “Setting a channel’s mode”Needs MANAGE_CHANNELS:
await channel.setTypingMode("anonymous"); // "named", "anonymous" or "off"channel.typingMode; // the current modeuse zaun_client::protocol::model::TypingMode;
channel.set_typing_mode(TypingMode::Anonymous)?;let mode = channel.typing_mode();