Merge pull request #4 from aljazceru/claude/fix-channel-add-enter-01H88cPopcq3yfugGjQWDGZZ

Claude/fix channel add enter 01 h88c popcq3yfug gj qwdgzz
This commit is contained in:
2025-11-14 11:09:02 +01:00
committed by GitHub
2 changed files with 43 additions and 27 deletions

View File

@@ -259,6 +259,20 @@ fn update_damus(damus: &mut Damus, app_ctx: &mut AppContext<'_>, ctx: &egui::Con
) {
warn!("update_damus init: {err}");
}
// Check if we only have the default fallback account (no real accounts)
// If so, redirect to add account screen on first run
let selected_account = app_ctx.accounts.get_selected_account();
let account_count = app_ctx.accounts.cache.into_iter().count();
if selected_account.key.pubkey == notedeck::FALLBACK_PUBKEY() &&
selected_account.key.secret_key.is_none() &&
account_count == 1 {
// Only have the fallback account, redirect to add account
info!("No real accounts found, redirecting to add account screen");
damus.columns_mut(app_ctx.i18n, app_ctx.accounts)
.get_selected_router()
.route_to(Route::add_account());
}
}
DamusState::Initialized => (),

View File

@@ -129,35 +129,37 @@ impl ChannelDialog {
);
// Handle Escape key to close dialog
ui.input(|i| {
if i.key_pressed(egui::Key::Escape) {
action = Some(ChannelDialogAction::Cancel);
}
// Handle Enter key when name is focused
if i.key_pressed(egui::Key::Enter) && !hashtags_response.has_focus() {
if !self.name.trim().is_empty() {
let hashtags: Vec<String> = self
.hashtags
.split(',')
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty())
.collect();
let escape_pressed = ui.input(|i| i.key_pressed(egui::Key::Escape));
let enter_pressed = ui.input(|i| i.key_pressed(egui::Key::Enter));
action = if let Some(index) = self.editing_index {
Some(ChannelDialogAction::Edit {
index,
name: self.name.trim().to_string(),
hashtags,
})
} else {
Some(ChannelDialogAction::Create {
name: self.name.trim().to_string(),
hashtags,
})
};
}
if escape_pressed {
action = Some(ChannelDialogAction::Cancel);
}
// Handle Enter key when name is focused (not hashtags multiline field)
if enter_pressed && !hashtags_response.has_focus() {
if !self.name.trim().is_empty() {
let hashtags: Vec<String> = self
.hashtags
.split(',')
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty())
.collect();
action = if let Some(index) = self.editing_index {
Some(ChannelDialogAction::Edit {
index,
name: self.name.trim().to_string(),
hashtags,
})
} else {
Some(ChannelDialogAction::Create {
name: self.name.trim().to_string(),
hashtags,
})
};
}
});
}
ui.add_space(24.0);