From: Dominik Csapak <d.csapak@proxmox.com>
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 [thread overview]
Message-ID: <20260602115348.2333552-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260602115348.2333552-1-d.csapak@proxmox.com>
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 <d.csapak@proxmox.com>
---
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<Self>) -> 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
next prev parent reply other threads:[~2026-06-02 11:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 11:53 [PATCH pmg-yew-quarantine-gui/yew-comp 0/3] add about text to pmg mobile quarantine Dominik Csapak
2026-06-02 11:53 ` [PATCH yew-comp 1/3] markdown: correctly set css class Dominik Csapak
2026-06-02 11:53 ` Dominik Csapak [this message]
2026-06-02 11:53 ` [PATCH pmg-yew-quarantine-gui 3/3] spam list page: add 'about' button to menu Dominik Csapak
2026-06-02 20:50 ` applied: [PATCH pmg-yew-quarantine-gui/yew-comp 0/3] add about text to pmg mobile quarantine Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260602115348.2333552-3-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.