From 0962a2085206baebfd16ccf37085a8bdce74576e Mon Sep 17 00:00:00 2001 From: Aaron Greenspan Date: Mon, 11 Jan 2021 12:39:02 -0700 Subject: [PATCH] agent: adds ui to app installed preview --- agent/src/Handler/Apps.hs | 5 ++++- agent/src/Handler/Types/Apps.hs | 2 ++ agent/src/Lib/External/AppManifest.hs | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/agent/src/Handler/Apps.hs b/agent/src/Handler/Apps.hs index 0a8ed916e..278559ac7 100644 --- a/agent/src/Handler/Apps.hs +++ b/agent/src/Handler/Apps.hs @@ -68,6 +68,7 @@ import Lib.Background import Lib.Error import qualified Lib.External.AppMgr as AppMgr import qualified Lib.External.Registry as Reg +import qualified Lib.External.AppManifest as AppManifest import Lib.IconCache import qualified Lib.Notifications as Notifications import Lib.SystemPaths @@ -230,7 +231,7 @@ getInstalledAppsLogic :: (Has (Reader AgentCtx) sig m, Has AppMgr2.AppMgr sig m, getInstalledAppsLogic = do jobCache <- asks appBackgroundJobs >>= liftIO . readTVarIO let installCache = installInfo . fst <$> inspect SInstalling jobCache - serverApps <- AppMgr2.list [AppMgr2.flags|-s -d|] + serverApps <- AppMgr2.list [AppMgr2.flags|-s -d -m|] let remapped = remapAppMgrInfo jobCache serverApps installingPreviews = flip HM.mapWithKey @@ -242,6 +243,7 @@ getInstalledAppsLogic = do , appInstalledPreviewStatus = AppStatusTmp Installing , appInstalledPreviewVersionInstalled = storeAppVersionInfoVersion , appInstalledPreviewTorAddress = Nothing + , appInstalledPreviewUi = False } installedPreviews = flip HML.mapWithKey @@ -251,6 +253,7 @@ getInstalledAppsLogic = do , appInstalledPreviewStatus = s , appInstalledPreviewVersionInstalled = v , appInstalledPreviewTorAddress = infoResTorAddress + , appInstalledPreviewUi = withSome1 infoResManifest AppManifest.hasUi } pure $ HML.elems $ HML.union installingPreviews installedPreviews diff --git a/agent/src/Handler/Types/Apps.hs b/agent/src/Handler/Types/Apps.hs index 548db4b02..867fc05e2 100644 --- a/agent/src/Handler/Types/Apps.hs +++ b/agent/src/Handler/Types/Apps.hs @@ -43,6 +43,7 @@ data AppInstalledPreview = AppInstalledPreview , appInstalledPreviewStatus :: AppStatus , appInstalledPreviewVersionInstalled :: Version , appInstalledPreviewTorAddress :: Maybe TorAddress + , appInstalledPreviewUi :: Bool } deriving (Eq, Show) instance ToJSON AppInstalledPreview where @@ -50,6 +51,7 @@ instance ToJSON AppInstalledPreview where [ "status" .= appInstalledPreviewStatus , "versionInstalled" .= appInstalledPreviewVersionInstalled , "torAddress" .= (unTorAddress <$> appInstalledPreviewTorAddress) + , "ui" .= appInstalledPreviewUi ] data InstallNewAppReq = InstallNewAppReq diff --git a/agent/src/Lib/External/AppManifest.hs b/agent/src/Lib/External/AppManifest.hs index b35dccfeb..c3636076b 100644 --- a/agent/src/Lib/External/AppManifest.hs +++ b/agent/src/Lib/External/AppManifest.hs @@ -64,6 +64,9 @@ data AppManifest (n :: Nat) where , appManifestV0Dependencies :: HM.HashMap AppId VersionRange } -> AppManifest 0 +hasUi :: forall n. AppManifest n -> Bool +hasUi AppManifestV0 {..} = isJust $ HM.lookup 80 appManifestV0PortMapping + instance FromJSON (Some1 AppManifest) where parseJSON = withObject "App Manifest" $ \o -> do o .: "compat" >>= \case