Skip to content

Commit 15594b3

Browse files
authored
Recalculate the issues on language changes (#3262)
## Problem When the language changes, the issues are not updated to the new language. ## Solution * Add a `SetLocale` message to each service. * Recalculate the issues when changing the language. ## Open questions * Should we keep the SetLocale messages in those services where it is a no-op? * At some point, we should unify the `SetLocale` and `SetConfig<T>` messages. Not as part of this PR, though. ## Testing - Tested manually
2 parents 7a34d0d + e0efdb6 commit 15594b3

File tree

26 files changed

+296
-16
lines changed

26 files changed

+296
-16
lines changed

rust/agama-bootloader/src/message.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,20 @@ impl SetKernelArg {
6060
Self { id, value }
6161
}
6262
}
63+
64+
#[derive(Clone)]
65+
pub struct SetLocale {
66+
pub locale: String,
67+
}
68+
69+
impl SetLocale {
70+
pub fn new(locale: &str) -> Self {
71+
Self {
72+
locale: locale.to_string(),
73+
}
74+
}
75+
}
76+
77+
impl Message for SetLocale {
78+
type Reply = ();
79+
}

rust/agama-bootloader/src/service.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,10 @@ impl MessageHandler<message::SetKernelArg> for Service {
122122
Ok(())
123123
}
124124
}
125+
126+
#[async_trait]
127+
impl MessageHandler<message::SetLocale> for Service {
128+
async fn handle(&mut self, _message: message::SetLocale) -> Result<(), Error> {
129+
Ok(())
130+
}
131+
}

rust/agama-files/src/message.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,20 @@ pub struct WriteFiles;
6767
impl Message for WriteFiles {
6868
type Reply = ();
6969
}
70+
71+
#[derive(Clone)]
72+
pub struct SetLocale {
73+
pub locale: String,
74+
}
75+
76+
impl SetLocale {
77+
pub fn new(locale: &str) -> Self {
78+
Self {
79+
locale: locale.to_string(),
80+
}
81+
}
82+
}
83+
84+
impl Message for SetLocale {
85+
type Reply = ();
86+
}

rust/agama-files/src/service.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,10 @@ impl MessageHandler<message::WriteFiles> for Service {
244244
Ok(())
245245
}
246246
}
247+
248+
#[async_trait]
249+
impl MessageHandler<message::SetLocale> for Service {
250+
async fn handle(&mut self, _message: message::SetLocale) -> Result<(), Error> {
251+
Ok(())
252+
}
253+
}

rust/agama-hostname/src/message.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,20 @@ pub struct Install;
9797
impl Message for Install {
9898
type Reply = ();
9999
}
100+
101+
#[derive(Clone)]
102+
pub struct SetLocale {
103+
pub locale: String,
104+
}
105+
106+
impl SetLocale {
107+
pub fn new(locale: &str) -> Self {
108+
Self {
109+
locale: locale.to_string(),
110+
}
111+
}
112+
}
113+
114+
impl Message for SetLocale {
115+
type Reply = ();
116+
}

rust/agama-hostname/src/service.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,10 @@ impl MessageHandler<message::Install> for Service {
274274
self.model.install()
275275
}
276276
}
277+
278+
#[async_trait]
279+
impl MessageHandler<message::SetLocale> for Service {
280+
async fn handle(&mut self, _message: message::SetLocale) -> Result<(), Error> {
281+
Ok(())
282+
}
283+
}

rust/agama-iscsi/src/message.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,20 @@ impl SetConfig {
6464
impl Message for SetConfig {
6565
type Reply = ();
6666
}
67+
68+
#[derive(Clone)]
69+
pub struct SetLocale {
70+
pub locale: String,
71+
}
72+
73+
impl SetLocale {
74+
pub fn new(locale: &str) -> Self {
75+
Self {
76+
locale: locale.to_string(),
77+
}
78+
}
79+
}
80+
81+
impl Message for SetLocale {
82+
type Reply = ();
83+
}

rust/agama-iscsi/src/service.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,10 @@ impl MessageHandler<message::SetConfig> for Service {
143143
Ok(())
144144
}
145145
}
146+
147+
#[async_trait]
148+
impl MessageHandler<message::SetLocale> for Service {
149+
async fn handle(&mut self, _message: message::SetLocale) -> Result<(), Error> {
150+
Ok(())
151+
}
152+
}

rust/agama-manager/src/service.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,15 @@ impl Service {
508508
.call(l10n::message::SetSystem::new(config.clone()))
509509
.await?;
510510
if let Some(locale) = config.locale {
511+
self.software
512+
.cast(software::message::SetLocale::new(locale.as_str()))?;
511513
self.storage
512514
.cast(storage::message::SetLocale::new(locale.as_str()))?;
515+
self.users
516+
.cast(users::message::SetLocale::new(locale.as_str()))?;
517+
if let Some(s390) = &self.s390 {
518+
s390.cast(s390::message::SetLocale::new(locale.as_str()))?;
519+
}
513520
}
514521
Ok(())
515522
}

rust/agama-network/src/action.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,6 @@ pub enum Action {
9696
RemoveConnection(String, Responder<Result<(), NetworkStateError>>),
9797
/// Apply the current configuration.
9898
Apply(Responder<Result<(), NetworkAdapterError>>),
99+
/// Sets the locale
100+
SetLocale(String),
99101
}

0 commit comments

Comments
 (0)