Skip to content

Conversation

@mpretty-cyro
Copy link
Collaborator

@mpretty-cyro mpretty-cyro commented Oct 15, 2025

  • Initial Session Pro backend integration work
  • Refactored the OpenGroupManager and OpenGroupManagerCache into a single CommunityManager
    • This now maintains an in-memory cache to make it easier to retrieve the current state without needing to query the database
  • Refactored the SessionThreadViewModel and MessageViewModel (see below for more info)
  • Refactored OWSAudioPlayer into Swift
  • Reworked some config handling logic so all merges happen before processing the merge changes (this way we can handle multi-config changes properly)
  • Removed a bunch of GRDB-specific relationship code (just makes things messy since we have raw SQL elsewhere)
  • Added some convenience code to clean up the DSL of consuming events
  • Updated the code to retrieve group auth via libSession instead of the database
  • Updated to the latest libSession
  • Updated code to encode and decode messages via libSession (instead of doing directly and just using libSession for crypto)
  • Updated code to use strings from libSession instead of hardcoded values
  • Fixed a bug where default communities would use auth to retrieve display pics
  • Fixed a bug where interactions may not be able to be marked as deleted if there was an attachment without a downloadUrl
  • Fixed a few issues with performing UI actions on background threads (mentions "@you badge")
  • Fixed a bug where the Toggle ListItemAccessory could swallow touches and make it appear as though something changed when it didn't
  • Fixed a bug where the toggle wouldn't be tinted the right colour in SwiftUI screens
  • Fixed a bug where determining whether a string was RTL could cause lag
  • Fixed a bug where the ObservationBuilder could incorrectly run queries in cancelled contexts resulting in potential buggy outputs
  • Fixed a bug where outgoing voice messages might not be able to be played

SessionThreadViewModel Refactor

The SessionThreadViewModel has been renamed to ConversationInfoViewModel and is now a simple struct (as opposed to a FetchableRecord with a handful of behemoth database queries)

The ConversationInfoViewModel and MessageViewModel now get initialised with a ConversationDataCache which is an object that holds a bunch of [ID -> Data] stores for various types that are needed to construct the aforementioned view models. The ConversationDataCache will generally be populated via the ConversationDataHelper which, when combined with our ObservableEvent system, is where the majority of the work for this refactoring has gone. This helper essentially has 4 parts:

  • determineFetchRequirements: Reviews any events which have come through and determines whether anything needs to be fetched from the database
  • applyNonDatabaseEvents: Updates the cached data directly based on delta information included in the ObservableEvent instances
  • fetchFromDatabase: Fetches any data from the database based on the info returned from determineFetchRequirements, this function will also resolve any dependant data that newly fetched objects need if they aren't already in the cache
  • fetchFromLibSession: Retrieves requested data from libSession

Using the above setup all screens which contain conversation or message data now use these two view models, and can share the state of the view models between each other to reduce the need to refetch data when entering a new screen

Some additional changes included due to the above are:

  • No longer need to pass displayNameRetriever throughout
  • Removed deprecated display name retrieval functions
  • Removed some duplicate code
  • Removed some synchronous database query hacks we needed until refactoring had been completed
  • Refactored mentions to be handled by tags
  • Refactored and optimised the searching logic (also added some caching)
  • Refactored the ThreadSettingsViewModel to use the new ObservationBuilder system
  • Refactored the ThreadPickerViewModel to use the new ObservationBuilder system
  • Refactored the HomeViewModel to retrieve data using the ConversationDataHelper
  • Refactored the ConversationViewModel to retrieve data using the ConversationDataHelper

@mpretty-cyro mpretty-cyro self-assigned this Oct 15, 2025
@mpretty-cyro mpretty-cyro added enhancement New feature or request Jira This ticket is being tracked in Jira labels Oct 15, 2025
@mpretty-cyro mpretty-cyro changed the title [WIP] Use libSession for message encoding and decoding [WIP] Session Pro Integration Oct 28, 2025
…ession-message-wrapping

# Conflicts:
#	SessionMessagingKit/Jobs/AttachmentUploadJob.swift
#	SessionMessagingKit/Jobs/MessageSendJob.swift
#	SessionMessagingKit/Sending & Receiving/Message Handling/MessageSender+Groups.swift
#	SessionMessagingKit/Sending & Receiving/MessageSender.swift
#	SessionUtilitiesKit/Crypto/CryptoError.swift
• Updated the code to use the libSession function to determine message lengths
• Fixed an issue where CTA modal benefits could incorrectly be truncated
@mpretty-cyro mpretty-cyro changed the base branch from master to dev November 3, 2025 04:12
…essage-wrapping

# Conflicts:
#	SessionUIKit/Components/SwiftUI/ProCTAModal.swift
…e/libsession-message-wrapping

# Conflicts:
#	Session/Conversations/ConversationVC+Interaction.swift
#	Session/Conversations/Input View/InputView.swift
#	Session/Settings/DeveloperSettings/DeveloperSettingsProViewModel.swift
#	Session/Settings/SettingsViewModel.swift
#	SessionMessagingKit/Jobs/ReuploadUserDisplayPictureJob.swift
#	SessionMessagingKit/LibSession/Config Handling/LibSession+Contacts.swift
#	SessionMessagingKit/LibSession/Config Handling/LibSession+Pro.swift
#	SessionMessagingKit/LibSession/Config Handling/LibSession+UserProfile.swift
#	SessionMessagingKit/Sending & Receiving/MessageSender+Convenience.swift
#	SessionMessagingKit/Utilities/SessionProState.swift
#	SessionUIKit/Components/SwiftUI/ProCTAModal.swift
#	SessionUtilitiesKit/General/Feature.swift
#	SignalUtilitiesKit/Media Viewing & Editing/Attachment Approval/AttachmentTextToolbar.swift
• Refactored the MessageViewModel to be a dumb data types instead of a monolithic query
• Refactored the ConversationViewModel due to handle the updated MessageViewModel
• Refactored OWSAudioPlayer into Swift
• Refactored the OpenGroupManager and OpenGroupManagerCache to be a single actor (CommunityManager), it also holds community state in memory
• Removed a bunch of GRDB-specific relationship code (just makes things messy since we have raw SQL elsewhere)
• Fixed a bug where the ObservationBuilder could incorrectly run queries in cancelled contexts resulting in potential buggy outputs
• Fixed a bug where outgoing voice messages might not be able to be played
• Updated the dev settings to show the different products
• Fixed an issue where opening a conversation from global search would result in data missing
…essage-wrapping

# Conflicts:
#	Session.xcodeproj/project.pbxproj
#	Session/Conversations/ConversationVC+Interaction.swift
#	Session/Conversations/ConversationVC.swift
#	Session/Conversations/Settings/ThreadSettingsViewModel.swift
#	Session/Home/App Review/AppReviewPromptModel.swift
#	Session/Home/HomeViewModel.swift
#	Session/Media Viewing & Editing/MessageInfoScreen.swift
#	Session/Meta/AppDelegate.swift
#	Session/Settings/DeveloperSettings/DeveloperSettingsProViewModel.swift
#	Session/Settings/SettingsViewModel.swift
#	Session/Shared/BaseVC.swift
#	Session/Utilities/UIContextualAction+Utilities.swift
#	SessionMessagingKit/Database/Models/SessionThread.swift
#	SessionMessagingKit/SessionPro/SessionProPaymentScreenContent.swift
#	SessionMessagingKit/SessionPro/SessionProSettingsViewModel.swift
#	SessionMessagingKit/SessionPro/SessionProState.swift
#	SessionMessagingKit/Shared Models/SessionThreadViewModel.swift
#	SessionNotificationServiceExtension/NotificationServiceExtension.swift
#	SessionUIKit/Components/Input View/InputView.swift
#	SessionUIKit/Components/SwiftUI/ProCTAModal.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen+CancelPlan.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen+Models.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen+Purchase.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen+Renew.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen+RequestRefund.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen+UpdatePlan.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPaymentScreen.swift
#	SessionUIKit/Screens/Settings/SessionProSettings/SessionProPlanUpdatedScreen.swift
#	SessionUIKit/Style Guide/Constants+Apple.swift
#	SignalUtilitiesKit/Media Viewing & Editing/Attachment Approval/AttachmentApprovalViewController.swift
#	SignalUtilitiesKit/Media Viewing & Editing/Attachment Approval/AttachmentTextToolbar.swift
• Added logic to handle non-originating accounts
• Added explicit SessionPro errors
• Moved profile pro decisions into the SessionProManager to consolidate the logic
• Resolved a bunch of TODOs
• Fixed an issue where a invalid pro key would prevent messages from decoding
…essage-wrapping

# Conflicts:
#	Session/Conversations/ConversationVC+Interaction.swift
#	Session/Conversations/ConversationVC.swift
#	Session/Conversations/Settings/ThreadSettingsViewModel.swift
#	Session/Home/GlobalSearch/GlobalSearchViewController.swift
#	Session/Meta/AppDelegate.swift
#	SessionMessagingKit/Open Groups/OpenGroupManager.swift
#	SessionMessagingKit/Sending & Receiving/MessageReceiver.swift
#	SessionMessagingKit/Utilities/MessageWrapper.swift
• Tweaked group message deletion to determine admin status via libSession instead of the database (since it now retrieves keys from libSession)
• Fixed a bug where interactions may not be able to be marked as deleted if there was an attachment without a downloadUrl
@mpretty-cyro mpretty-cyro changed the title [WIP] Session Pro Integration [WIP] Initial Session Pro Integration, Query Refactoring and Bug Fixes Dec 18, 2025
• Added some initial pro revocation list logic
• Updated to libSession 1.5.9
• Fixed duplicate file warnings
• Fixed a bug where an invalid thread would be created on fresh install
• Fixed a bug where restoring a device could result in the conversation list staying empty
• Fixed a possible deadlock during dependency initialisation
• Fixed an issue preventing destroyed/kicked groups from rendering correctly
• Fixed an auth issue when creating a new group
• Fixed an issue where the input would incorrect allow text entry when the user can't send messages
• Fixed an issue where conversations weren't correctly being identified as message requests
• Fixed an issue where the empty state in a conversation could end up with the wrong font
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Jira This ticket is being tracked in Jira

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant