cli: option to disable notifications, closes #2340 (#2373)

This commit is contained in:
Evgeny Poberezkin
2023-05-03 17:40:11 +02:00
committed by GitHub
parent 69767126aa
commit 5116bfa79c
5 changed files with 12 additions and 2 deletions

View File

@@ -105,5 +105,6 @@ mkChatOpts BroadcastBotOpts {coreOptions} =
chatServerPort = Nothing,
optFilesFolder = Nothing,
allowInstantFiles = True,
muteNotifications = True,
maintenance = False
}

View File

@@ -129,6 +129,7 @@ mobileChatOpts dbFilePrefix dbKey =
chatServerPort = Nothing,
optFilesFolder = Nothing,
allowInstantFiles = True,
muteNotifications = True,
maintenance = True
}

View File

@@ -36,6 +36,7 @@ data ChatOpts = ChatOpts
chatServerPort :: Maybe String,
optFilesFolder :: Maybe FilePath,
allowInstantFiles :: Bool,
muteNotifications :: Bool,
maintenance :: Bool
}
@@ -221,6 +222,11 @@ chatOptsP appDir defaultDbFileName = do
<> short 'f'
<> help "Send and receive instant files without acceptance"
)
muteNotifications <-
switch
( long "mute"
<> help "Mute notifications"
)
maintenance <-
switch
( long "maintenance"
@@ -235,6 +241,7 @@ chatOptsP appDir defaultDbFileName = do
chatServerPort,
optFilesFolder,
allowInstantFiles,
muteNotifications,
maintenance
}

View File

@@ -41,8 +41,8 @@ terminalChatConfig =
simplexChatTerminal :: WithTerminal t => ChatConfig -> ChatOpts -> t -> IO ()
simplexChatTerminal cfg opts t = do
sendToast <- initializeNotifications
handle checkDBKeyError . simplexChatCore cfg opts (Just sendToast) $ \u cc -> do
sendToast <- if muteNotifications opts then pure Nothing else Just <$> initializeNotifications
handle checkDBKeyError . simplexChatCore cfg opts sendToast $ \u cc -> do
ct <- newChatTerminal t
when (firstTime cc) . printToTerminal ct $ chatWelcome u
runChatTerminal ct cc

View File

@@ -73,6 +73,7 @@ testOpts =
chatServerPort = Nothing,
optFilesFolder = Nothing,
allowInstantFiles = True,
muteNotifications = True,
maintenance = False
}