Strip/update dead code

This commit is contained in:
Mike Dilger 2022-12-24 16:42:37 +13:00
parent 7e18d33f71
commit 9f5f9b1a46
9 changed files with 2 additions and 47 deletions

View File

@ -10,7 +10,6 @@ pub struct About {
pub storage_path: String, pub storage_path: String,
} }
#[allow(dead_code)]
pub fn about() -> About { pub fn about() -> About {
let data_dir = match dirs::data_dir() { let data_dir = match dirs::data_dir() {
Some(mut d) => { Some(mut d) => {

View File

@ -10,7 +10,6 @@ pub struct DbEventHashtag {
} }
impl DbEventHashtag { impl DbEventHashtag {
#[allow(dead_code)]
pub async fn insert(&self) -> Result<(), Error> { pub async fn insert(&self) -> Result<(), Error> {
let event = self.event.clone(); let event = self.event.clone();
let hashtag = self.hashtag.clone(); let hashtag = self.hashtag.clone();

View File

@ -13,7 +13,6 @@ pub struct DbEventRelationship {
} }
impl DbEventRelationship { impl DbEventRelationship {
#[allow(dead_code)]
pub async fn insert(&self) -> Result<(), Error> { pub async fn insert(&self) -> Result<(), Error> {
let original = self.original.clone(); let original = self.original.clone();
let referring = self.referring.clone(); let referring = self.referring.clone();

View File

@ -135,7 +135,7 @@ impl DbPerson {
Ok(()) Ok(())
} }
#[allow(dead_code)] // Update metadata without clobbering anything else
pub async fn update_metadata( pub async fn update_metadata(
pubkey: PublicKeyHex, pubkey: PublicKeyHex,
metadata: Metadata, metadata: Metadata,

View File

@ -41,7 +41,6 @@ impl DbSetting {
output output
} }
#[allow(dead_code)]
pub async fn fetch_setting(key: &str) -> Result<Option<String>, Error> { pub async fn fetch_setting(key: &str) -> Result<Option<String>, Error> {
let db_settings = DbSetting::fetch(Some(&format!("key='{}'", key))).await?; let db_settings = DbSetting::fetch(Some(&format!("key='{}'", key))).await?;

View File

@ -1,6 +1,5 @@
use crate::comms::BusMessage; use crate::comms::BusMessage;
use crate::db::{DbPerson, DbPersonRelay, DbRelay}; use crate::db::{DbPerson, DbPersonRelay, DbRelay};
use crate::error::Error;
use crate::relationship::Relationship; use crate::relationship::Relationship;
use crate::settings::Settings; use crate::settings::Settings;
use async_recursion::async_recursion; use async_recursion::async_recursion;
@ -46,7 +45,6 @@ pub struct Globals {
pub people: Mutex<HashMap<PublicKey, DbPerson>>, pub people: Mutex<HashMap<PublicKey, DbPerson>>,
/// Whether or not we have a saved private key and need the password to unlock it /// Whether or not we have a saved private key and need the password to unlock it
#[allow(dead_code)]
pub need_password: AtomicBool, pub need_password: AtomicBool,
/// Settings /// Settings
@ -79,29 +77,6 @@ lazy_static! {
} }
impl Globals { impl Globals {
#[allow(dead_code)]
pub async fn get_feed(threaded: bool) -> Vec<Id> {
let feed: Vec<Event> = GLOBALS
.events
.lock()
.await
.iter()
.map(|(_, e)| e)
.filter(|e| e.kind == EventKind::TextNote)
.filter(|e| {
if threaded {
e.replies_to().is_none()
} else {
true
}
})
.cloned()
.collect();
Self::sort_feed(feed, threaded)
}
#[allow(dead_code)]
pub fn blocking_get_feed(threaded: bool) -> Vec<Id> { pub fn blocking_get_feed(threaded: bool) -> Vec<Id> {
let feed: Vec<Event> = GLOBALS let feed: Vec<Event> = GLOBALS
.events .events
@ -138,7 +113,6 @@ impl Globals {
feed.iter().map(|e| e.id).collect() feed.iter().map(|e| e.id).collect()
} }
#[allow(dead_code)]
pub async fn store_desired_event(id: Id, url: Option<Url>) { pub async fn store_desired_event(id: Id, url: Option<Url>) {
let mut desired_events = GLOBALS.desired_events.lock().await; let mut desired_events = GLOBALS.desired_events.lock().await;
desired_events desired_events
@ -151,7 +125,6 @@ impl Globals {
.or_insert_with(|| if let Some(u) = url { vec![u] } else { vec![] }); .or_insert_with(|| if let Some(u) = url { vec![u] } else { vec![] });
} }
#[allow(dead_code)]
pub async fn add_relationship(id: Id, related: Id, relationship: Relationship) { pub async fn add_relationship(id: Id, related: Id, relationship: Relationship) {
let r = (related, relationship); let r = (related, relationship);
let mut relationships = GLOBALS.relationships.lock().await; let mut relationships = GLOBALS.relationships.lock().await;
@ -165,7 +138,6 @@ impl Globals {
.or_insert_with(|| vec![r]); .or_insert_with(|| vec![r]);
} }
#[allow(dead_code)]
#[async_recursion] #[async_recursion]
pub async fn update_last_reply(id: Id, time: Unixtime) { pub async fn update_last_reply(id: Id, time: Unixtime) {
{ {
@ -228,17 +200,6 @@ impl Globals {
} }
} }
#[allow(dead_code)]
async fn save_person(pubkey: PublicKey) -> Result<(), Error> {
let mut people = GLOBALS.people.lock().await;
let person = people
.entry(pubkey)
.or_insert_with(|| DbPerson::new(pubkey.into()));
DbPerson::update(person.clone()).await?;
Ok(())
}
pub async fn followed_pubkeys() -> Vec<PublicKeyHex> { pub async fn followed_pubkeys() -> Vec<PublicKeyHex> {
let people = GLOBALS.people.lock().await; let people = GLOBALS.people.lock().await;
people people

View File

@ -6,7 +6,6 @@ use nostr_types::{Event, EventKind, Metadata, Unixtime, Url};
// This processes a new event, saving the results into the database // This processes a new event, saving the results into the database
// and also populating the GLOBALS maps. // and also populating the GLOBALS maps.
#[allow(dead_code)]
pub async fn process_new_event( pub async fn process_new_event(
event: &Event, event: &Event,
from_relay: bool, from_relay: bool,

View File

@ -1,8 +1,8 @@
/// A relationship between events /// A relationship between events
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
#[allow(dead_code)]
pub enum Relationship { pub enum Relationship {
Reply, Reply,
#[allow(dead_code)]
Quote, Quote,
Reaction(String), Reaction(String),
Deletion(String), Deletion(String),

View File

@ -67,7 +67,6 @@ impl Settings {
Ok(settings) Ok(settings)
} }
#[allow(dead_code)]
pub async fn save(&self) -> Result<(), Error> { pub async fn save(&self) -> Result<(), Error> {
let maybe_db = GLOBALS.db.lock().await; let maybe_db = GLOBALS.db.lock().await;
let db = maybe_db.as_ref().unwrap(); let db = maybe_db.as_ref().unwrap();