agent: adds ui to app installed preview

This commit is contained in:
Aaron Greenspan
2021-01-11 12:39:02 -07:00
committed by Aiden McClelland
parent 3a63dab586
commit 0962a20852
3 changed files with 9 additions and 1 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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