Skip to content

Commit

Permalink
apply new formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
boxdot committed Feb 20, 2025
1 parent e145d9f commit 83c5956
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion benches/app.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::Path;

use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
use gurk::app::App;
use gurk::config::{Config, User};
use gurk::signal::test::SignalManagerMock;
Expand Down
2 changes: 1 addition & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ fn parse_keybindings(kbc: &KeybindingConfig) -> Result<Keybinding, CommandParseE
mod tests {
use toml;

use super::{get_keybindings, ModeKeybindingConfig, DEFAULT_KEYBINDINGS};
use super::{DEFAULT_KEYBINDINGS, ModeKeybindingConfig, get_keybindings};

#[test]
fn default_keybindings_deserialize() {
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{anyhow, bail, Context};
use anyhow::{Context, anyhow, bail};
use serde::{Deserialize, Serialize};
use url::Url;

Expand Down Expand Up @@ -270,7 +270,7 @@ fn default_true() -> bool {
#[cfg(test)]
mod tests {
use super::*;
use tempfile::{tempdir, NamedTempFile, TempDir};
use tempfile::{NamedTempFile, TempDir, tempdir};

fn example_user() -> User {
User {
Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Signal Messenger client for terminal
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::{Duration, Instant};

use anyhow::Context;
Expand All @@ -13,14 +13,14 @@ use crossterm::{
KeyEventKind, MouseButton, MouseEvent, MouseEventKind,
},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode},
};
use gurk::app::App;
use gurk::backoff::Backoff;
use gurk::storage::{sync_from_signal, JsonStorage, MemCache, SqliteStorage, Storage};
use gurk::storage::{JsonStorage, MemCache, SqliteStorage, Storage, sync_from_signal};
use gurk::{config, signal, ui};
use presage::libsignal_service::content::Content;
use ratatui::{backend::CrosstermBackend, Terminal};
use ratatui::{Terminal, backend::CrosstermBackend};
use tokio::select;
use tokio_stream::StreamExt;
use tokio_util::task::LocalPoolHandle;
Expand Down
2 changes: 1 addition & 1 deletion src/receipt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::hash_map::Entry;

use serde::{Deserialize, Serialize};
use tracing::error;
Expand Down
2 changes: 1 addition & 1 deletion src/signal/attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
use anyhow::Context;
use chrono::Local;
use mime_guess::mime::{APPLICATION_OCTET_STREAM, IMAGE_JPEG};
use mime_guess::{get_mime_extensions, Mime};
use mime_guess::{Mime, get_mime_extensions};
use presage::proto::AttachmentPointer;
use regex::Regex;
use tracing::info;
Expand Down
2 changes: 1 addition & 1 deletion src/signal/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::receipt::Receipt;
use crate::util::utc_now_timestamp_msec;

use super::{
attachment, Attachment, GroupMasterKeyBytes, ProfileKeyBytes, ResolvedGroup, SignalManager,
Attachment, GroupMasterKeyBytes, ProfileKeyBytes, ResolvedGroup, SignalManager, attachment,
};

pub(super) struct PresageManager {
Expand Down
9 changes: 6 additions & 3 deletions src/signal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod test;

use std::path::Path;

use anyhow::{anyhow, bail, Context as _};
use anyhow::{Context as _, anyhow, bail};
use futures_channel::oneshot;
use image::Luma;
use presage::{libsignal_service::configuration::SignalServers, model::identity::OnNewIdentity};
Expand All @@ -16,8 +16,8 @@ use url::Url;

use crate::config::{self, Config, DeprecatedConfigKey, LoadedConfig};

pub use self::manager::{Attachment, ResolvedGroup, SignalManager};
use self::r#impl::PresageManager;
pub use self::manager::{Attachment, ResolvedGroup, SignalManager};

// TODO: these should be either re-exported from presage/libsignal-service
const PROFILE_KEY_LEN: usize = 32;
Expand Down Expand Up @@ -79,7 +79,10 @@ pub async fn ensure_linked_device(
return Ok((Box::new(PresageManager::new(manager, local_pool)), config));
}
Err(e) => {
bail!("error loading manager. Try again later or run with --relink to force relink: {}", e)
bail!(
"error loading manager. Try again later or run with --relink to force relink: {}",
e
)
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/signal/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use presage::libsignal_service::prelude::AttachmentIdentifier;
use presage::libsignal_service::sender::AttachmentSpec;
use presage::model::contacts::Contact;
use presage::model::groups::Group;
use presage::proto::data_message::Quote;
use presage::proto::AttachmentPointer;
use presage::proto::data_message::Quote;
use tokio::sync::oneshot;
use tokio_stream::Stream;
use uuid::Uuid;
Expand Down
4 changes: 2 additions & 2 deletions src/storage/json.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::borrow::Cow;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::fs::File;
use std::io::{BufReader, BufWriter};
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -351,7 +351,7 @@ impl Storage for JsonStorage {
mod tests {
use chrono::{DateTime, Utc};
use tempfile::NamedTempFile;
use uuid::{uuid, Uuid};
use uuid::{Uuid, uuid};

use crate::data::TypingSet;

Expand Down
2 changes: 1 addition & 1 deletion src/storage/memcache.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::borrow::Cow;
use std::collections::btree_map::Entry;
use std::collections::BTreeMap;
use std::collections::btree_map::Entry;

use uuid::Uuid;

Expand Down
2 changes: 1 addition & 1 deletion src/storage/sql/encoding.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Encoding/decoding of types to/from Sql
use serde::de::DeserializeOwned;
use serde::Serialize;
use serde::de::DeserializeOwned;
use sqlx::encode::IsNull;
use sqlx::error::BoxDynError;
use sqlx::sqlite::SqliteValueRef;
Expand Down
4 changes: 2 additions & 2 deletions src/ui/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::fmt;

use chrono::Datelike;
use itertools::Itertools;
use ratatui::Frame;
use ratatui::text::{Line, Span, Text};
use ratatui::widgets::{Block, Borders, Clear, List, ListDirection, ListItem, Paragraph};
use ratatui::Frame;
use ratatui::{
layout::{Constraint, Direction, Layout, Rect},
widgets::Padding,
Expand All @@ -27,8 +27,8 @@ use crate::receipt::{Receipt, ReceiptEvent};
use crate::storage::MessageId;
use crate::util::utc_timestamp_msec_to_local;

use super::name_resolver::NameResolver;
use super::CHANNEL_VIEW_RATIO;
use super::name_resolver::NameResolver;

/// The main function drawing the UI for each frame
pub fn draw(f: &mut Frame, app: &mut App) {
Expand Down
9 changes: 2 additions & 7 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ impl<T> StatefulList<T> {
let i = match self.state.selected() {
Some(i) => {
if i + 1 >= self.items.len() {
if MESSAGE_SCROLL_BACK {
0
} else {
i
}
if MESSAGE_SCROLL_BACK { 0 } else { i }
} else {
i + 1
}
Expand Down Expand Up @@ -115,8 +111,7 @@ pub fn is_phone_number(s: impl AsRef<str>) -> bool {
}

// Based on Alacritty, APACHE-2.0 License
pub const URL_REGEX: &str =
"(ipfs:|ipns:|magnet:|mailto:|gemini:|gopher:|https:|http:|news:|file:|git:|ssh:|ftp:)\
pub const URL_REGEX: &str = "(ipfs:|ipns:|magnet:|mailto:|gemini:|gopher:|https:|http:|news:|file:|git:|ssh:|ftp:)\
[^\u{0000}-\u{001F}\u{007F}-\u{009F}<>\"\\s{-}\\^⟨⟩`]+";
pub const ATTACHMENT_REGEX: &str = "file:[^\u{0000}-\u{001F}\u{007F}-\u{009F}<>\"\\s{-}\\^⟨⟩`]+";

Expand Down

0 comments on commit 83c5956

Please sign in to comment.