From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 488E41FF141 for ; Tue, 02 Jun 2026 13:54:24 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5CACD11A0B; Tue, 2 Jun 2026 13:54:23 +0200 (CEST) From: Dominik Csapak To: pmg-devel@lists.proxmox.com Subject: [PATCH pmg-yew-quarantine-gui 2/3] spam list page: factor `link` out Date: Tue, 2 Jun 2026 13:53:41 +0200 Message-ID: <20260602115348.2333552-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260602115348.2333552-1-d.csapak@proxmox.com> References: <20260602115348.2333552-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.049 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: HOPJPLWXGFOCYYTVLXBMNBUTPZXD7IIX X-Message-ID-Hash: HOPJPLWXGFOCYYTVLXBMNBUTPZXD7IIX X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: no reason to call `ctx.link()` every time, just do that once at the beginning of the `view` method. Is faster and makes the code a bit shorter. Signed-off-by: Dominik Csapak --- src/page_spam_list.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/page_spam_list.rs b/src/page_spam_list.rs index 58d2541..5a3dacd 100644 --- a/src/page_spam_list.rs +++ b/src/page_spam_list.rs @@ -208,17 +208,18 @@ impl Component for PmgPageSpamList { } fn view(&self, ctx: &Context) -> Html { + let link = ctx.link(); let content = SpamList::new() .starttime((self.start_date / 1000.0) as u64) .endtime((self.end_date / 1000.0) as u64) - .on_preview(ctx.link().callback(Msg::Preview)); + .on_preview(link.callback(Msg::Preview)); let dialog = match self.state { ViewState::Normal => None, ViewState::ShowDialog => Some( Dialog::new(tr!("Select Date")) .with_child(self.date_range_form(ctx)) - .on_close(ctx.link().callback(|_| Msg::CloseDialog)), + .on_close(link.callback(|_| Msg::CloseDialog)), ), ViewState::ShowSubscriptionNotice => Some( Dialog::new(tr!("No valid subscription")) @@ -230,11 +231,11 @@ impl Component for PmgPageSpamList { .with_child( Row::new().class(JustifyContent::FlexEnd).with_child( Button::new(tr!("OK")) - .on_activate(ctx.link().callback(|_| Msg::CloseDialog)), + .on_activate(link.callback(|_| Msg::CloseDialog)), ), ), ) - .on_close(ctx.link().callback(|_| Msg::CloseDialog)), + .on_close(link.callback(|_| Msg::CloseDialog)), ), ViewState::ShowLanguageSelect => Some( Dialog::new(tr!("Select Language")) @@ -246,11 +247,11 @@ impl Component for PmgPageSpamList { .with_child(tr!("Language")) .with_child(LanguageSelector::new()), ) - .on_close(ctx.link().callback(|_| Msg::CloseDialog)), + .on_close(link.callback(|_| Msg::CloseDialog)), ), }; - let fab = Fab::new("fa fa-calendar").on_activate(ctx.link().callback(|_| Msg::ShowDialog)); + let fab = Fab::new("fa fa-calendar").on_activate(link.callback(|_| Msg::ShowDialog)); let sub_notice = match self.subscription_result { Some(true) | None => None, @@ -264,7 +265,7 @@ impl Component for PmgPageSpamList { Button::new(tr!("No valid subscription")) .icon_class("fa fa-exclamation-triangle") .class("pwt-button-text") - .on_activate(ctx.link().callback(|_| Msg::ShowSubscriptionNotice)), + .on_activate(link.callback(|_| Msg::ShowSubscriptionNotice)), ), ), }; @@ -293,25 +294,21 @@ impl Component for PmgPageSpamList { MenuItem::new(tr!("Language")) .icon_class("fa fa-language") .on_select( - ctx.link() - .callback(|_| Msg::ShowLanguageSelect), + link.callback(|_| Msg::ShowLanguageSelect), ), ) .with_item( MenuItem::new(tr!("Switch to Desktop View")) .icon_class("fa fa-desktop") .on_select( - ctx.link() - .callback(|_| Msg::SwitchToDesktop), + link.callback(|_| Msg::SwitchToDesktop), ), ) .with_separator() .with_item( MenuItem::new(tr!("Logout")) .icon_class("fa fa-sign-out") - .on_select( - ctx.link().callback(|_| Msg::Logout), - ), + .on_select(link.callback(|_| Msg::Logout)), ), ), ), -- 2.47.3