feat: new option to suppress 0.4 deprecation warnings (#2027)

This commit is contained in:
三咲雅 · Misaki Masa 2024-12-11 17:38:43 +08:00 committed by GitHub
parent 61cab0f30a
commit ccf466d881
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View file

@ -26,6 +26,10 @@ pub struct Manager {
pub scrolloff: u8,
pub mouse_events: MouseEvents,
pub title_format: String,
// TODO: remove this in Yazi 0.4.2
#[serde(default)]
pub _v4_suppress_deprecation_warnings: bool,
}
impl FromStr for Manager {

View file

@ -18,10 +18,9 @@ impl<T: Into<yazi_fs::Cha>> From<T> for Cha {
fn from(cha: T) -> Self { Self(cha.into()) }
}
static WARNED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
#[inline]
fn warn_deprecated(id: Option<&str>) {
static WARNED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
if !WARNED.swap(true, std::sync::atomic::Ordering::Relaxed) {
let id = match id {
Some(id) => format!("`{id}.yazi` plugin"),

View file

@ -1,6 +1,7 @@
use std::time::Duration;
use tokio::sync::oneshot;
use yazi_config::MANAGER;
use yazi_macro::emit;
use yazi_shared::{Layer, event::Cmd};
@ -23,6 +24,10 @@ impl AppProxy {
#[inline]
pub fn notify(opt: NotifyOpt) {
if MANAGER._v4_suppress_deprecation_warnings && opt.title.contains("Deprecated") {
return;
}
emit!(Call(Cmd::new("notify").with_any("option", opt), Layer::App));
}