mirror of
https://github.com/luminous-devs/lume.git
synced 2024-10-01 09:21:07 +00:00
chore: Remove unused modules and update metadata.rs (#199)
This commit is contained in:
parent
921cf871ee
commit
c682a58842
@ -1,3 +1,4 @@
|
||||
use super::get_latest_event;
|
||||
use crate::Nostr;
|
||||
use keyring::Entry;
|
||||
use nostr_sdk::prelude::*;
|
||||
@ -88,7 +89,7 @@ pub async fn get_current_user_profile(state: State<'_, Nostr>) -> Result<String,
|
||||
.await
|
||||
{
|
||||
Ok(events) => {
|
||||
if let Some(event) = events.first() {
|
||||
if let Some(event) = get_latest_event(&events) {
|
||||
if let Ok(metadata) = Metadata::from_json(&event.content) {
|
||||
Ok(metadata.as_json())
|
||||
} else {
|
||||
|
@ -2,3 +2,5 @@ pub mod event;
|
||||
pub mod keys;
|
||||
pub mod metadata;
|
||||
pub mod relay;
|
||||
mod utils;
|
||||
pub use utils::get_latest_event;
|
5
src-tauri/src/nostr/utils.rs
Normal file
5
src-tauri/src/nostr/utils.rs
Normal file
@ -0,0 +1,5 @@
|
||||
use nostr_sdk::Event;
|
||||
|
||||
pub fn get_latest_event(events: &[Event]) -> Option<&Event> {
|
||||
events.iter().max_by_key(|event| event.created_at())
|
||||
}
|
Loading…
Reference in New Issue
Block a user