Jump to content

Message/alert/toast before UniApplication.Restart


neo4a

Recommended Posts

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.

Link to comment
Share on other sites

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;

 

Link to comment
Share on other sites

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;

 

  • Upvote 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by neo4a
added parameter modal for masked toast in desktop mode
Link to comment
Share on other sites

  • 2 months later...
  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...