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 Lib.Error
import qualified Lib.External.AppMgr as AppMgr import qualified Lib.External.AppMgr as AppMgr
import qualified Lib.External.Registry as Reg import qualified Lib.External.Registry as Reg
import qualified Lib.External.AppManifest as AppManifest
import Lib.IconCache import Lib.IconCache
import qualified Lib.Notifications as Notifications import qualified Lib.Notifications as Notifications
import Lib.SystemPaths import Lib.SystemPaths
@@ -230,7 +231,7 @@ getInstalledAppsLogic :: (Has (Reader AgentCtx) sig m, Has AppMgr2.AppMgr sig m,
getInstalledAppsLogic = do getInstalledAppsLogic = do
jobCache <- asks appBackgroundJobs >>= liftIO . readTVarIO jobCache <- asks appBackgroundJobs >>= liftIO . readTVarIO
let installCache = installInfo . fst <$> inspect SInstalling jobCache 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 let remapped = remapAppMgrInfo jobCache serverApps
installingPreviews = flip installingPreviews = flip
HM.mapWithKey HM.mapWithKey
@@ -242,6 +243,7 @@ getInstalledAppsLogic = do
, appInstalledPreviewStatus = AppStatusTmp Installing , appInstalledPreviewStatus = AppStatusTmp Installing
, appInstalledPreviewVersionInstalled = storeAppVersionInfoVersion , appInstalledPreviewVersionInstalled = storeAppVersionInfoVersion
, appInstalledPreviewTorAddress = Nothing , appInstalledPreviewTorAddress = Nothing
, appInstalledPreviewUi = False
} }
installedPreviews = flip installedPreviews = flip
HML.mapWithKey HML.mapWithKey
@@ -251,6 +253,7 @@ getInstalledAppsLogic = do
, appInstalledPreviewStatus = s , appInstalledPreviewStatus = s
, appInstalledPreviewVersionInstalled = v , appInstalledPreviewVersionInstalled = v
, appInstalledPreviewTorAddress = infoResTorAddress , appInstalledPreviewTorAddress = infoResTorAddress
, appInstalledPreviewUi = withSome1 infoResManifest AppManifest.hasUi
} }
pure $ HML.elems $ HML.union installingPreviews installedPreviews pure $ HML.elems $ HML.union installingPreviews installedPreviews

View File

@@ -43,6 +43,7 @@ data AppInstalledPreview = AppInstalledPreview
, appInstalledPreviewStatus :: AppStatus , appInstalledPreviewStatus :: AppStatus
, appInstalledPreviewVersionInstalled :: Version , appInstalledPreviewVersionInstalled :: Version
, appInstalledPreviewTorAddress :: Maybe TorAddress , appInstalledPreviewTorAddress :: Maybe TorAddress
, appInstalledPreviewUi :: Bool
} }
deriving (Eq, Show) deriving (Eq, Show)
instance ToJSON AppInstalledPreview where instance ToJSON AppInstalledPreview where
@@ -50,6 +51,7 @@ instance ToJSON AppInstalledPreview where
[ "status" .= appInstalledPreviewStatus [ "status" .= appInstalledPreviewStatus
, "versionInstalled" .= appInstalledPreviewVersionInstalled , "versionInstalled" .= appInstalledPreviewVersionInstalled
, "torAddress" .= (unTorAddress <$> appInstalledPreviewTorAddress) , "torAddress" .= (unTorAddress <$> appInstalledPreviewTorAddress)
, "ui" .= appInstalledPreviewUi
] ]
data InstallNewAppReq = InstallNewAppReq data InstallNewAppReq = InstallNewAppReq

View File

@@ -64,6 +64,9 @@ data AppManifest (n :: Nat) where
, appManifestV0Dependencies :: HM.HashMap AppId VersionRange , appManifestV0Dependencies :: HM.HashMap AppId VersionRange
} -> AppManifest 0 } -> AppManifest 0
hasUi :: forall n. AppManifest n -> Bool
hasUi AppManifestV0 {..} = isJust $ HM.lookup 80 appManifestV0PortMapping
instance FromJSON (Some1 AppManifest) where instance FromJSON (Some1 AppManifest) where
parseJSON = withObject "App Manifest" $ \o -> do parseJSON = withObject "App Manifest" $ \o -> do
o .: "compat" >>= \case o .: "compat" >>= \case