mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
deckconfig.proto -> deck_config.proto
Makes it consistent with our other proto files, and matches the service name.
This commit is contained in:
parent
5349f32e8d
commit
ffadbf577b
12 changed files with 45 additions and 42 deletions
|
@ -7,7 +7,7 @@ option java_multiple_files = true;
|
||||||
// the DeckConfig message clashes with the name of the file
|
// the DeckConfig message clashes with the name of the file
|
||||||
option java_outer_classname = "DeckConf";
|
option java_outer_classname = "DeckConf";
|
||||||
|
|
||||||
package anki.deckconfig;
|
package anki.deck_config;
|
||||||
|
|
||||||
import "anki/generic.proto";
|
import "anki/generic.proto";
|
||||||
import "anki/collection.proto";
|
import "anki/collection.proto";
|
|
@ -11,7 +11,7 @@ if TYPE_CHECKING:
|
||||||
|
|
||||||
import anki.cards
|
import anki.cards
|
||||||
import anki.collection
|
import anki.collection
|
||||||
from anki import deckconfig_pb2, decks_pb2
|
from anki import deck_config_pb2, decks_pb2
|
||||||
from anki._legacy import DeprecatedNamesMixin, deprecated, print_deprecation_warning
|
from anki._legacy import DeprecatedNamesMixin, deprecated, print_deprecation_warning
|
||||||
from anki.collection import OpChanges, OpChangesWithCount, OpChangesWithId
|
from anki.collection import OpChanges, OpChangesWithCount, OpChangesWithId
|
||||||
from anki.consts import *
|
from anki.consts import *
|
||||||
|
@ -23,8 +23,8 @@ DeckTreeNode = decks_pb2.DeckTreeNode
|
||||||
DeckNameId = decks_pb2.DeckNameId
|
DeckNameId = decks_pb2.DeckNameId
|
||||||
FilteredDeckConfig = decks_pb2.Deck.Filtered
|
FilteredDeckConfig = decks_pb2.Deck.Filtered
|
||||||
DeckCollapseScope = decks_pb2.SetDeckCollapsedRequest.Scope
|
DeckCollapseScope = decks_pb2.SetDeckCollapsedRequest.Scope
|
||||||
DeckConfigsForUpdate = deckconfig_pb2.DeckConfigsForUpdate
|
DeckConfigsForUpdate = deck_config_pb2.DeckConfigsForUpdate
|
||||||
UpdateDeckConfigs = deckconfig_pb2.UpdateDeckConfigsRequest
|
UpdateDeckConfigs = deck_config_pb2.UpdateDeckConfigsRequest
|
||||||
Deck = decks_pb2.Deck
|
Deck = decks_pb2.Deck
|
||||||
|
|
||||||
# type aliases until we can move away from dicts
|
# type aliases until we can move away from dicts
|
||||||
|
|
|
@ -225,7 +225,7 @@ import anki.card_rendering_pb2
|
||||||
import anki.cards_pb2
|
import anki.cards_pb2
|
||||||
import anki.collection_pb2
|
import anki.collection_pb2
|
||||||
import anki.config_pb2
|
import anki.config_pb2
|
||||||
import anki.deckconfig_pb2
|
import anki.deck_config_pb2
|
||||||
import anki.decks_pb2
|
import anki.decks_pb2
|
||||||
import anki.i18n_pb2
|
import anki.i18n_pb2
|
||||||
import anki.image_occlusion_pb2
|
import anki.image_occlusion_pb2
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
// Copyright: Ankitects Pty Ltd and contributors
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
// DeckConfig inside deck_config.proto
|
||||||
|
#![allow(clippy::module_inception)]
|
||||||
|
|
||||||
mod generic_helpers;
|
mod generic_helpers;
|
||||||
|
|
||||||
macro_rules! protobuf {
|
macro_rules! protobuf {
|
||||||
|
@ -17,7 +20,7 @@ protobuf!(card_rendering, "card_rendering");
|
||||||
protobuf!(cards, "cards");
|
protobuf!(cards, "cards");
|
||||||
protobuf!(collection, "collection");
|
protobuf!(collection, "collection");
|
||||||
protobuf!(config, "config");
|
protobuf!(config, "config");
|
||||||
protobuf!(deckconfig, "deckconfig");
|
protobuf!(deck_config, "deck_config");
|
||||||
protobuf!(decks, "decks");
|
protobuf!(decks, "decks");
|
||||||
protobuf!(generic, "generic");
|
protobuf!(generic, "generic");
|
||||||
protobuf!(i18n, "i18n");
|
protobuf!(i18n, "i18n");
|
||||||
|
|
|
@ -6,13 +6,13 @@ mod service;
|
||||||
pub(crate) mod undo;
|
pub(crate) mod undo;
|
||||||
mod update;
|
mod update;
|
||||||
|
|
||||||
pub use anki_proto::deckconfig::deck_config::config::LeechAction;
|
pub use anki_proto::deck_config::deck_config::config::LeechAction;
|
||||||
pub use anki_proto::deckconfig::deck_config::config::NewCardGatherPriority;
|
pub use anki_proto::deck_config::deck_config::config::NewCardGatherPriority;
|
||||||
pub use anki_proto::deckconfig::deck_config::config::NewCardInsertOrder;
|
pub use anki_proto::deck_config::deck_config::config::NewCardInsertOrder;
|
||||||
pub use anki_proto::deckconfig::deck_config::config::NewCardSortOrder;
|
pub use anki_proto::deck_config::deck_config::config::NewCardSortOrder;
|
||||||
pub use anki_proto::deckconfig::deck_config::config::ReviewCardOrder;
|
pub use anki_proto::deck_config::deck_config::config::ReviewCardOrder;
|
||||||
pub use anki_proto::deckconfig::deck_config::config::ReviewMix;
|
pub use anki_proto::deck_config::deck_config::config::ReviewMix;
|
||||||
pub use anki_proto::deckconfig::deck_config::Config as DeckConfigInner;
|
pub use anki_proto::deck_config::deck_config::Config as DeckConfigInner;
|
||||||
pub use schema11::DeckConfSchema11;
|
pub use schema11::DeckConfSchema11;
|
||||||
pub use schema11::NewCardOrderSchema11;
|
pub use schema11::NewCardOrderSchema11;
|
||||||
pub use update::UpdateDeckConfigsRequest;
|
pub use update::UpdateDeckConfigsRequest;
|
||||||
|
|
|
@ -13,13 +13,13 @@ impl crate::services::DeckConfigService for Collection {
|
||||||
fn add_or_update_deck_config_legacy(
|
fn add_or_update_deck_config_legacy(
|
||||||
&mut self,
|
&mut self,
|
||||||
input: generic::Json,
|
input: generic::Json,
|
||||||
) -> error::Result<anki_proto::deckconfig::DeckConfigId> {
|
) -> error::Result<anki_proto::deck_config::DeckConfigId> {
|
||||||
let conf: DeckConfSchema11 = serde_json::from_slice(&input.json)?;
|
let conf: DeckConfSchema11 = serde_json::from_slice(&input.json)?;
|
||||||
let mut conf: DeckConfig = conf.into();
|
let mut conf: DeckConfig = conf.into();
|
||||||
|
|
||||||
self.transact_no_undo(|col| {
|
self.transact_no_undo(|col| {
|
||||||
col.add_or_update_deck_config_legacy(&mut conf)?;
|
col.add_or_update_deck_config_legacy(&mut conf)?;
|
||||||
Ok(anki_proto::deckconfig::DeckConfigId { dcid: conf.id.0 })
|
Ok(anki_proto::deck_config::DeckConfigId { dcid: conf.id.0 })
|
||||||
})
|
})
|
||||||
.map(Into::into)
|
.map(Into::into)
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ impl crate::services::DeckConfigService for Collection {
|
||||||
|
|
||||||
fn get_deck_config(
|
fn get_deck_config(
|
||||||
&mut self,
|
&mut self,
|
||||||
input: anki_proto::deckconfig::DeckConfigId,
|
input: anki_proto::deck_config::DeckConfigId,
|
||||||
) -> error::Result<anki_proto::deckconfig::DeckConfig> {
|
) -> error::Result<anki_proto::deck_config::DeckConfig> {
|
||||||
Ok(Collection::get_deck_config(self, input.into(), true)?
|
Ok(Collection::get_deck_config(self, input.into(), true)?
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into())
|
.into())
|
||||||
|
@ -47,7 +47,7 @@ impl crate::services::DeckConfigService for Collection {
|
||||||
|
|
||||||
fn get_deck_config_legacy(
|
fn get_deck_config_legacy(
|
||||||
&mut self,
|
&mut self,
|
||||||
input: anki_proto::deckconfig::DeckConfigId,
|
input: anki_proto::deck_config::DeckConfigId,
|
||||||
) -> error::Result<generic::Json> {
|
) -> error::Result<generic::Json> {
|
||||||
let conf = Collection::get_deck_config(self, input.into(), true)?.unwrap();
|
let conf = Collection::get_deck_config(self, input.into(), true)?.unwrap();
|
||||||
let conf: DeckConfSchema11 = conf.into();
|
let conf: DeckConfSchema11 = conf.into();
|
||||||
|
@ -62,7 +62,7 @@ impl crate::services::DeckConfigService for Collection {
|
||||||
|
|
||||||
fn remove_deck_config(
|
fn remove_deck_config(
|
||||||
&mut self,
|
&mut self,
|
||||||
input: anki_proto::deckconfig::DeckConfigId,
|
input: anki_proto::deck_config::DeckConfigId,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
self.transact_no_undo(|col| col.remove_deck_config_inner(input.into()))
|
self.transact_no_undo(|col| col.remove_deck_config_inner(input.into()))
|
||||||
.map(Into::into)
|
.map(Into::into)
|
||||||
|
@ -71,21 +71,21 @@ impl crate::services::DeckConfigService for Collection {
|
||||||
fn get_deck_configs_for_update(
|
fn get_deck_configs_for_update(
|
||||||
&mut self,
|
&mut self,
|
||||||
input: anki_proto::decks::DeckId,
|
input: anki_proto::decks::DeckId,
|
||||||
) -> error::Result<anki_proto::deckconfig::DeckConfigsForUpdate> {
|
) -> error::Result<anki_proto::deck_config::DeckConfigsForUpdate> {
|
||||||
self.get_deck_configs_for_update(input.did.into())
|
self.get_deck_configs_for_update(input.did.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_deck_configs(
|
fn update_deck_configs(
|
||||||
&mut self,
|
&mut self,
|
||||||
input: anki_proto::deckconfig::UpdateDeckConfigsRequest,
|
input: anki_proto::deck_config::UpdateDeckConfigsRequest,
|
||||||
) -> error::Result<anki_proto::collection::OpChanges> {
|
) -> error::Result<anki_proto::collection::OpChanges> {
|
||||||
self.update_deck_configs(input.into()).map(Into::into)
|
self.update_deck_configs(input.into()).map(Into::into)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<DeckConfig> for anki_proto::deckconfig::DeckConfig {
|
impl From<DeckConfig> for anki_proto::deck_config::DeckConfig {
|
||||||
fn from(c: DeckConfig) -> Self {
|
fn from(c: DeckConfig) -> Self {
|
||||||
anki_proto::deckconfig::DeckConfig {
|
anki_proto::deck_config::DeckConfig {
|
||||||
id: c.id.0,
|
id: c.id.0,
|
||||||
name: c.name,
|
name: c.name,
|
||||||
mtime_secs: c.mtime_secs.0,
|
mtime_secs: c.mtime_secs.0,
|
||||||
|
@ -95,8 +95,8 @@ impl From<DeckConfig> for anki_proto::deckconfig::DeckConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<anki_proto::deckconfig::UpdateDeckConfigsRequest> for UpdateDeckConfigsRequest {
|
impl From<anki_proto::deck_config::UpdateDeckConfigsRequest> for UpdateDeckConfigsRequest {
|
||||||
fn from(c: anki_proto::deckconfig::UpdateDeckConfigsRequest) -> Self {
|
fn from(c: anki_proto::deck_config::UpdateDeckConfigsRequest) -> Self {
|
||||||
UpdateDeckConfigsRequest {
|
UpdateDeckConfigsRequest {
|
||||||
target_deck_id: c.target_deck_id.into(),
|
target_deck_id: c.target_deck_id.into(),
|
||||||
configs: c.configs.into_iter().map(Into::into).collect(),
|
configs: c.configs.into_iter().map(Into::into).collect(),
|
||||||
|
@ -109,8 +109,8 @@ impl From<anki_proto::deckconfig::UpdateDeckConfigsRequest> for UpdateDeckConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<anki_proto::deckconfig::DeckConfig> for DeckConfig {
|
impl From<anki_proto::deck_config::DeckConfig> for DeckConfig {
|
||||||
fn from(c: anki_proto::deckconfig::DeckConfig) -> Self {
|
fn from(c: anki_proto::deck_config::DeckConfig) -> Self {
|
||||||
DeckConfig {
|
DeckConfig {
|
||||||
id: c.id.into(),
|
id: c.id.into(),
|
||||||
name: c.name,
|
name: c.name,
|
||||||
|
@ -121,8 +121,8 @@ impl From<anki_proto::deckconfig::DeckConfig> for DeckConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<anki_proto::deckconfig::DeckConfigId> for DeckConfigId {
|
impl From<anki_proto::deck_config::DeckConfigId> for DeckConfigId {
|
||||||
fn from(dcid: anki_proto::deckconfig::DeckConfigId) -> Self {
|
fn from(dcid: anki_proto::deck_config::DeckConfigId) -> Self {
|
||||||
DeckConfigId(dcid.dcid)
|
DeckConfigId(dcid.dcid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ use std::collections::HashMap;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use anki_proto::deckconfig::deck_configs_for_update::current_deck::Limits;
|
use anki_proto::deck_config::deck_configs_for_update::current_deck::Limits;
|
||||||
use anki_proto::deckconfig::deck_configs_for_update::ConfigWithExtra;
|
use anki_proto::deck_config::deck_configs_for_update::ConfigWithExtra;
|
||||||
use anki_proto::deckconfig::deck_configs_for_update::CurrentDeck;
|
use anki_proto::deck_config::deck_configs_for_update::CurrentDeck;
|
||||||
use anki_proto::decks::deck::normal::DayLimit;
|
use anki_proto::decks::deck::normal::DayLimit;
|
||||||
|
|
||||||
use crate::config::StringKey;
|
use crate::config::StringKey;
|
||||||
|
@ -35,8 +35,8 @@ impl Collection {
|
||||||
pub fn get_deck_configs_for_update(
|
pub fn get_deck_configs_for_update(
|
||||||
&mut self,
|
&mut self,
|
||||||
deck: DeckId,
|
deck: DeckId,
|
||||||
) -> Result<anki_proto::deckconfig::DeckConfigsForUpdate> {
|
) -> Result<anki_proto::deck_config::DeckConfigsForUpdate> {
|
||||||
Ok(anki_proto::deckconfig::DeckConfigsForUpdate {
|
Ok(anki_proto::deck_config::DeckConfigsForUpdate {
|
||||||
all_config: self.get_deck_config_with_extra_for_update()?,
|
all_config: self.get_deck_config_with_extra_for_update()?,
|
||||||
current_deck: Some(self.get_current_deck_for_update(deck)?),
|
current_deck: Some(self.get_current_deck_for_update(deck)?),
|
||||||
defaults: Some(DeckConfig::default().into()),
|
defaults: Some(DeckConfig::default().into()),
|
||||||
|
|
|
@ -267,8 +267,8 @@ impl Collection {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use anki_proto::deckconfig::deck_config::config::NewCardGatherPriority;
|
use anki_proto::deck_config::deck_config::config::NewCardGatherPriority;
|
||||||
use anki_proto::deckconfig::deck_config::config::NewCardSortOrder;
|
use anki_proto::deck_config::deck_config::config::NewCardSortOrder;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::card::CardQueue;
|
use crate::card::CardQueue;
|
||||||
|
|
|
@ -6,7 +6,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import {
|
import {
|
||||||
DeckConfig_Config_NewCardGatherPriority as GatherOrder,
|
DeckConfig_Config_NewCardGatherPriority as GatherOrder,
|
||||||
DeckConfig_Config_NewCardSortOrder as SortOrder,
|
DeckConfig_Config_NewCardSortOrder as SortOrder,
|
||||||
} from "@tslib/anki/deckconfig_pb";
|
} from "@tslib/anki/deck_config_pb";
|
||||||
import * as tr from "@tslib/ftl";
|
import * as tr from "@tslib/ftl";
|
||||||
import { HelpPage } from "@tslib/help-page";
|
import { HelpPage } from "@tslib/help-page";
|
||||||
import type Carousel from "bootstrap/js/dist/carousel";
|
import type Carousel from "bootstrap/js/dist/carousel";
|
||||||
|
|
|
@ -3,7 +3,7 @@ Copyright: Ankitects Pty Ltd and contributors
|
||||||
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DeckConfig_Config_NewCardInsertOrder } from "@tslib/anki/deckconfig_pb";
|
import { DeckConfig_Config_NewCardInsertOrder } from "@tslib/anki/deck_config_pb";
|
||||||
import * as tr from "@tslib/ftl";
|
import * as tr from "@tslib/ftl";
|
||||||
import { HelpPage } from "@tslib/help-page";
|
import { HelpPage } from "@tslib/help-page";
|
||||||
import type Carousel from "bootstrap/js/dist/carousel";
|
import type Carousel from "bootstrap/js/dist/carousel";
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { protoBase64 } from "@bufbuild/protobuf";
|
import { protoBase64 } from "@bufbuild/protobuf";
|
||||||
import { DeckConfig_Config_LeechAction, DeckConfigsForUpdate } from "@tslib/anki/deckconfig_pb";
|
import { DeckConfig_Config_LeechAction, DeckConfigsForUpdate } from "@tslib/anki/deck_config_pb";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
|
|
||||||
import { DeckOptionsState } from "./lib";
|
import { DeckOptionsState } from "./lib";
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import type { PlainMessage } from "@bufbuild/protobuf";
|
import type { PlainMessage } from "@bufbuild/protobuf";
|
||||||
import { updateDeckConfigs } from "@tslib/anki/deck_config_service";
|
|
||||||
import type {
|
import type {
|
||||||
DeckConfigsForUpdate,
|
DeckConfigsForUpdate,
|
||||||
DeckConfigsForUpdate_CurrentDeck,
|
DeckConfigsForUpdate_CurrentDeck,
|
||||||
UpdateDeckConfigsRequest,
|
UpdateDeckConfigsRequest,
|
||||||
} from "@tslib/anki/deckconfig_pb";
|
} from "@tslib/anki/deck_config_pb";
|
||||||
import { DeckConfig, DeckConfig_Config, DeckConfigsForUpdate_CurrentDeck_Limits } from "@tslib/anki/deckconfig_pb";
|
import { DeckConfig, DeckConfig_Config, DeckConfigsForUpdate_CurrentDeck_Limits } from "@tslib/anki/deck_config_pb";
|
||||||
|
import { updateDeckConfigs } from "@tslib/anki/deck_config_service";
|
||||||
import { localeCompare } from "@tslib/i18n";
|
import { localeCompare } from "@tslib/i18n";
|
||||||
import { cloneDeep, isEqual } from "lodash-es";
|
import { cloneDeep, isEqual } from "lodash-es";
|
||||||
import type { Readable, Writable } from "svelte/store";
|
import type { Readable, Writable } from "svelte/store";
|
||||||
|
|
Loading…
Reference in a new issue