Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: static template
✓ CI success Fintan Halpenny committed 7 months ago
commit e124bc0f68e1b44ab4eee60e0b42d12f7e5394de
parent a8107d460af69a44b04d5badc9541ef145b2c4dd
3 passed (3 total) View logs
1 file changed +9 -11
modified crates/radicle-term/src/spinner.rs
@@ -1,6 +1,6 @@
use std::io::IsTerminal;
use std::mem::ManuallyDrop;
-
use std::sync::{Arc, Mutex};
+
use std::sync::{Arc, LazyLock, Mutex};
use std::{fmt, io, thread, time};

use indicatif::{ProgressBar, ProgressDrawTarget, ProgressStyle};
@@ -16,6 +16,8 @@ pub const DEFAULT_STYLE: [Paint<&'static str>; 4] = [
    Paint::magenta("◤"),
    Paint::blue("◥"),
];
+
static TEMPLATE: LazyLock<ProgressStyle> =
+
    LazyLock::new(|| ProgressStyle::with_template("{spinner:.blue} {msg}").unwrap());

impl From<DrawTarget> for ProgressDrawTarget {
    fn from(value: DrawTarget) -> Self {
@@ -154,16 +156,12 @@ pub fn spinner_to(

            spinner.set_draw_target(progress_target.into());
            spinner.set_message(message.to_string());
-
            spinner.set_style(
-
                ProgressStyle::with_template("{spinner:.blue} {msg}")
-
                    .unwrap()
-
                    .tick_strings(&[
-
                        DEFAULT_STYLE[0].to_string().as_str(),
-
                        DEFAULT_STYLE[1].to_string().as_str(),
-
                        DEFAULT_STYLE[2].to_string().as_str(),
-
                        DEFAULT_STYLE[3].to_string().as_str(),
-
                    ]),
-
            );
+
            spinner.set_style(TEMPLATE.clone().tick_strings(&[
+
                DEFAULT_STYLE[0].to_string().as_str(),
+
                DEFAULT_STYLE[1].to_string().as_str(),
+
                DEFAULT_STYLE[2].to_string().as_str(),
+
                DEFAULT_STYLE[3].to_string().as_str(),
+
            ]));

            move || {
                loop {