From 81d666557b965657afb96875401e2d78f5566c0f Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Sun, 16 Apr 2023 18:23:56 +0800 Subject: [PATCH] chore: clean code. --- src-tauri/src/ambient_light/publisher.rs | 10 ++------ src-tauri/src/main.rs | 7 +----- src-tauri/src/screenshot_manager.rs | 31 +++++++----------------- 3 files changed, 12 insertions(+), 36 deletions(-) diff --git a/src-tauri/src/ambient_light/publisher.rs b/src-tauri/src/ambient_light/publisher.rs index 1651ddc..a42d45e 100644 --- a/src-tauri/src/ambient_light/publisher.rs +++ b/src-tauri/src/ambient_light/publisher.rs @@ -16,7 +16,7 @@ use crate::{ use itertools::Itertools; -use super::{LedStripConfigGroup, SamplePointConfig, SamplePointMapper}; +use super::{LedStripConfigGroup, SamplePointMapper}; pub struct LedColorsPublisher { sorted_colors_rx: Arc>>>, @@ -68,7 +68,6 @@ impl LedColorsPublisher { return; } - let mut start: tokio::time::Instant = tokio::time::Instant::now(); let mut interval = tokio::time::interval(Duration::from_millis(66)); let init_version = internal_tasks_version.read().await.clone(); @@ -88,8 +87,6 @@ impl LedColorsPublisher { break; } - // log::info!("tick: {}ms", start.elapsed().as_millis()); - start = tokio::time::Instant::now(); let colors = screenshot_manager::get_display_colors( display_id, &sample_points, @@ -104,7 +101,7 @@ impl LedColorsPublisher { let colors = colors.unwrap(); - let color_len = colors.len(); + // let color_len = colors.len(); match display_colors_tx.send(( display_id, @@ -265,11 +262,8 @@ impl LedColorsPublisher { let colors = rx.borrow().clone(); - let len = colors.len(); - match Self::send_colors(colors).await { Ok(_) => { - // log::info!("colors sent. len: {}", len); } Err(err) => { warn!("colors send failed: {}", err); diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index e2270c9..6841223 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -8,12 +8,7 @@ mod rpc; pub mod screenshot; mod screenshot_manager; -use ambient_light::{ - Border, ColorCalibration, LedColorsPublisher, LedStripConfig, LedStripConfigGroup, -}; -use core_graphics::display::{ - kCGNullWindowID, kCGWindowImageDefault, kCGWindowListOptionOnScreenOnly, CGDisplay, -}; +use ambient_light::{Border, ColorCalibration, LedStripConfig, LedStripConfigGroup}; use display_info::DisplayInfo; use paris::{error, info, warn}; use screenshot::Screenshot; diff --git a/src-tauri/src/screenshot_manager.rs b/src-tauri/src/screenshot_manager.rs index 05c7c1d..3d0c9e3 100644 --- a/src-tauri/src/screenshot_manager.rs +++ b/src-tauri/src/screenshot_manager.rs @@ -10,11 +10,7 @@ use tokio::sync::{broadcast, watch, OnceCell}; use tokio::time::{self, Duration}; use crate::screenshot::LedSamplePoints; -use crate::{ - ambient_light::SamplePointMapper, - led_color::LedColor, - screenshot::Screenshot, -}; +use crate::{ambient_light::SamplePointMapper, led_color::LedColor, screenshot::Screenshot}; pub fn take_screenshot(display_id: u32, scale_factor: f32) -> anyhow::Result { log::debug!("take_screenshot"); @@ -36,7 +32,6 @@ pub fn take_screenshot(display_id: u32, scale_factor: f32) -> anyhow::Result anyhow::Result { - log::info!("take_screenshot_loop: merged_screenshot_tx.send success. display#{}", display_id); + log::info!( + "take_screenshot_loop: merged_screenshot_tx.send success. display#{}", + display_id + ); } - Err(err) => { - // warn!("take_screenshot_loop: merged_screenshot_tx.send failed. display#{}. err: {}", display_id, err); + Err(_) => { } } screenshot_tx.send(screenshot).unwrap();