1use crate::i18n::{tr, Locale, MessageKey};
9
10#[derive(Debug, Clone, PartialEq, Eq)]
13pub enum UserNotice {
14 DownloadDidNotFinish,
16 FolderCouldNotBeAdded,
17 SearchDidNotFinish,
18 FilesMovedOrMissing,
19 FolderAdded,
21 SearchReady,
22 PreviewsCleared,
23}
24
25impl UserNotice {
26 pub fn is_problem(&self) -> bool {
29 matches!(
30 self,
31 Self::DownloadDidNotFinish
32 | Self::FolderCouldNotBeAdded
33 | Self::SearchDidNotFinish
34 | Self::FilesMovedOrMissing
35 )
36 }
37
38 pub fn title(&self, locale: Locale) -> &'static str {
39 let key = match self {
40 Self::DownloadDidNotFinish => MessageKey::NoticeDownloadFailTitle,
41 Self::FolderCouldNotBeAdded => MessageKey::NoticeFolderFailTitle,
42 Self::SearchDidNotFinish => MessageKey::NoticeSearchFailTitle,
43 Self::FilesMovedOrMissing => MessageKey::NoticeFilesMissingTitle,
44 Self::FolderAdded => MessageKey::NoticeFolderAddedTitle,
45 Self::SearchReady => MessageKey::NoticeSearchReadyTitle,
46 Self::PreviewsCleared => MessageKey::NoticePreviewsClearedTitle,
47 };
48 tr(locale, key)
49 }
50
51 pub fn body(&self, locale: Locale) -> &'static str {
52 let key = match self {
53 Self::DownloadDidNotFinish => MessageKey::NoticeDownloadFailBody,
54 Self::FolderCouldNotBeAdded => MessageKey::NoticeFolderFailBody,
55 Self::SearchDidNotFinish => MessageKey::NoticeSearchFailBody,
56 Self::FilesMovedOrMissing => MessageKey::NoticeFilesMissingBody,
57 Self::FolderAdded => MessageKey::NoticeFolderAddedBody,
58 Self::SearchReady => MessageKey::NoticeSearchReadyBody,
59 Self::PreviewsCleared => MessageKey::NoticePreviewsClearedBody,
60 };
61 tr(locale, key)
62 }
63
64 pub fn action(&self, locale: Locale) -> Option<&'static str> {
67 let key = match self {
68 Self::DownloadDidNotFinish | Self::SearchDidNotFinish => MessageKey::NoticeActionTryAgain,
69 Self::FolderCouldNotBeAdded => MessageKey::NoticeActionChooseFolder,
70 Self::FilesMovedOrMissing => MessageKey::NoticeActionChooseFolder,
71 Self::FolderAdded | Self::SearchReady | Self::PreviewsCleared => return None,
72 };
73 Some(tr(locale, key))
74 }
75}