mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
core: wallpapers api (#4110)
* core: wallpapers api * optional colors * update * api * update * whitespace * typo * test, fix * fix color parsing * separate UI and Theme color schemes * update * enable test * multiple themes, one per color scheme * theme overrides as a separate type * rename --------- Co-authored-by: Avently <7953703+avently@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
e38d5bd885
commit
bc5af35a3e
@@ -1,3 +1,4 @@
|
||||
{-# LANGUAGE DuplicateRecordFields #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PostfixOperators #-}
|
||||
|
||||
@@ -15,6 +16,8 @@ import qualified Data.Text as T
|
||||
import Simplex.Chat.Store.Shared (createContact)
|
||||
import Simplex.Chat.Types (ConnStatus (..), Profile (..))
|
||||
import Simplex.Chat.Types.Shared (GroupMemberRole (..))
|
||||
import Simplex.Chat.Types.UITheme
|
||||
import Simplex.Chat.Types.Util (encodeJSON)
|
||||
import Simplex.Messaging.Encoding.String (StrEncoding (..))
|
||||
import System.Directory (copyFile, createDirectoryIfMissing)
|
||||
import Test.Hspec hiding (it)
|
||||
@@ -73,6 +76,7 @@ chatProfileTests = do
|
||||
it "direct messages" testGroupPrefsDirectForRole
|
||||
it "files & media" testGroupPrefsFilesForRole
|
||||
it "SimpleX links" testGroupPrefsSimplexLinksForRole
|
||||
it "set user, contact and group UI theme" testSetUITheme
|
||||
|
||||
testUpdateProfile :: HasCallStack => FilePath -> IO ()
|
||||
testUpdateProfile =
|
||||
@@ -1935,8 +1939,8 @@ testGroupPrefsDirectForRole = testChat4 aliceProfile bobProfile cathProfile danP
|
||||
dan <## "#team: you joined the group"
|
||||
dan
|
||||
<### [ "#team: member alice (Alice) is connected",
|
||||
"#team: member bob (Bob) is connected"
|
||||
],
|
||||
"#team: member bob (Bob) is connected"
|
||||
],
|
||||
do
|
||||
alice <## "#team: cath added dan (Daniel) to the group (connecting...)"
|
||||
alice <## "#team: new member dan is connected",
|
||||
@@ -1947,7 +1951,7 @@ testGroupPrefsDirectForRole = testChat4 aliceProfile bobProfile cathProfile danP
|
||||
-- dan cannot send direct messages to alice (owner)
|
||||
dan ##> "@alice hello alice"
|
||||
dan <## "bad chat command: direct messages not allowed"
|
||||
(alice </)
|
||||
(alice </)
|
||||
-- but alice can
|
||||
alice `send` "@dan hello dan"
|
||||
alice <## "member #team dan does not have direct connection, creating"
|
||||
@@ -2029,3 +2033,54 @@ testGroupPrefsSimplexLinksForRole = testChat3 aliceProfile bobProfile cathProfil
|
||||
cc <## "alice updated group #team:"
|
||||
cc <## "updated group preferences:"
|
||||
cc <## "SimpleX links: on for owners"
|
||||
|
||||
testSetUITheme :: HasCallStack => FilePath -> IO ()
|
||||
testSetUITheme =
|
||||
testChat2 aliceProfile bobProfile $ \alice bob -> do
|
||||
connectUsers alice bob
|
||||
alice ##> "/g team"
|
||||
alice <## "group #team is created"
|
||||
alice <## "to add members use /a team <name> or /create link #team"
|
||||
alice #$> ("/_set theme user 1 " <> theme UCMDark, id, "ok")
|
||||
alice #$> ("/_set theme @2 " <> theme UCMDark, id, "ok")
|
||||
alice #$> ("/_set theme #1 " <> theme UCMDark, id, "ok")
|
||||
alice ##> "/u"
|
||||
userInfo alice "alice (Alice)"
|
||||
alice <## ("UI themes: " <> theme UCMDark)
|
||||
alice ##> "/create user alice2"
|
||||
userInfo alice "alice2"
|
||||
alice ##> "/u alice"
|
||||
userInfo alice "alice (Alice)"
|
||||
alice <## ("UI themes: " <> theme UCMDark)
|
||||
alice ##> "/i @bob"
|
||||
contactInfo alice
|
||||
alice <## ("UI themes: " <> theme UCMDark)
|
||||
alice ##> "/i #team"
|
||||
groupInfo alice
|
||||
alice <## ("UI themes: " <> theme UCMDark)
|
||||
alice #$> ("/_set theme user 1", id, "ok")
|
||||
alice #$> ("/_set theme @2", id, "ok")
|
||||
alice #$> ("/_set theme #1", id, "ok")
|
||||
alice ##> "/u"
|
||||
userInfo alice "alice (Alice)"
|
||||
alice ##> "/i @bob"
|
||||
contactInfo alice
|
||||
alice ##> "/i #team"
|
||||
groupInfo alice
|
||||
where
|
||||
theme cm = T.unpack $ encodeJSON UIThemeEntityOverrides {light = Nothing, dark = Just $ UIThemeEntityOverride cm Nothing defaultUIColors}
|
||||
userInfo a name = do
|
||||
a <## ("user profile: " <> name)
|
||||
a <## "use /p <display name> to change it"
|
||||
a <## "(the updated profile will be sent to all your contacts)"
|
||||
contactInfo a = do
|
||||
a <## "contact ID: 2"
|
||||
a <## "receiving messages via: localhost"
|
||||
a <## "sending messages via: localhost"
|
||||
a <## "you've shared main profile with this contact"
|
||||
a <## "connection not verified, use /code command to see security code"
|
||||
a <## "quantum resistant end-to-end encryption"
|
||||
a <## "peer chat protocol version range: (Version 1, Version 8)"
|
||||
groupInfo a = do
|
||||
a <## "group ID: 1"
|
||||
a <## "current members: 1"
|
||||
|
||||
Reference in New Issue
Block a user