Skip to content

Commit

Permalink
Merge pull request #4 from Barre/remove_old_elementrs_request_pane_gui
Browse files Browse the repository at this point in the history
Keep only 500 requests in web frontend "requests" pane
  • Loading branch information
Barre authored May 10, 2022
2 parents 8c285f4 + 7f94baa commit 33fe1ff
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion web_frontend/src/requests.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::get_api_host;
use futures::future::{AbortHandle, Abortable};
use futures::StreamExt;
use reqwasm::websocket::futures::WebSocket;
use serde::Deserialize;
use wasm_bindgen_futures::spawn_local;
use yew::{html, Component, Context, Html};

use crate::get_api_host;
const MAX_REQUESTS_SHOWN: usize = 500;

#[derive(Deserialize)]
pub struct Message {
Expand Down Expand Up @@ -60,6 +61,8 @@ impl Component for Requests {
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool {
self.messages.insert(0, msg);

self.messages.truncate(MAX_REQUESTS_SHOWN);

// The server only sends new messages when there is actually
// new data.
true
Expand Down

0 comments on commit 33fe1ff

Please sign in to comment.