fix(channels): use default_channel from config

This commit is contained in:
lalvarezt 2025-05-22 12:35:47 +02:00
parent 7bbf538898
commit 8e987e1cda
2 changed files with 8 additions and 9 deletions

View File

@ -4,6 +4,7 @@ use std::{
ops::Deref, ops::Deref,
}; };
use crate::config::default_channel;
use crate::{cable::CableSpec, channels::preview::PreviewCommand}; use crate::{cable::CableSpec, channels::preview::PreviewCommand};
/// A prototype for cable channels. /// A prototype for cable channels.
@ -110,11 +111,10 @@ impl Deref for Cable {
impl Cable { impl Cable {
pub fn default_channel(&self) -> ChannelPrototype { pub fn default_channel(&self) -> ChannelPrototype {
self.get(DEFAULT_PROTOTYPE_NAME) let default_channel = &default_channel();
.cloned() self.get(default_channel).cloned().unwrap_or_else(|| {
.unwrap_or_else(|| { panic!("Default channel '{default_channel}' not found")
panic!("Default channel '{DEFAULT_PROTOTYPE_NAME}' not found") })
})
} }
} }

View File

@ -15,8 +15,6 @@ pub use themes::Theme;
use tracing::{debug, warn}; use tracing::{debug, warn};
pub use ui::UiConfig; pub use ui::UiConfig;
use crate::channels::prototypes::DEFAULT_PROTOTYPE_NAME;
mod keybindings; mod keybindings;
pub mod shell_integration; pub mod shell_integration;
mod themes; mod themes;
@ -41,8 +39,9 @@ pub struct AppConfig {
pub default_channel: String, pub default_channel: String,
} }
fn default_channel() -> String { pub fn default_channel() -> String {
DEFAULT_PROTOTYPE_NAME.to_string() let config = Config::load_user_config(&get_config_dir()).unwrap();
config.application.default_channel.to_string()
} }
impl Hash for AppConfig { impl Hash for AppConfig {