Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Session.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8547,7 +8547,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
COMPILE_LIB_SESSION = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 665;
CURRENT_PROJECT_VERSION = 668;
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -8628,7 +8628,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
COMPILE_LIB_SESSION = "";
CURRENT_PROJECT_VERSION = 665;
CURRENT_PROJECT_VERSION = 668;
ENABLE_BITCODE = NO;
ENABLE_MODULE_VERIFIER = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -9328,7 +9328,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
COMPILE_LIB_SESSION = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 665;
CURRENT_PROJECT_VERSION = 668;
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -9917,7 +9917,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
COMPILE_LIB_SESSION = YES;
CURRENT_PROJECT_VERSION = 665;
CURRENT_PROJECT_VERSION = 668;
ENABLE_BITCODE = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down
80 changes: 41 additions & 39 deletions Session/Conversations/ConversationVC+Interaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ extension ConversationVC:
}

// Handle taps outside of tableview cell to dismiss keyboard
@MainActor @objc func dismissKeyboardOnTap(_ recognizer: UITapGestureRecognizer) {
/// If the tap was inside the "Send" button on the input then we **don't** want to dismiss the keyboard (the user should be
/// able to send multiple messages in a row)
let location: CGPoint = recognizer.location(in: self.snInputView.sendButton)
@MainActor @objc func dismissKeyboardOnMessageListTap(_ recognizer: UITapGestureRecognizer) {
/// If the tap was inside the input then we **don't** want to dismiss the keyboard (the user should be able to interact with their
/// current text, or tap the buttons without the keyboard being dismissed)
let location: CGPoint = recognizer.location(in: self.snInputView)

guard !snInputView.sendButton.bounds.contains(location) else { return }
guard !snInputView.bounds.contains(location) else { return }

_ = self.snInputView.resignFirstResponder()
}
Expand Down Expand Up @@ -1642,41 +1642,43 @@ extension ConversationVC:
return cellViewModel.profile?.blocksCommunityMessageRequests != true
}()

let userProfileModal: ModalHostingViewController = ModalHostingViewController(
modal: UserProfileModal(
info: .init(
sessionId: sessionId,
blindedId: blindedId,
qrCodeImage: qrCodeImage,
profileInfo: profileInfo,
displayName: displayName,
contactDisplayName: contactDisplayName,
isProUser: dependencies.mutate(cache: .libSession, { $0.validateProProof(for: cellViewModel.profile) }),
isMessageRequestsEnabled: isMessasgeRequestsEnabled,
onStartThread: { [weak self] in
self?.startThread(
with: cellViewModel.authorId,
openGroupServer: cellViewModel.threadOpenGroupServer,
openGroupPublicKey: cellViewModel.threadOpenGroupPublicKey
)
},
onProBadgeTapped: { [weak self, dependencies] in
dependencies[singleton: .sessionProState].showSessionProCTAIfNeeded(
.generic,
dismissType: .single,
afterClosed: { [weak self] in
self?.snInputView.updateNumberOfCharactersLeft(self?.snInputView.text ?? "")
},
presenting: { modal in
dependencies[singleton: .appContext].frontMostViewController?.present(modal, animated: true)
}
)
}
),
dataManager: dependencies[singleton: .imageDataManager]
DispatchQueue.main.async { [weak self] in
let userProfileModal: ModalHostingViewController = ModalHostingViewController(
modal: UserProfileModal(
info: .init(
sessionId: sessionId,
blindedId: blindedId,
qrCodeImage: qrCodeImage,
profileInfo: profileInfo,
displayName: displayName,
contactDisplayName: contactDisplayName,
isProUser: dependencies.mutate(cache: .libSession, { $0.validateProProof(for: cellViewModel.profile) }),
isMessageRequestsEnabled: isMessasgeRequestsEnabled,
onStartThread: { [weak self] in
self?.startThread(
with: cellViewModel.authorId,
openGroupServer: cellViewModel.threadOpenGroupServer,
openGroupPublicKey: cellViewModel.threadOpenGroupPublicKey
)
},
onProBadgeTapped: { [weak self, dependencies] in
dependencies[singleton: .sessionProState].showSessionProCTAIfNeeded(
.generic,
dismissType: .single,
afterClosed: { [weak self] in
self?.snInputView.updateNumberOfCharactersLeft(self?.snInputView.text ?? "")
},
presenting: { modal in
dependencies[singleton: .appContext].frontMostViewController?.present(modal, animated: true)
}
)
}
),
dataManager: dependencies[singleton: .imageDataManager]
)
)
)
present(userProfileModal, animated: true, completion: nil)
self?.present(userProfileModal, animated: true, completion: nil)
}
}

func startThread(
Expand Down
2 changes: 1 addition & 1 deletion Session/Conversations/ConversationVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ final class ConversationVC: BaseVC, LibSessionRespondingViewController, Conversa
private lazy var tableViewTapGesture: UITapGestureRecognizer = {
let result: UITapGestureRecognizer = UITapGestureRecognizer()
result.delegate = self
result.addTarget(self, action: #selector(dismissKeyboardOnTap))
result.addTarget(self, action: #selector(dismissKeyboardOnMessageListTap))
result.cancelsTouchesInView = false

return result
Expand Down
22 changes: 12 additions & 10 deletions Session/Conversations/Settings/ThreadSettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,7 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
private func toggleConversationPinnedStatus(currentPinnedPriority: Int32) {
let isCurrentlyPinned: Bool = (currentPinnedPriority > LibSession.visiblePriority)

if !isCurrentlyPinned && !dependencies[cache: .libSession].isSessionPro {
if !isCurrentlyPinned && dependencies[feature: .sessionProEnabled] && !dependencies[cache: .libSession].isSessionPro {
// TODO: [Database Relocation] Retrieve the full conversation list from lib session and check the pinnedPriority that way instead of using the database
dependencies[singleton: .storage].writeAsync (
updates: { [threadId, dependencies] db in
Expand Down Expand Up @@ -2039,16 +2039,18 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
numPinnedConversations > 0
else { return }

let sessionProModal: ModalHostingViewController = ModalHostingViewController(
modal: ProCTAModal(
delegate: dependencies[singleton: .sessionProState],
variant: .morePinnedConvos(
isGrandfathered: (numPinnedConversations > LibSession.PinnedConversationLimit)
),
dataManager: dependencies[singleton: .imageDataManager]
DispatchQueue.main.async {
let sessionProModal: ModalHostingViewController = ModalHostingViewController(
modal: ProCTAModal(
delegate: dependencies[singleton: .sessionProState],
variant: .morePinnedConvos(
isGrandfathered: (numPinnedConversations > LibSession.PinnedConversationLimit)
),
dataManager: dependencies[singleton: .imageDataManager]
)
)
)
self?.transitionToScreen(sessionProModal, transitionType: .present)
self?.transitionToScreen(sessionProModal, transitionType: .present)
}
}
)
return
Expand Down
11 changes: 8 additions & 3 deletions Session/Home/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ public class HomeViewModel: NavigatableStateHolder {
profileCache[eventValue.id] = userProfile
}


/// Then handle database events
if !dependencies[singleton: .storage].isSuspended, let databaseEvents: Set<ObservedEvent> = splitEvents[.databaseQuery], !databaseEvents.isEmpty {
do {
Expand Down Expand Up @@ -383,8 +382,14 @@ public class HomeViewModel: NavigatableStateHolder {
.fetchCount(db)
}

/// Update loaded page info as needed
if loadPageEvent != nil || !insertedIds.isEmpty || !deletedIds.isEmpty {
/// Update loaded page info as needed (any change to a conversation could result in an order change so reload
/// the paged data if needed (as that will fetch the correct order)
if
loadPageEvent != nil ||
!idsNeedingRequery.isEmpty ||
!insertedIds.isEmpty ||
!deletedIds.isEmpty
{
loadResult = try loadResult.load(
db,
target: (
Expand Down
53 changes: 29 additions & 24 deletions Session/Media Viewing & Editing/MessageInfoScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -539,14 +539,17 @@ struct MessageInfoScreen: View {
guard dependencies[feature: .sessionProEnabled] && (!dependencies[cache: .libSession].isSessionPro) else {
return
}
let sessionProModal: ModalHostingViewController = ModalHostingViewController(
modal: ProCTAModal(
delegate: dependencies[singleton: .sessionProState],
variant: proCTAVariant,
dataManager: dependencies[singleton: .imageDataManager]

DispatchQueue.main.async {
let sessionProModal: ModalHostingViewController = ModalHostingViewController(
modal: ProCTAModal(
delegate: dependencies[singleton: .sessionProState],
variant: proCTAVariant,
dataManager: dependencies[singleton: .imageDataManager]
)
)
)
self.host.controller?.present(sessionProModal, animated: true)
self.host.controller?.present(sessionProModal, animated: true)
}
}

func showUserProfileModal() {
Expand Down Expand Up @@ -623,24 +626,26 @@ struct MessageInfoScreen: View {
)
}()

let userProfileModal: ModalHostingViewController = ModalHostingViewController(
modal: UserProfileModal(
info: .init(
sessionId: sessionId,
blindedId: blindedId,
qrCodeImage: qrCodeImage,
profileInfo: profileInfo,
displayName: displayName,
contactDisplayName: contactDisplayName,
isProUser: dependencies.mutate(cache: .libSession, { $0.validateProProof(for: messageViewModel.profile) }),
isMessageRequestsEnabled: isMessasgeRequestsEnabled,
onStartThread: self.onStartThread,
onProBadgeTapped: self.showSessionProCTAIfNeeded
),
dataManager: dependencies[singleton: .imageDataManager]
DispatchQueue.main.async {
let userProfileModal: ModalHostingViewController = ModalHostingViewController(
modal: UserProfileModal(
info: .init(
sessionId: sessionId,
blindedId: blindedId,
qrCodeImage: qrCodeImage,
profileInfo: profileInfo,
displayName: displayName,
contactDisplayName: contactDisplayName,
isProUser: dependencies.mutate(cache: .libSession, { $0.validateProProof(for: messageViewModel.profile) }),
isMessageRequestsEnabled: isMessasgeRequestsEnabled,
onStartThread: self.onStartThread,
onProBadgeTapped: self.showSessionProCTAIfNeeded
),
dataManager: dependencies[singleton: .imageDataManager]
)
)
)
self.host.controller?.present(userProfileModal, animated: true, completion: nil)
self.host.controller?.present(userProfileModal, animated: true, completion: nil)
}
}

private func showMediaFullScreen(attachment: Attachment) {
Expand Down
23 changes: 14 additions & 9 deletions Session/Onboarding/Onboarding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,15 @@ extension Onboarding {

/// If we don't have the `Note to Self` thread then create it (not visible by default)
if (try? SessionThread.exists(db, id: userSessionId.hexString)) != nil {
try SessionThread.upsert(
db,
id: userSessionId.hexString,
variant: .contact,
values: SessionThread.TargetValues(shouldBeVisible: .setTo(false)),
using: dependencies
)
try ThreadCreationContext.$isOnboarding.withValue(true) {
try SessionThread.upsert(
db,
id: userSessionId.hexString,
variant: .contact,
values: SessionThread.TargetValues(shouldBeVisible: .setTo(false)),
using: dependencies
)
}
}

/// Update the `displayName` if changed
Expand Down Expand Up @@ -440,8 +442,11 @@ extension Onboarding {
}
},
completion: { _ in
/// No need to show the seed again if the user is restoring
dependencies.setAsync(.hasViewedSeed, (initialFlow == .restore))
/// No need to show the seed again if the user is restoring (just in case only set the value if it hasn't already
/// been set - this will prevent us from unintentionally re-showing the seed banner)
if !dependencies.mutate(cache: .libSession, { $0.has(.hasViewedSeed) }) {
dependencies.setAsync(.hasViewedSeed, (initialFlow == .restore))
}

/// Now that the onboarding process is completed we can store the `UserMetadata` for the Share and Notification
/// extensions (prior to this point the account is in an invalid state so they can't be used)
Expand Down
2 changes: 1 addition & 1 deletion Session/Utilities/DonationsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class DonationsManager {
/// case we _do_ want to show it)
let appInstallationDate: Date = {
guard !dependencies.hasSet(feature: .customFirstInstallDateTime) else {
return Date(timeIntervalSince1970: dependencies[feature: .customFirstInstallDateTime] ?? 0)
return Date(timeIntervalSince1970: dependencies[feature: .customFirstInstallDateTime])
}

let attributes: [FileAttributeKey: Any]? = try? dependencies[singleton: .fileManager]
Expand Down
33 changes: 17 additions & 16 deletions Session/Utilities/UIContextualAction+Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,16 @@ public extension UIContextualAction {
indexPath: indexPath,
tableView: tableView
) { _, _, completionHandler in
if !isCurrentlyPinned,
!dependencies[cache: .libSession].isSessionPro,
let pinnedConversationsNumber: Int = dependencies[singleton: .storage].read({ db in
try SessionThread
.filter(SessionThread.Columns.pinnedPriority > 0)
.fetchCount(db)
}),
pinnedConversationsNumber >= LibSession.PinnedConversationLimit
if
dependencies[feature: .sessionProEnabled],
!isCurrentlyPinned,
!dependencies[cache: .libSession].isSessionPro,
let pinnedConversationsNumber: Int = dependencies[singleton: .storage].read({ db in
try SessionThread
.filter(SessionThread.Columns.pinnedPriority > 0)
.fetchCount(db)
}),
pinnedConversationsNumber >= LibSession.PinnedConversationLimit
{
let sessionProModal: ModalHostingViewController = ModalHostingViewController(
modal: ProCTAModal(
Expand All @@ -259,14 +261,13 @@ public extension UIContextualAction {
// Delay the change to give the cell "unswipe" animation some time to complete
DispatchQueue.global(qos: .default).asyncAfter(deadline: .now() + unswipeAnimationDelay) {
dependencies[singleton: .storage].writeAsync { db in
try SessionThread
.filter(id: threadViewModel.threadId)
.updateAllAndConfig(
db,
SessionThread.Columns.pinnedPriority
.set(to: (isCurrentlyPinned ? 0 : 1)),
using: dependencies
)
try SessionThread.updateVisibility(
db,
threadId: threadViewModel.threadId,
isVisible: true,
customPriority: (isCurrentlyPinned ? LibSession.visiblePriority : 1),
using: dependencies
)
}
}
}
Expand Down
Loading