feat: auto-join #ops on first login (web + TUI)
New users with no peer/group set automatically join #ops so they have someone to talk to. Saved peer overrides this on subsequent visits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -48,6 +48,24 @@ pub async fn run_tui(
|
||||
network::poll_loop(poll_messages, poll_receipts, poll_pending_files, poll_fp, poll_identity, poll_db, poll_client, poll_last_dm, poll_connected).await;
|
||||
});
|
||||
|
||||
// Auto-join #ops if no peer set
|
||||
if app.peer_fp.is_none() {
|
||||
let join_url = format!("{}/v1/groups/ops/join", client.base_url);
|
||||
let fp_clean: String = our_fp.chars().filter(|c| c.is_ascii_hexdigit()).collect::<String>().to_lowercase();
|
||||
let _ = client.client.post(&join_url)
|
||||
.json(&serde_json::json!({"fingerprint": fp_clean}))
|
||||
.send().await;
|
||||
app.peer_fp = Some("#ops".to_string());
|
||||
app.add_message(types::ChatLine {
|
||||
sender: "system".into(),
|
||||
text: "Welcome! You have been added to #ops".into(),
|
||||
is_system: true,
|
||||
is_self: false,
|
||||
message_id: None,
|
||||
timestamp: chrono::Local::now(),
|
||||
});
|
||||
}
|
||||
|
||||
loop {
|
||||
terminal.draw(|frame| app.draw(frame))?;
|
||||
|
||||
|
||||
@@ -925,9 +925,20 @@ async function enterChat() {
|
||||
addSys('/alias · /g · /gleave · /gkick · /gmembers · /glist · /friend · /file · /info');
|
||||
|
||||
const savedPeer = localStorage.getItem('wz-peer');
|
||||
if (savedPeer) $peerInput.value = savedPeer;
|
||||
if (savedPeer) {
|
||||
$peerInput.value = savedPeer;
|
||||
}
|
||||
|
||||
connectWebSocket();
|
||||
|
||||
// Auto-join #ops if no peer/group set
|
||||
if (!savedPeer) {
|
||||
setTimeout(async () => {
|
||||
await groupSwitch('ops');
|
||||
addSys('Welcome! You have been added to #ops');
|
||||
}, 500);
|
||||
}
|
||||
|
||||
$input.focus();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user