Follow-up to the previous iOS commit. Still not compiled - no Swift toolchain here.
The "core ignored keepActiveUser" path in the compose picker rested on a false
premise. It claimed the form stays open and the alert draws over it, but the resync it
performs replaces the chat list with the new profile's, and the prepared chat stayed
with the previous one - so getChat returns nothing, the pushed chat view renders
nothing, and this picker, which is the sheet's presenter, is removed by the switch
itself. The alert was then raised into a hierarchy being torn down and discarded. The
form is now dismissed first, and the chat id cleared only if it is still the chat this
picker belongs to, since a notification tap may have navigated elsewhere meanwhile.
Rows stay live during the reassignment. creatingProfile is cleared as soon as
createProfileForChat returns, which is the moment it hands off to changeProfile's
fire-and-forget Task, and none of the rows had a disabled state at all - so a second
change could be started on top of the first, two concurrent reassignments of the same
prepared contact and two racing user switches. This is what the Kotlin side made
onCreated suspending for.
The one-time link picker's new else branch reset the switch status but not the
selection, so after a cancelled retry the profile that was not switched to kept the
checkmark and tapping it did nothing - the view thought it was already selected. Its
"core ignored the flag" path likewise left the picker pointing at a profile that is no
longer active. The incognito handler has the identical latch the else branch was added
for, and hardening the row's disabled state on profileSwitchStatus made that stuck path
disable the row permanently, so it gets the same treatment - and its two state writes
move onto the main actor, where the rest of that block already was.
Both swallowed errors are now logged, and the comment claiming two .sheet modifiers on
one view conflict is dropped - it contradicted the sibling file and the deployment
target.
Mirrors the Android/desktop fixes where iOS has the same defects, and fixes the ones
that are specific to SwiftUI. Still not compiled - no Swift toolchain here, same
status as the rest of the iOS port in this branch.
Swallowed alert. The one-time link picker reported "the core ignored keepActiveUser"
by setting its own `alert` @State, consumed by .alert(item:) on the very view that is
presenting the create-profile sheet. UIKit refuses an alert on a controller that
already has a presentation, so it was never shown: the active profile silently
switched, the connection stayed where it was, and the user was left looking at an
unchanged form. Uses the global showAlert, which targets the top view controller, as
the compose picker already does.
Stale picker list. The compose picker fills its own `users` in onAppear and never
again, so the profile just created was missing from the list whenever the
reassignment failed - tapping "Add profile" again then hit "Duplicate display name!"
- and the frame height, which is computed from that count, was one row short. The
local from listUsers also shadowed the property, which is what hid this.
Resync failure reported as a creation failure. changeActiveUserAsync_ throws, and on
the "core ignored the flag" path that propagated into the form's catch, which says
"Error creating profile!" although the profile had been created. On the compose
picker that path also left chatId pointing at a prepared chat that had stayed with
the previous profile, i.e. at a chat absent from the list, which renders blank.
Sheet owner destroyed mid-dismissal. The compose picker's sheet was attached inside
profilePicker(), which is swapped out for currentSelection() the moment listExpanded
flips - which changeProfile does while the sheet is still dismissing, and which an
incoming event can do at any time via profileChangeProhibited. Moved to the Group in
viewBody(), which survives both; stacking sheets is supported from iOS 14.5 and the
app targets 15.
Dismissal during creation. The submit runs in an unstructured Task that SwiftUI does
not cancel, so a swipe-to-dismiss still created the profile and switched to it while
every state write, including the one clearing the in-flight flag, landed on a view
that was gone. Both sheets now block interactive dismissal while creating.
Latched picker. If apiChangeConnectionUser returns nothing rather than throwing,
profileSwitchStatus was never reset, leaving the picker dimmed behind a spinner with
hit testing off. Pre-existing, but the new row routes through the same handler.
Re-tappable row. switchingProfileByTimeout only latches half a second after the
switch starts, and creatingProfile is cleared as soon as the switch is handed over,
so the row was live in between.
Adds "Add profile" to the profile picker shown above the compose box for a
prepared chat, so connecting as someone new does not mean leaving the invitation
to create a profile in settings.
NewUser and createActiveUser gain keepActiveUser, with apiCreateProfileKeepingActive
as the named entry point; the flag never appears at a call site. The profile is
created without becoming active so the profile that owns the prepared chat stays
active for the reassignment.
The row is emitted first: unlike the Android/desktop list this one is not
reverse-laid-out, so first renders at the top. After switching, the chat is
reopened explicitly - keepingChatId only preserves its place in the reloaded
list.
Reuses the existing "Add profile" and "Error changing chat profile" strings, so
no new translation entries.
Group chat and its support chats have the same chat id, so a draft saved
in "chat with admins" was restored in the group chat and shown as its draft
in the chat list. Include chat scope in the draft chat id.
Also save the draft when support chat is closed without changing chat id -
in that case KeyChangeEffect that saves drafts doesn't run.
* android, desktop, ios: drop stale mention map entry when @name is edited in place
The compose-state mentions map was only pruned when fewer @name tokens were
parsed from the text than were in the map. Editing an inserted @Name token in
place (without re-picking from the picker) keeps the count at 1 while the
parsed name no longer matches the stored key, so the stale entry was sent and
the core rejected it with SEInvalidMention. Pruning now triggers whenever any
map key is absent from the parsed mention names; the modified token is then
sent as an unresolved formatted @ token.
* android, desktop, ios: filter mentions at send time so in-place edits round-trip
Treat the compose-state mentions map as a sticky cache of name -> memberId
bindings recorded by the picker. The previous removeUnusedMentions pruned
it on every text change, which dropped the binding the instant a letter was
removed from an inserted @name token. Now the map is no longer mutated by
text edits: memberMentions, the picker max-reached check, and the
mentionMemberName disambiguator all filter against the names currently
parsed from the message, so deleting and retyping the original characters
re-resolves the original member, and the SEInvalidMention error from an
in-place edit no longer occurs.
* android, desktop, ios: cap memberMentions at MAX so stale cache entries cannot overflow the server limit
With the sticky cache, manually typing an @name that happens to match a
stale cache entry could push memberMentions above maxSndMentions and have
the core reject the send with SEInvalidMention. The getter now walks
parsedMessage in text order and stops at MAX_NUMBER_OF_MENTIONS; later
@-tokens past the cap become visual-only formatting and the message still
goes through. Also hoists the iOS activeMentions computation out of the
per-row ForEach so it runs once per picker open rather than once per row.
* android, desktop, ios: simplify mention restoration to minimal surgical diff
Reverts the unnecessary mentionMemberName changes (the original
mentions.containsKey behaviour preserves bindings better than the
parsed-only variant), switches the picker checks to memberMentions.size
(no helper variable needed since the getter already caps at MAX), and
collapses the Kotlin memberMentions getter into a flat chain.
* android, desktop, ios: gate picker mention-id and max-reached banner by memberMentions
With the sticky cache, the picker's "currently bound member" highlight
and the showMaxReachedBox banner-suppression clause read mentions[name]
directly, so a stale cache entry made one row clickable (as a no-op) at
the MAX limit and could suppress the banner when the user is actually
adding a new mention. Both now gate the lookup by membership in the
capped memberMentions, restoring the pre-fix UX where at MAX all rows
are disabled and the banner shows when adding past the limit.
A long file name took all the row width and squeezed the cancel (X)
icon to zero, so the file could not be dismissed before sending.
Give the file-name text the layout weight and a single line (Compose),
and lineLimit(1) on iOS, so it truncates and the close icon keeps its
space. Affects Android, Desktop and iOS.
* core: test support chats in channels, CLI defaults to sending as member in support chat
* ui: enable support chats in channels
* use correct scope when sending from UI
* more readable
* remove test output
* show member support chat in channels
* preference for support chats
* ios: types for support preference
* mp: support preference types
* show support preference in UI
* fix ios
* make support preference optional in JSON parser
* update string
* change strings, pass parameters to prefs
* refactor kotlin
* take support preference into account
* refactor core
* do not show broadcast placeholder in support scope
* move role check, add pref check on update
* support preference test (failing)
* fix version
* fix tests
* warning alert when enabling chats with admins
* revert on dismiss
* update text and icons
* query plans
---------
Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
* ios: sharing channel links/cards
* update nix shas
* improve
* fix preview
* change condition
* move button for owner
* refactor
* refactor 2
* fix sheets
* MsgChatLink JSON encoding
* correct default icon when editing group profile
* drop link from card
* card layout
* strip link from text
* remove file ref
* share via chat when created
* rename file, do not show text when there is no text
* better card layout
* padding, info string
* add log
* padding
* text layout
* warning emoji if signature verification failed
* chat link preview in chat list
* description
* alert information
* tappable preview
* better
* conditional border color
* sending and forwarding views
* small link icons for forwarding
* strip link in one place
* forwarded context
* quote view for chat links
* reduce diff, remove unnecessary changes
* simplify
* trim description
* diff
---------
Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
* rfc: bot messages and buttons
* update
* update bot rfc
* core: add bot commands to chat preferences and peer type to profile
* update postgresql schema
* update query plans
* chat sessions preference
* markdown for bot commands
* schema
* core: file preference, options to create bot from CLI
* core: different command type
* ios: commands menu
* update types
* update ios
* improve command markdown
* core, ios: update types
* android, desktop: clickable commands in messages in chats with bots
* android, desktop: commands menu
* command menu button, bot icon
* ios: connect flow for bots
* android, desktop: connect flow for bots
* icon
* CLI commands to view and set commands, remove "hidden" property of command, bot api docs
* corrections
* fix inheriting profile preferences to business groups
* note on business address
* ios: export localizations
* fix test
* commands to set file preference on user/contact, tidy up layout and display of command and attachment buttons
* core: use longer timeouts for background network requests, support retries with increased timeouts
* ios: update types
* ios: allow user retry actions with failed network requests
* build: add exporting API functions with retry
* android, desktop: update types and C APIs
* android, desktop: alert to retry action on network error
* simplexmq
* core: add/send contact address and request messages, ios: use auto-reply as welcome message
* revert event type change
* fix test, type
* multiplatform: update type
* fix query
* ios: hide keyboard when sending the message
* failing test for business chat with a welcome message
* retry joining via contact address
* query plans
* do not send history to the first member (the original customer) of business chat
* correctly handle retries when joining groups, do not create a new connection on retry
* failing test for group welcome message and feature items
* do not send history item if member saw it during joining (based on welcomeSharedMsgId in join request)
* correct fields in PendingContactConnection, update plans
* prevent duplicate group description created in chat, while ensuring that it is created
* fix query
* core: fix retry when connecting via invitation short link
* ios: fix conditions, mark contacts as connected, only show spinners on contacts when connection status is ready or sndReady
* core: option to show group as sender of chat item (for the initial items, e.g. welcome message)
* add chat item to contact request chats
* return AChat for prepared chats and contact requests
* update iOS api types, show prepared contact as blue, show preview info when content message is not available (previously was showing feature item)
* ios: remove ContactType
* ios: show group as sender, fix avatar not showing when member message sequence starts with merged items
* ios: update compose UI for all connection scenarios
* address settings
* ios: address settings UI
* fix tests
* fix tests 2
* ios: fix minor issues