Add profile sync policy controls
This commit is contained in:
@@ -38,7 +38,7 @@ pub use plugin::{
|
||||
PluginSignature, PluginSignatureAlgorithm,
|
||||
};
|
||||
pub use privacy::HistoryRecordingPolicy;
|
||||
pub use profile::{Profile, ProfileKind};
|
||||
pub use profile::{Profile, ProfileKind, ProfileSyncPolicy};
|
||||
pub use reading_list::{ReadingListEntry, ReadingProgress};
|
||||
pub use search::SearchEngine;
|
||||
pub use site_permission::{
|
||||
|
||||
@@ -6,6 +6,39 @@ pub enum ProfileKind {
|
||||
Private,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
pub enum ProfileSyncPolicy {
|
||||
#[default]
|
||||
Enabled,
|
||||
Paused,
|
||||
}
|
||||
|
||||
impl ProfileSyncPolicy {
|
||||
#[must_use]
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
Self::Enabled => "Sync on",
|
||||
Self::Paused => "Sync paused",
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn action_label(self) -> &'static str {
|
||||
match self {
|
||||
Self::Enabled => "Pause Sync",
|
||||
Self::Paused => "Resume Sync",
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn toggled(self) -> Self {
|
||||
match self {
|
||||
Self::Enabled => Self::Paused,
|
||||
Self::Paused => Self::Enabled,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct Profile {
|
||||
id: ProfileId,
|
||||
@@ -13,6 +46,7 @@ pub struct Profile {
|
||||
color_hex: u32,
|
||||
kind: ProfileKind,
|
||||
download_policy: DownloadPolicy,
|
||||
sync_policy: ProfileSyncPolicy,
|
||||
}
|
||||
|
||||
impl Profile {
|
||||
@@ -24,6 +58,7 @@ impl Profile {
|
||||
color_hex,
|
||||
kind,
|
||||
download_policy: DownloadPolicy::ask_every_time(),
|
||||
sync_policy: ProfileSyncPolicy::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +87,16 @@ impl Profile {
|
||||
&self.download_policy
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn sync_policy(&self) -> ProfileSyncPolicy {
|
||||
self.sync_policy
|
||||
}
|
||||
|
||||
pub fn set_download_policy(&mut self, download_policy: DownloadPolicy) {
|
||||
self.download_policy = download_policy;
|
||||
}
|
||||
|
||||
pub fn set_sync_policy(&mut self, sync_policy: ProfileSyncPolicy) {
|
||||
self.sync_policy = sync_policy;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user