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 BB7C91FF17E for ; Thu, 30 Oct 2025 08:59:19 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E979519EEC; Thu, 30 Oct 2025 08:59:53 +0100 (CET) MIME-Version: 1.0 Date: Thu, 30 Oct 2025 07:59:48 +0000 In-Reply-To: <20251029143617.18134-1-d.csapak@proxmox.com> References: <20251029143617.18134-1-d.csapak@proxmox.com> X-Mailer: BlueMind-MailApp-v5 Message-ID: From: Dietmar Maurer To: Yew framework devel list at Proxmox X-Bm-Parsing-Options: encoded-parts X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761811176339 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.316 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 HTML_MESSAGE 0.001 HTML included in message KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com] Subject: [yew-devel] applied: [RFC PATCH yew-widget-toolkit] catalog loader: defer first content rendering after language is loaded X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Content-Type: multipart/mixed; boundary="===============3742706440620134567==" Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" --===============3742706440620134567== Content-Type: multipart/alternative; boundary="-=Part.4df2.a0e0aaeb279fb76e.19a34211528.418a25e1c5ac4cc=-" ---=Part.4df2.a0e0aaeb279fb76e.19a34211528.418a25e1c5ac4cc=- Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable applied On Wednesday, 10/29/2025, 15:36, Dominik Csapak = wrote: >From : Dominik Csapak Sent on : Wednesday, 10/29/2025, 15:36 To : yew-devel@lists=2Eproxmox=2Ecom Subject : [yew-devel] [RFC PATCH yew-widget-toolkit] catalog loader: defer= first content rendering after language is loaded Currently, whenever the catalog loader tries to load a language, it will empty out the content once, iow=2E render an empty body and then the actual content again=2E This means that all sub components are recreated and lose their state=2E When changing between languages this is necessary, since otherwise already rendered text will not be rerendered with the new language=2E On first page load on the other hand, rendering once in the default language and then immediately in the target language (even if it's also the default language) does not make much sense, since * most of the time the language catalog is rather small =C2=A0(e=2Eg=2E pdm german mo file is ~75KiB), so the initial rendering i= s immediately =C2=A0lost and rerendered * even if the language would take longer to load, displaying it for a =C2=A0relatively short time in the wrong language is not helpful=2E * doing anything in a 'create' method of components that should only run =C2=A0once, cannot be done in a way that retains some info about it=2E Fo= r =C2=A0example the PMG mobile gui that tries to do some action from the GE= T =C2=A0parameters, but only once (including removing the GET parameters)= =2E =C2=A0That can work, but we can't show any popup/snackbar then since the =C2=A0language loaded in the meantime and we have no knowledge that we di= d =C2=A0such an action=2E To fix this, render nothing until any language was at least loaded once=2E On our older ExtJS GUIs, the server determines the language with a cookie and the index has the link in the section of the html=2E This will block the javascript execution until that loaded, so this solution here mimics the behavior on our ExtJS GUIs=2E Signed-off-by: Dominik Csapak --- src/widget/catalog_loader=2Ers | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/widget/catalog_loader=2Ers b/src/widget/catalog_loader=2E= rs index b346838=2E=2Ec32619d 100644 --- a/src/widget/catalog_loader=2Ers +++ b/src/widget/catalog_loader=2Ers @@ -79,6 +79,7 @@ pub struct PwtCatalogLoader { =C2=A0 =C2=A0 lang: String, =C2=A0 =C2=A0 last_url: String, =C2=A0 =C2=A0 state: LoadState, + =C2=A0 =C2=A0loaded_once: bool, } =20 impl Component for PwtCatalogLoader { @@ -101,6 +102,7 @@ impl Component for PwtCatalogLoader { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 last_url: String::new(), =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 state: LoadState::Idle, =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 _observer, + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0loaded_once: false, =C2=A0 =C2=A0 =C2=A0 =C2=A0 } =C2=A0 =C2=A0 } =20 @@ -115,6 +117,7 @@ impl Component for PwtCatalogLoader { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } else { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 log= ::warn!("could not load language info for '{}'", self=2Elang); =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0self=2Eloaded_onc= e =3D true; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self=2Estate =3D = LoadState::Idle; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 true =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } @@ -144,7 +147,7 @@ impl Component for PwtCatalogLoader { =C2=A0 =C2=A0 fn view(&self, ctx: &yew::Context) -> yew::Html { =C2=A0 =C2=A0 =C2=A0 =C2=A0 let props =3D ctx=2Eprops(); =20 - =C2=A0 =C2=A0 =C2=A0 =C2=A0if matches!(self=2Estate, LoadState::LoadFini= shed(_)) { + =C2=A0 =C2=A0 =C2=A0 =C2=A0if !self=2Eloaded_once || matches!(self=2Esta= te, LoadState::LoadFinished(_)) { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 html! {} =C2=A0 =C2=A0 =C2=A0 =C2=A0 } else { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 html! {props=2Ebody=2Eclone()} --=20 2=2E47=2E3 _______________________________________________ yew-devel mailing list yew-devel@lists=2Eproxmox=2Ecom https://lists=2Eproxmox=2Ecom/cgi-bin/mailman/listinfo/yew-devel ---=Part.4df2.a0e0aaeb279fb76e.19a34211528.418a25e1c5ac4cc=- Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
applied

On Wednesday, 10/29/2025, 15:36, Dominik Csapak <d=2Ecsapak@proxmo= x=2Ecom> wrote:

From  : Dominik Csapa= k <d=2Ecsapak@proxmox=2Ecom>
Sen= t on  : Wednesday, 10/29/2025, 15:36
To : yew-devel@lists=2Eproxmox=2Ecom
Subject : [yew-devel] [RFC PATCH yew-wid= get-toolkit] catalog loader: defer first content rendering after language i= s loaded

Currently, whenever the catalog loader tries to l= oad a language, it will empty out the content once, iow=2E render an empty = body and then the actual content again=2E This means that all sub component= s are recreated and lose their state=2E When changing between languages th= is is necessary, since otherwise already rendered text will not be rerender= ed with the new language=2E On first page load on the other hand, renderin= g once in the default language and then immediately in the target language = (even if it's also the default language) does not make much sense, since * = most of the time the language catalog is rather small  (e=2Eg=2E pdm = german mo file is ~75KiB), so the initial rendering is immediately  l= ost and rerendered * even if the language would take longer to load, displa= ying it for a  relatively short time in the wrong language is not hel= pful=2E * doing anything in a 'create' method of components that should onl= y run  once, cannot be done in a way that retains some info about it= =2E For  example the PMG mobile gui that tries to do some action from= the GET  parameters, but only once (including removing the GET param= eters)=2E  That can work, but we can't show any popup/snackbar then s= ince the  language loaded in the meantime and we have no knowledge th= at we did  such an action=2E To fix this, render nothing until any l= anguage was at least loaded once=2E On our older ExtJS GUIs, the server de= termines the language with a cookie and the index has the link in the <h= ead> section of the html=2E This will block the javascript execution unt= il that loaded, so this solution here mimics the behavior on our ExtJS GUIs= =2E Signed-off-by: Dominik Csapak <d=2Ecsapak@proxmox=2Ecom&= gt; --- src/widget/catalog_loader=2Ers | 5 ++++- 1 file changed, 4 insert= ions(+), 1 deletion(-) diff --git a/src/widget/catalog_loader=2Ers b/src/w= idget/catalog_loader=2Ers index b346838=2E=2Ec32619d 100644 --- a/src/widge= t/catalog_loader=2Ers +++ b/src/widget/catalog_loader=2Ers @@ -79,6 +79,7 @= @ pub struct PwtCatalogLoader {     lang: String,    = last_url: String,     state: LoadState, +    loaded_o= nce: bool, } impl Component for PwtCatalogLoader { @@ -101,6 +102,7 @@ = impl Component for PwtCatalogLoader {           &= nbsp; last_url: String::new(),             s= tate: LoadState::Idle,             _observer= , +            loaded_once: false,   &n= bsp;     }     } @@ -115,6 +117,7 @@ impl Component = for PwtCatalogLoader {               &n= bsp; } else {                 &nbs= p;   log::warn!("could not load language info for '{}'", self=2Elang);=                 } +    =            self=2Eloaded_once =3D true; &nb= sp;               self=2Estate =3D LoadS= tate::Idle;                 true =             } @@ -144,7 +147,7 @@ impl Compon= ent for PwtCatalogLoader {     fn view(&self, ctx: &yew:= :Context<Self>) -> yew::Html {         let pr= ops =3D ctx=2Eprops(); -        if matches!(self=2Est= ate, LoadState::LoadFinished(_)) { +        if !self=2E= loaded_once || matches!(self=2Estate, LoadState::LoadFinished(_)) {  =           html! {}         }= else {             html! {props=2Ebody=2Ecl= one()} -- 2=2E47=2E3 _______________________________________________ ye= w-devel mailing list yew-devel@lists=2Eproxmox=2Ecom https://lists=2Eproxmox=2Ecom/cgi-bin/m= ailman/listinfo/yew-devel

---=Part.4df2.a0e0aaeb279fb76e.19a34211528.418a25e1c5ac4cc=--- --===============3742706440620134567== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel --===============3742706440620134567==--