From 2467e1dd1fb9749ea8cb8ef7d2dd23ca39fb521f Mon Sep 17 00:00:00 2001 From: rc-swag <58423624+rc-swag@users.noreply.github.com> Date: Fri, 17 Jan 2025 17:20:10 +1000 Subject: [PATCH] feat(windows): check update use statemachine Also the first time remoteupdate check config runs it needs to return true if the 'last update time' registry entry does not exist. --- .../main/Keyman.System.RemoteUpdateCheck.pas | 5 ++--- windows/src/desktop/kmshell/main/UfrmMain.pas | 14 ++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/windows/src/desktop/kmshell/main/Keyman.System.RemoteUpdateCheck.pas b/windows/src/desktop/kmshell/main/Keyman.System.RemoteUpdateCheck.pas index df892929f0..55dde4eb1a 100644 --- a/windows/src/desktop/kmshell/main/Keyman.System.RemoteUpdateCheck.pas +++ b/windows/src/desktop/kmshell/main/Keyman.System.RemoteUpdateCheck.pas @@ -239,9 +239,8 @@ begin begin Exit; end; - if Registry.ValueExists(SRegValue_LastUpdateCheckTime) and - (Now - Registry.ReadDateTime(SRegValue_LastUpdateCheckTime) > - CheckPeriod) then + if (not Registry.ValueExists(SRegValue_LastUpdateCheckTime)) or + ((Now - Registry.ReadDateTime(SRegValue_LastUpdateCheckTime)) > CheckPeriod) then begin Result := True; end; diff --git a/windows/src/desktop/kmshell/main/UfrmMain.pas b/windows/src/desktop/kmshell/main/UfrmMain.pas index 86df47ec70..394cb09377 100644 --- a/windows/src/desktop/kmshell/main/UfrmMain.pas +++ b/windows/src/desktop/kmshell/main/UfrmMain.pas @@ -188,7 +188,7 @@ uses MessageIdentifiers, Keyman.System.ExecutionHistory, Keyman.System.KeymanSentryClient, - Keyman.System.RemoteUpdateCheck, + Keyman.System.UpdateStateMachine, OptionsXMLRenderer, Keyman.Configuration.System.UmodWebHttpServer, Keyman.Configuration.System.HttpServer.App.ConfigMain, @@ -800,16 +800,14 @@ begin end; procedure TfrmMain.Update_CheckNow; -// TODO: epic-windows-update -// Get an instance to the state machine and call handle check so the state can change to update -// available. -var UpdateCheck : TRemoteUpdateCheck; +var + BUpdateSM : TUpdateStateMachine; begin - UpdateCheck := TRemoteUpdateCheck.Create(True); + BUpdateSM := TUpdateStateMachine.Create(False); try - UpdateCheck.Run; + BUpdateSM.HandleCheck; finally - UpdateCheck.Free; + BUpdateSM.Free; end; DoRefresh; end;