use cfg of spotify object
TODO: - apply this to other single config values that are passed directly, e.g. in the statusbar - use a more appropriate object to hold `cfg`
This commit is contained in:
@@ -19,7 +19,7 @@ pub struct Config {
|
||||
pub backend_device: Option<String>,
|
||||
pub volnorm: Option<bool>,
|
||||
pub volnorm_pregain: Option<f32>,
|
||||
pub notify: Option<bool>
|
||||
pub notify: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
|
||||
|
||||
@@ -224,10 +224,7 @@ fn main() {
|
||||
&cfg,
|
||||
));
|
||||
|
||||
let queue = Arc::new(queue::Queue::new(
|
||||
spotify.clone(),
|
||||
cfg.notify.unwrap_or(false),
|
||||
));
|
||||
let queue = Arc::new(queue::Queue::new(spotify.clone()));
|
||||
|
||||
#[cfg(feature = "mpris")]
|
||||
let mpris_manager = Arc::new(mpris::MprisManager::new(spotify.clone(), queue.clone()));
|
||||
|
||||
@@ -20,19 +20,17 @@ pub struct Queue {
|
||||
random_order: RwLock<Option<Vec<usize>>>,
|
||||
current_track: RwLock<Option<usize>>,
|
||||
repeat: RwLock<RepeatSetting>,
|
||||
notify: bool,
|
||||
spotify: Arc<Spotify>,
|
||||
}
|
||||
|
||||
impl Queue {
|
||||
pub fn new(spotify: Arc<Spotify>, notify: bool) -> Queue {
|
||||
pub fn new(spotify: Arc<Spotify>) -> Queue {
|
||||
let q = Queue {
|
||||
queue: Arc::new(RwLock::new(Vec::new())),
|
||||
spotify,
|
||||
current_track: RwLock::new(None),
|
||||
repeat: RwLock::new(RepeatSetting::None),
|
||||
random_order: RwLock::new(None),
|
||||
notify,
|
||||
};
|
||||
q.set_repeat(q.spotify.repeat);
|
||||
q.set_shuffle(q.spotify.shuffle);
|
||||
@@ -218,7 +216,7 @@ impl Queue {
|
||||
let mut current = self.current_track.write().unwrap();
|
||||
current.replace(index);
|
||||
self.spotify.update_track();
|
||||
if self.notify {
|
||||
if self.spotify.cfg.notify.unwrap_or(false) {
|
||||
Notification::new()
|
||||
.summary(&track.to_string())
|
||||
.show()
|
||||
|
||||
@@ -83,7 +83,7 @@ pub enum PlayerEvent {
|
||||
pub struct Spotify {
|
||||
events: EventManager,
|
||||
credentials: Credentials,
|
||||
cfg: config::Config,
|
||||
pub cfg: config::Config,
|
||||
status: RwLock<PlayerEvent>,
|
||||
api: RwLock<SpotifyAPI>,
|
||||
elapsed: RwLock<Option<Duration>>,
|
||||
|
||||
Reference in New Issue
Block a user