mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-07-02 22:11:54 +00:00
9bd38c4aec
* android, desktop, ios: connect via SimpleX name
* android, desktop, ios: open known contact on name lookup; surface prepared contact
Name search opens the contact (not list-filter); resolved/prepared contacts and groups are added to the chat list so they're visible and openable. Kotlin compile-verified; iOS edits pattern-matched, pending Xcode build.
* feat(names): UI names role + agent NAME error
Parity with the core names rework (#7045):
- Add `names` to ServerRoles (Android + iOS) and a per-operator
"To resolve names" toggle under the SMP section (xftp has no names
role; the shared ServerRoles field stays false there).
- Mirror the new agent error: NameErrorType + a NAME case on both
AgentErrorType and ProtocolErrorType (the SMP ErrorType mirror), so
the new SMP/agent NAME errors decode instead of crashing the decoder.
- Remove ChatErrorType.SimplexNameResolverUnavailable (deleted in core)
and repoint its "name resolution unavailable" alert to the agent
NAME NO_SERVERS error, reusing the existing strings.
Android (multiplatform) compiles clean; iOS mirrors the same changes
(builds in Xcode).
* feat(names): UI warning when no server resolves names
Mirror core USWNoNamesServers: add the NoNamesServers variant to
UserServersWarning (Kotlin sealed class + Swift enum) and its
globalWarning / globalServersWarning branch, rendered by the existing
ServersWarningFooter / ServersWarningView. Matches the noChatRelays
warning exactly.
* fix(servers): show all validation errors and warnings, not just the first
globalServersError/Warning returned only the first entry, so a second
warning (e.g. no names servers behind no chat relays) or a second error
(e.g. no XFTP servers behind no SMP servers) was never displayed. Make
them return all entries (globalServersErrors/Warnings) and render one
footer row each, across the three combined-footer views. Per-protocol
SMP/XFTP footers are unchanged.
* docs(names): add SimpleX name UI plan
* feat(names): add name model fields + SimplexName helpers
* feat(names): verify + set-name API & responses
* docs(names): bump core sync to 5008b4e62
* feat(names): show name + verification on chat info
* feat(names): add Verify SimpleX names privacy toggle
* feat(names): add set-name screens (user + channel)
* update ui
* fix kotlin
* fix codable
* fix ios
* fix errors
* api in UI
* send name as string in protocol
* update simplexmq, capitalize
* verify that name is in profile for own and known contacts and channels as condition of name resolution
* update simplexmq
---------
Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
86 lines
4.4 KiB
Haskell
86 lines
4.4 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module ViewTests where
|
|
|
|
import Data.Time
|
|
import Simplex.Chat.View
|
|
import Test.Hspec
|
|
|
|
viewTests :: Spec
|
|
viewTests = do
|
|
testRecent
|
|
|
|
testRecent :: Spec
|
|
testRecent = describe "recent" $ do
|
|
let tz = hoursToTimeZone 1
|
|
now1159 = UTCTime (fromGregorian 2023 6 7) (secondsToDiffTime $ 10 * 3600 + 59 * 60) -- 11:59 in tz
|
|
now1200 = UTCTime (fromGregorian 2023 6 7) (secondsToDiffTime $ 11 * 3600) -- 12:00 in tz
|
|
today0000 = UTCTime (fromGregorian 2023 6 6) (secondsToDiffTime $ 23 * 3600) -- 00:00 in tz
|
|
today0600 = UTCTime (fromGregorian 2023 6 7) (secondsToDiffTime $ 5 * 3600) -- 06:00 in tz
|
|
today1200 = UTCTime (fromGregorian 2023 6 7) (secondsToDiffTime $ 11 * 3600) -- 12:00 in tz
|
|
today1800 = UTCTime (fromGregorian 2023 6 7) (secondsToDiffTime $ 17 * 3600) -- 18:00 in tz
|
|
today2359 = UTCTime (fromGregorian 2023 6 7) (secondsToDiffTime $ 22 * 3600 + 59 * 60) -- 23:59 in tz
|
|
yesterday0000 = UTCTime (fromGregorian 2023 6 5) (secondsToDiffTime $ 23 * 3600) -- 00:00 in tz
|
|
yesterday1759 = UTCTime (fromGregorian 2023 6 6) (secondsToDiffTime $ 16 * 3600 + 59 * 60) -- 17:59 in tz
|
|
yesterday1800 = UTCTime (fromGregorian 2023 6 6) (secondsToDiffTime $ 17 * 3600) -- 18:00 in tz
|
|
yesterday2359 = UTCTime (fromGregorian 2023 6 6) (secondsToDiffTime $ 22 * 3600 + 59 * 60) -- 23:59 in tz
|
|
sameDayLastMonth1900 = UTCTime (fromGregorian 2023 5 7) (secondsToDiffTime $ 18 * 3600) -- 19:00 in tz
|
|
prevDayLastMonth1900 = UTCTime (fromGregorian 2023 5 6) (secondsToDiffTime $ 18 * 3600) -- 19:00 in tz
|
|
sameDayLastYear1900 = UTCTime (fromGregorian 2022 6 7) (secondsToDiffTime $ 18 * 3600) -- 19:00 in tz
|
|
prevDayLastYear1900 = UTCTime (fromGregorian 2022 6 6) (secondsToDiffTime $ 18 * 3600) -- 19:00 in tz
|
|
tomorrow0000 = UTCTime (fromGregorian 2023 6 7) (secondsToDiffTime $ 23 * 3600) -- 00:00 in tz
|
|
tomorrow1759 = UTCTime (fromGregorian 2023 6 8) (secondsToDiffTime $ 16 * 3600 + 59 * 60) -- 17:59 in tz
|
|
tomorrow1800 = UTCTime (fromGregorian 2023 6 8) (secondsToDiffTime $ 17 * 3600) -- 18:00 in tz
|
|
tomorrow2359 = UTCTime (fromGregorian 2023 6 8) (secondsToDiffTime $ 22 * 3600 + 59 * 60) -- 23:59 in tz
|
|
sameDayNextMonth1900 = UTCTime (fromGregorian 2023 7 7) (secondsToDiffTime $ 18 * 3600) -- 19:00 in tz
|
|
prevDayNextMonth1900 = UTCTime (fromGregorian 2023 7 6) (secondsToDiffTime $ 18 * 3600) -- 19:00 in tz
|
|
sameDayNextYear1900 = UTCTime (fromGregorian 2024 6 7) (secondsToDiffTime $ 18 * 3600) -- 19:00 in tz
|
|
prevDayNextYear1900 = UTCTime (fromGregorian 2024 6 6) (secondsToDiffTime $ 18 * 3600) -- 19:00 in tz
|
|
test tz now1159 today0000 True
|
|
test tz now1159 today0600 True
|
|
test tz now1159 today1200 True
|
|
test tz now1159 today1800 True
|
|
test tz now1159 today2359 True
|
|
test tz now1159 yesterday0000 False
|
|
test tz now1159 yesterday1759 False
|
|
test tz now1159 yesterday1800 True
|
|
test tz now1159 yesterday2359 True
|
|
test tz now1159 sameDayLastMonth1900 False
|
|
test tz now1159 prevDayLastMonth1900 False
|
|
test tz now1159 sameDayLastYear1900 False
|
|
test tz now1159 prevDayLastYear1900 False
|
|
test tz now1159 tomorrow0000 False
|
|
test tz now1159 tomorrow1759 False
|
|
test tz now1159 tomorrow1800 False
|
|
test tz now1159 tomorrow2359 False
|
|
test tz now1159 sameDayNextMonth1900 False
|
|
test tz now1159 prevDayNextMonth1900 False
|
|
test tz now1159 sameDayNextYear1900 False
|
|
test tz now1159 prevDayNextYear1900 False
|
|
|
|
test tz now1200 today0000 True
|
|
test tz now1200 today0600 True
|
|
test tz now1200 today1200 True
|
|
test tz now1200 today1800 True
|
|
test tz now1200 today2359 True
|
|
test tz now1200 yesterday0000 False
|
|
test tz now1200 yesterday1759 False
|
|
test tz now1200 yesterday1800 False
|
|
test tz now1200 yesterday2359 False
|
|
test tz now1200 sameDayLastMonth1900 False
|
|
test tz now1200 prevDayLastMonth1900 False
|
|
test tz now1200 sameDayLastYear1900 False
|
|
test tz now1200 prevDayLastYear1900 False
|
|
test tz now1200 tomorrow0000 False
|
|
test tz now1200 tomorrow1759 False
|
|
test tz now1200 tomorrow1800 False
|
|
test tz now1200 tomorrow2359 False
|
|
test tz now1200 sameDayNextMonth1900 False
|
|
test tz now1200 prevDayNextMonth1900 False
|
|
test tz now1200 sameDayNextYear1900 False
|
|
test tz now1200 prevDayNextYear1900 False
|
|
where
|
|
test tz now time expected =
|
|
it ("returns " <> show expected <> " for time " <> show time <> " when time zone is " <> show tz <> " and current time is " <> show now) $
|
|
recent now tz time `shouldBe` expected
|