neo4a Posted April 8, 2019 Share Posted April 8, 2019 How to show a message (or alert/toast) right now before UniSession.UniApplication.Restart to indicate and inform user that app is reloading. Need this for desktop and mobile environment as well. Thanks. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 8, 2019 Share Posted April 8, 2019 1. UniTimer1 Enabled = False Interval = 5000 RunOnce = True procedure TMainForm.UniTimer1Timer(Sender: TObject); begin UniApplication.Restart end; 2. Run procedure TMainForm.UniButton1Click(Sender: TObject); begin ShowMessage('The App will restart now'); UniTimer1.Enabled := True; end; Quote Link to comment Share on other sites More sharing options...
neo4a Posted April 8, 2019 Author Share Posted April 8, 2019 Thanks. Is there a way to display a message box only without any button? With other words: How do I run Ext.toast('Hello Sencha!'); within datamodule? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 8, 2019 Share Posted April 8, 2019 7 minutes ago, neo4a said: Is there a way to display a message box only without any button? procedure TMainForm.UniButton1Click(Sender: TObject); begin //ShowMessage('The App will restart now'); UniSession.AddJS('Ext.toast({html: "The App will restart now", header: false, autoCloseDelay: 5000});'); UniTimer1.Enabled := True; end; 1 Quote Link to comment Share on other sites More sharing options...
neo4a Posted April 8, 2019 Author Share Posted April 8, 2019 With the sample above I get 'undefined' as toast im mobile view of my app. What do I need to change? Thanks. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 8, 2019 Share Posted April 8, 2019 16 minutes ago, neo4a said: With the sample above I get 'undefined' as toast im mobile view of my app. What do I need to change? UniSession.AddJS('Ext.toast({message: "The App will restart now", timeout: 5000});'); Quote Link to comment Share on other sites More sharing options...
neo4a Posted April 8, 2019 Author Share Posted April 8, 2019 Ok. That works. But it seemed that Tuni(m)timer is not working within Mainmodule. procedure TUniMainModule.act_ReloadExecute(Sender: TObject); begin inherited; UniSession.addJS('Ext.Viewport.setMasked({xtype: ''loadmask'', message: ''Neustart''});'); if UniSession.ismobile then unimTimer1.enabled := True else uniTimer1.enabled := True; Tuni(m)timer.OnTimer is never executed. I'm trying to keep non visual things in datamodule. Quote Link to comment Share on other sites More sharing options...
neo4a Posted April 9, 2019 Author Share Posted April 9, 2019 (edited) FYI, this is my approach handling session restarting for desktop and mobile version in Mainmodule only: procedure TUniMainModule.act_ReloadExecute(Sender: TObject); var aTimer : TUniTimer; begin inherited; if UniSession.IsMobile then begin UniSession.addJS('Ext.Viewport.setMasked({xtype: ''loadmask'', message: ''Please be patient...''});'); UniSession.addJS('Ext.toast({message: "The App will restart now...", timeout: 5000});'); aTimer := TUnimTimer.Create(Masterform); end else begin UniSession.AddJS('Ext.toast({html: "The App will restart now...", header: false, autoCloseDelay: 5000, modal: true});'); aTimer := TUniTimer.Create(Masterform); end; with aTimer do begin Interval := 1000; RunOnce := True; OnTimer := DoRestartTimer; Enabled := True; end; end; procedure TUniMainModule.DoRestartTimer(Sender: TObject); begin UniSession.UniApplication.Restart; end; Edited April 9, 2019 by neo4a added parameter modal for masked toast in desktop mode Quote Link to comment Share on other sites More sharing options...
Uelson Cavalcante Posted June 11, 2019 Share Posted June 11, 2019 On 6/30/2017 at 5:18 PM, Ken_Sowyer said: Beleza! Vou dar uma olhada nas demos... Muito obrigado pela atenção! Toast como chamar ele com left? Quote Link to comment Share on other sites More sharing options...
yakup Posted March 2 Share Posted March 2 You can now use websocket for this issue. i do that 😉 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.