mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
backend: Persist use-server setting
This commit is contained in:
parent
18bf01f876
commit
384ca255f3
2 changed files with 22 additions and 1 deletions
|
|
@ -118,6 +118,8 @@ impl Backend {
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.use_server.set(self.settings.boolean("use-server"));
|
||||||
|
|
||||||
if self.get_music_library_path().is_none() {
|
if self.get_music_library_path().is_none() {
|
||||||
self.set_state(BackendState::NoMusicLibrary);
|
self.set_state(BackendState::NoMusicLibrary);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -128,13 +130,24 @@ impl Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the server should be used by default.
|
/// Whether the server should be used by default.
|
||||||
|
///
|
||||||
|
/// This will return `false` if no server URL is set up. Otherwise, the
|
||||||
|
/// value is based on the users "use-server" preference.
|
||||||
pub fn use_server(&self) -> bool {
|
pub fn use_server(&self) -> bool {
|
||||||
self.use_server.get()
|
self.client.get_server_url().is_some() && self.use_server.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set whether the server should be used by default.
|
/// Set whether the server should be used by default.
|
||||||
pub fn set_use_server(&self, enabled: bool) {
|
pub fn set_use_server(&self, enabled: bool) {
|
||||||
self.use_server.set(enabled);
|
self.use_server.set(enabled);
|
||||||
|
|
||||||
|
if let Err(err) = self.settings.set_boolean("use-server", enabled) {
|
||||||
|
warn!(
|
||||||
|
"An error happened whilte trying to save the \"use-server\" setting to GSettings. \
|
||||||
|
Error message: {}",
|
||||||
|
err
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the URL of the Musicus server to connect to.
|
/// Set the URL of the Musicus server to connect to.
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,13 @@
|
||||||
<default>"https://wolfgang.johrpan.de"</default>
|
<default>"https://wolfgang.johrpan.de"</default>
|
||||||
<summary>URL of the Wolfgang server to use</summary>
|
<summary>URL of the Wolfgang server to use</summary>
|
||||||
</key>
|
</key>
|
||||||
|
<key name="use-server" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Whether to use the Wolfgang server</summary>
|
||||||
|
<description>
|
||||||
|
This setting determines whether the Wolfgang server will be used for
|
||||||
|
finding new items as well as to upload new additions and edits.
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue