Split next_id() logic into function
This commit is contained in:
parent
cf94792f12
commit
9e8ce5f8d9
1 changed files with 9 additions and 7 deletions
|
|
@ -74,6 +74,14 @@ impl Notifications {
|
||||||
notifications
|
notifications
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn next_id(&self) -> NonZeroU32 {
|
||||||
|
let mut next_id = self.next_id.lock().unwrap();
|
||||||
|
let id = *next_id;
|
||||||
|
*next_id = NonZeroU32::new(u32::from(*next_id).wrapping_add(1))
|
||||||
|
.unwrap_or(NonZeroU32::new(1).unwrap());
|
||||||
|
id
|
||||||
|
}
|
||||||
|
|
||||||
fn notify(
|
fn notify(
|
||||||
&self,
|
&self,
|
||||||
_app_name: String,
|
_app_name: String,
|
||||||
|
|
@ -85,13 +93,7 @@ impl Notifications {
|
||||||
_hints: HashMap<String, glib::Variant>,
|
_hints: HashMap<String, glib::Variant>,
|
||||||
_expire_timeout: i32,
|
_expire_timeout: i32,
|
||||||
) -> NonZeroU32 {
|
) -> NonZeroU32 {
|
||||||
let id = replaces_id.unwrap_or_else(|| {
|
let id = replaces_id.unwrap_or_else(|| self.next_id());
|
||||||
let mut next_id = self.next_id.lock().unwrap();
|
|
||||||
let id = *next_id;
|
|
||||||
*next_id = NonZeroU32::new(u32::from(*next_id).wrapping_add(1))
|
|
||||||
.unwrap_or(NonZeroU32::new(1).unwrap());
|
|
||||||
id
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue