mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
avoid warning on int sortBackwards from older Anki versions
This commit is contained in:
parent
75faba1667
commit
62fa265213
1 changed files with 6 additions and 1 deletions
|
@ -6,6 +6,7 @@ use crate::decks::DeckID;
|
||||||
use crate::err::Result;
|
use crate::err::Result;
|
||||||
use crate::timestamp::TimestampSecs;
|
use crate::timestamp::TimestampSecs;
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::{de::DeserializeOwned, Serialize};
|
||||||
|
use serde_aux::field_attributes::deserialize_bool_from_anything;
|
||||||
use serde_derive::Deserialize;
|
use serde_derive::Deserialize;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use slog::warn;
|
use slog::warn;
|
||||||
|
@ -52,6 +53,9 @@ impl From<ConfigKey> for &'static str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Default)]
|
||||||
|
struct BoolLike(#[serde(deserialize_with = "deserialize_bool_from_anything")] bool);
|
||||||
|
|
||||||
impl Collection {
|
impl Collection {
|
||||||
/// Get config item, returning None if missing/invalid.
|
/// Get config item, returning None if missing/invalid.
|
||||||
pub(crate) fn get_config_optional<'a, T, K>(&self, key: K) -> Option<T>
|
pub(crate) fn get_config_optional<'a, T, K>(&self, key: K) -> Option<T>
|
||||||
|
@ -93,7 +97,8 @@ impl Collection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_browser_sort_reverse(&self) -> bool {
|
pub(crate) fn get_browser_sort_reverse(&self) -> bool {
|
||||||
self.get_config_default(ConfigKey::BrowserSortReverse)
|
let b: BoolLike = self.get_config_default(ConfigKey::BrowserSortReverse);
|
||||||
|
b.0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_current_deck_id(&self) -> DeckID {
|
pub(crate) fn get_current_deck_id(&self) -> DeckID {
|
||||||
|
|
Loading…
Reference in a new issue