Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small fixes on listorders #57

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ pub async fn send_relays_requests(client: &Client, filters: Filter) -> Vec<Vec<E
for req in requests {
answers_requests.push(req.await.unwrap());
}

answers_requests
}

Expand Down Expand Up @@ -346,11 +347,15 @@ pub async fn get_orders_list(

// Get created at field from Nostr event
order.created_at = Some(ord.created_at.as_i64());

id_list.push(order.id.unwrap());
orders_list.push(order);
// Add only in case id of order is not present in the list (avoid duplicate)
if !id_list.contains(&order.id.unwrap()) {
id_list.push(order.id.unwrap());
orders_list.push(order);
}
}
}
// Return element sorted by second tuple element ( Timestamp )
orders_list.sort_by(|a, b| b.created_at.cmp(&a.created_at));

Ok(orders_list)
}
Expand Down
Loading