Simplify compositor and shell conditionals
Flatten nested guards in swipe cleanup, recording updates and popup dismissal. Use an eager optional fallback for workspace layouts and an array in the malformed-opacity test.
This commit is contained in:
1 parent
3ba1f3522d
commit
5706a71941
5 files changed
+8
-10
No files matched your search
@@ -590,7 +590,7 @@ mod tests {
|
|||||||
assert_eq!(decode_region_opacities(&[]), Some(vec![]));
|
assert_eq!(decode_region_opacities(&[]), Some(vec![]));
|
||||||
assert!(decode_region_opacities(&bytes[..11]).is_none());
|
assert!(decode_region_opacities(&bytes[..11]).is_none());
|
||||||
assert!(decode_region_opacities(&1001u32.to_ne_bytes()).is_none());
|
assert!(decode_region_opacities(&1001u32.to_ne_bytes()).is_none());
|
||||||
assert!(decode_region_opacities(&vec![0; 33 * 4]).is_none());
|
assert!(decode_region_opacities(&[0; 33 * 4]).is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -160,13 +160,12 @@ impl Ferese {
|
|||||||
.focus_swipe
|
.focus_swipe
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.is_some_and(|swipe| !self.focus_swipe_is_current(swipe))
|
.is_some_and(|swipe| !self.focus_swipe_is_current(swipe))
|
||||||
|
&& let Some(swipe) = self.focus_swipe.take()
|
||||||
{
|
{
|
||||||
if let Some(swipe) = self.focus_swipe.take() {
|
|
||||||
self.presentation_dependencies
|
self.presentation_dependencies
|
||||||
.restore_viewport(swipe.workspace, swipe.dependencies);
|
.restore_viewport(swipe.workspace, swipe.dependencies);
|
||||||
self.release_presentation_dependencies();
|
self.release_presentation_dependencies();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let mut active_animation = false;
|
let mut active_animation = false;
|
||||||
let mut completed_slides = Vec::new();
|
let mut completed_slides = Vec::new();
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ impl Ferese {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.filter(|swipe| swipe.workspace == workspace.id)
|
.filter(|swipe| swipe.workspace == workspace.id)
|
||||||
.and_then(|swipe| swipe.layout.as_ref())
|
.and_then(|swipe| swipe.layout.as_ref())
|
||||||
.or_else(|| match &workspace.layout {
|
.or(match &workspace.layout {
|
||||||
WorkspaceLayout::Scrolling(layout) => Some(layout),
|
WorkspaceLayout::Scrolling(layout) => Some(layout),
|
||||||
_ => None,
|
_ => None,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -159,11 +159,9 @@ impl Recorder {
|
|||||||
match event {
|
match event {
|
||||||
Event::Update(update) => match update.state.as_str() {
|
Event::Update(update) => match update.state.as_str() {
|
||||||
"selecting" if self.control.is_some() => self.state = State::Selecting,
|
"selecting" if self.control.is_some() => self.state = State::Selecting,
|
||||||
"recording" if self.control.is_some() => {
|
"recording" if self.control.is_some() && !matches!(self.state, State::Recording(_)) => {
|
||||||
if !matches!(self.state, State::Recording(_)) {
|
|
||||||
self.state = State::Recording(Instant::now());
|
self.state = State::Recording(Instant::now());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
"saving" => self.state = State::Saving,
|
"saving" => self.state = State::Saving,
|
||||||
"saved" => {
|
"saved" => {
|
||||||
self.state = update
|
self.state = update
|
||||||
|
|||||||
@@ -153,11 +153,12 @@ impl FereseShell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn animate_menu(&mut self) -> Task<Message> {
|
pub fn animate_menu(&mut self) -> Task<Message> {
|
||||||
if let Some(menu) = &self.menu {
|
if let Some(menu) = &self.menu
|
||||||
if menu.motion.closing() && !menu.animating() {
|
&& menu.motion.closing()
|
||||||
|
&& !menu.animating()
|
||||||
|
{
|
||||||
return self.destroy_menu();
|
return self.destroy_menu();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user