Skip to content

Commit ec4d989

Browse files
authored
Merge pull request #640 from session-foundation/dev
Release 2.14.7 RC2
2 parents 0eeb869 + 5d81d9c commit ec4d989

File tree

12 files changed

+148
-115
lines changed

12 files changed

+148
-115
lines changed

Session.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8547,7 +8547,7 @@
85478547
CODE_SIGN_IDENTITY = "iPhone Developer";
85488548
COMPILE_LIB_SESSION = "";
85498549
COPY_PHASE_STRIP = NO;
8550-
CURRENT_PROJECT_VERSION = 665;
8550+
CURRENT_PROJECT_VERSION = 668;
85518551
ENABLE_BITCODE = NO;
85528552
ENABLE_STRICT_OBJC_MSGSEND = YES;
85538553
ENABLE_TESTABILITY = YES;
@@ -8628,7 +8628,7 @@
86288628
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
86298629
CODE_SIGN_IDENTITY = "iPhone Distribution";
86308630
COMPILE_LIB_SESSION = "";
8631-
CURRENT_PROJECT_VERSION = 665;
8631+
CURRENT_PROJECT_VERSION = 668;
86328632
ENABLE_BITCODE = NO;
86338633
ENABLE_MODULE_VERIFIER = YES;
86348634
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -9328,7 +9328,7 @@
93289328
CODE_SIGN_IDENTITY = "iPhone Developer";
93299329
COMPILE_LIB_SESSION = YES;
93309330
COPY_PHASE_STRIP = NO;
9331-
CURRENT_PROJECT_VERSION = 665;
9331+
CURRENT_PROJECT_VERSION = 668;
93329332
ENABLE_BITCODE = NO;
93339333
ENABLE_STRICT_OBJC_MSGSEND = YES;
93349334
ENABLE_TESTABILITY = YES;
@@ -9917,7 +9917,7 @@
99179917
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
99189918
CODE_SIGN_IDENTITY = "iPhone Distribution";
99199919
COMPILE_LIB_SESSION = YES;
9920-
CURRENT_PROJECT_VERSION = 665;
9920+
CURRENT_PROJECT_VERSION = 668;
99219921
ENABLE_BITCODE = NO;
99229922
ENABLE_STRICT_OBJC_MSGSEND = YES;
99239923
GCC_NO_COMMON_BLOCKS = YES;

Session/Conversations/ConversationVC+Interaction.swift

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ extension ConversationVC:
3535
}
3636

3737
// Handle taps outside of tableview cell to dismiss keyboard
38-
@MainActor @objc func dismissKeyboardOnTap(_ recognizer: UITapGestureRecognizer) {
39-
/// If the tap was inside the "Send" button on the input then we **don't** want to dismiss the keyboard (the user should be
40-
/// able to send multiple messages in a row)
41-
let location: CGPoint = recognizer.location(in: self.snInputView.sendButton)
38+
@MainActor @objc func dismissKeyboardOnMessageListTap(_ recognizer: UITapGestureRecognizer) {
39+
/// 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
40+
/// current text, or tap the buttons without the keyboard being dismissed)
41+
let location: CGPoint = recognizer.location(in: self.snInputView)
4242

43-
guard !snInputView.sendButton.bounds.contains(location) else { return }
43+
guard !snInputView.bounds.contains(location) else { return }
4444

4545
_ = self.snInputView.resignFirstResponder()
4646
}
@@ -1642,41 +1642,43 @@ extension ConversationVC:
16421642
return cellViewModel.profile?.blocksCommunityMessageRequests != true
16431643
}()
16441644

1645-
let userProfileModal: ModalHostingViewController = ModalHostingViewController(
1646-
modal: UserProfileModal(
1647-
info: .init(
1648-
sessionId: sessionId,
1649-
blindedId: blindedId,
1650-
qrCodeImage: qrCodeImage,
1651-
profileInfo: profileInfo,
1652-
displayName: displayName,
1653-
contactDisplayName: contactDisplayName,
1654-
isProUser: dependencies.mutate(cache: .libSession, { $0.validateProProof(for: cellViewModel.profile) }),
1655-
isMessageRequestsEnabled: isMessasgeRequestsEnabled,
1656-
onStartThread: { [weak self] in
1657-
self?.startThread(
1658-
with: cellViewModel.authorId,
1659-
openGroupServer: cellViewModel.threadOpenGroupServer,
1660-
openGroupPublicKey: cellViewModel.threadOpenGroupPublicKey
1661-
)
1662-
},
1663-
onProBadgeTapped: { [weak self, dependencies] in
1664-
dependencies[singleton: .sessionProState].showSessionProCTAIfNeeded(
1665-
.generic,
1666-
dismissType: .single,
1667-
afterClosed: { [weak self] in
1668-
self?.snInputView.updateNumberOfCharactersLeft(self?.snInputView.text ?? "")
1669-
},
1670-
presenting: { modal in
1671-
dependencies[singleton: .appContext].frontMostViewController?.present(modal, animated: true)
1672-
}
1673-
)
1674-
}
1675-
),
1676-
dataManager: dependencies[singleton: .imageDataManager]
1645+
DispatchQueue.main.async { [weak self] in
1646+
let userProfileModal: ModalHostingViewController = ModalHostingViewController(
1647+
modal: UserProfileModal(
1648+
info: .init(
1649+
sessionId: sessionId,
1650+
blindedId: blindedId,
1651+
qrCodeImage: qrCodeImage,
1652+
profileInfo: profileInfo,
1653+
displayName: displayName,
1654+
contactDisplayName: contactDisplayName,
1655+
isProUser: dependencies.mutate(cache: .libSession, { $0.validateProProof(for: cellViewModel.profile) }),
1656+
isMessageRequestsEnabled: isMessasgeRequestsEnabled,
1657+
onStartThread: { [weak self] in
1658+
self?.startThread(
1659+
with: cellViewModel.authorId,
1660+
openGroupServer: cellViewModel.threadOpenGroupServer,
1661+
openGroupPublicKey: cellViewModel.threadOpenGroupPublicKey
1662+
)
1663+
},
1664+
onProBadgeTapped: { [weak self, dependencies] in
1665+
dependencies[singleton: .sessionProState].showSessionProCTAIfNeeded(
1666+
.generic,
1667+
dismissType: .single,
1668+
afterClosed: { [weak self] in
1669+
self?.snInputView.updateNumberOfCharactersLeft(self?.snInputView.text ?? "")
1670+
},
1671+
presenting: { modal in
1672+
dependencies[singleton: .appContext].frontMostViewController?.present(modal, animated: true)
1673+
}
1674+
)
1675+
}
1676+
),
1677+
dataManager: dependencies[singleton: .imageDataManager]
1678+
)
16771679
)
1678-
)
1679-
present(userProfileModal, animated: true, completion: nil)
1680+
self?.present(userProfileModal, animated: true, completion: nil)
1681+
}
16801682
}
16811683

16821684
func startThread(

Session/Conversations/ConversationVC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ final class ConversationVC: BaseVC, LibSessionRespondingViewController, Conversa
453453
private lazy var tableViewTapGesture: UITapGestureRecognizer = {
454454
let result: UITapGestureRecognizer = UITapGestureRecognizer()
455455
result.delegate = self
456-
result.addTarget(self, action: #selector(dismissKeyboardOnTap))
456+
result.addTarget(self, action: #selector(dismissKeyboardOnMessageListTap))
457457
result.cancelsTouchesInView = false
458458

459459
return result

Session/Conversations/Settings/ThreadSettingsViewModel.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,7 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi
20102010
private func toggleConversationPinnedStatus(currentPinnedPriority: Int32) {
20112011
let isCurrentlyPinned: Bool = (currentPinnedPriority > LibSession.visiblePriority)
20122012

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

2042-
let sessionProModal: ModalHostingViewController = ModalHostingViewController(
2043-
modal: ProCTAModal(
2044-
delegate: dependencies[singleton: .sessionProState],
2045-
variant: .morePinnedConvos(
2046-
isGrandfathered: (numPinnedConversations > LibSession.PinnedConversationLimit)
2047-
),
2048-
dataManager: dependencies[singleton: .imageDataManager]
2042+
DispatchQueue.main.async {
2043+
let sessionProModal: ModalHostingViewController = ModalHostingViewController(
2044+
modal: ProCTAModal(
2045+
delegate: dependencies[singleton: .sessionProState],
2046+
variant: .morePinnedConvos(
2047+
isGrandfathered: (numPinnedConversations > LibSession.PinnedConversationLimit)
2048+
),
2049+
dataManager: dependencies[singleton: .imageDataManager]
2050+
)
20492051
)
2050-
)
2051-
self?.transitionToScreen(sessionProModal, transitionType: .present)
2052+
self?.transitionToScreen(sessionProModal, transitionType: .present)
2053+
}
20522054
}
20532055
)
20542056
return

Session/Home/HomeViewModel.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ public class HomeViewModel: NavigatableStateHolder {
306306
profileCache[eventValue.id] = userProfile
307307
}
308308

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

386-
/// Update loaded page info as needed
387-
if loadPageEvent != nil || !insertedIds.isEmpty || !deletedIds.isEmpty {
385+
/// Update loaded page info as needed (any change to a conversation could result in an order change so reload
386+
/// the paged data if needed (as that will fetch the correct order)
387+
if
388+
loadPageEvent != nil ||
389+
!idsNeedingRequery.isEmpty ||
390+
!insertedIds.isEmpty ||
391+
!deletedIds.isEmpty
392+
{
388393
loadResult = try loadResult.load(
389394
db,
390395
target: (

Session/Media Viewing & Editing/MessageInfoScreen.swift

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -539,14 +539,17 @@ struct MessageInfoScreen: View {
539539
guard dependencies[feature: .sessionProEnabled] && (!dependencies[cache: .libSession].isSessionPro) else {
540540
return
541541
}
542-
let sessionProModal: ModalHostingViewController = ModalHostingViewController(
543-
modal: ProCTAModal(
544-
delegate: dependencies[singleton: .sessionProState],
545-
variant: proCTAVariant,
546-
dataManager: dependencies[singleton: .imageDataManager]
542+
543+
DispatchQueue.main.async {
544+
let sessionProModal: ModalHostingViewController = ModalHostingViewController(
545+
modal: ProCTAModal(
546+
delegate: dependencies[singleton: .sessionProState],
547+
variant: proCTAVariant,
548+
dataManager: dependencies[singleton: .imageDataManager]
549+
)
547550
)
548-
)
549-
self.host.controller?.present(sessionProModal, animated: true)
551+
self.host.controller?.present(sessionProModal, animated: true)
552+
}
550553
}
551554

552555
func showUserProfileModal() {
@@ -623,24 +626,26 @@ struct MessageInfoScreen: View {
623626
)
624627
}()
625628

626-
let userProfileModal: ModalHostingViewController = ModalHostingViewController(
627-
modal: UserProfileModal(
628-
info: .init(
629-
sessionId: sessionId,
630-
blindedId: blindedId,
631-
qrCodeImage: qrCodeImage,
632-
profileInfo: profileInfo,
633-
displayName: displayName,
634-
contactDisplayName: contactDisplayName,
635-
isProUser: dependencies.mutate(cache: .libSession, { $0.validateProProof(for: messageViewModel.profile) }),
636-
isMessageRequestsEnabled: isMessasgeRequestsEnabled,
637-
onStartThread: self.onStartThread,
638-
onProBadgeTapped: self.showSessionProCTAIfNeeded
639-
),
640-
dataManager: dependencies[singleton: .imageDataManager]
629+
DispatchQueue.main.async {
630+
let userProfileModal: ModalHostingViewController = ModalHostingViewController(
631+
modal: UserProfileModal(
632+
info: .init(
633+
sessionId: sessionId,
634+
blindedId: blindedId,
635+
qrCodeImage: qrCodeImage,
636+
profileInfo: profileInfo,
637+
displayName: displayName,
638+
contactDisplayName: contactDisplayName,
639+
isProUser: dependencies.mutate(cache: .libSession, { $0.validateProProof(for: messageViewModel.profile) }),
640+
isMessageRequestsEnabled: isMessasgeRequestsEnabled,
641+
onStartThread: self.onStartThread,
642+
onProBadgeTapped: self.showSessionProCTAIfNeeded
643+
),
644+
dataManager: dependencies[singleton: .imageDataManager]
645+
)
641646
)
642-
)
643-
self.host.controller?.present(userProfileModal, animated: true, completion: nil)
647+
self.host.controller?.present(userProfileModal, animated: true, completion: nil)
648+
}
644649
}
645650

646651
private func showMediaFullScreen(attachment: Attachment) {

Session/Onboarding/Onboarding.swift

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,15 @@ extension Onboarding {
396396

397397
/// If we don't have the `Note to Self` thread then create it (not visible by default)
398398
if (try? SessionThread.exists(db, id: userSessionId.hexString)) != nil {
399-
try SessionThread.upsert(
400-
db,
401-
id: userSessionId.hexString,
402-
variant: .contact,
403-
values: SessionThread.TargetValues(shouldBeVisible: .setTo(false)),
404-
using: dependencies
405-
)
399+
try ThreadCreationContext.$isOnboarding.withValue(true) {
400+
try SessionThread.upsert(
401+
db,
402+
id: userSessionId.hexString,
403+
variant: .contact,
404+
values: SessionThread.TargetValues(shouldBeVisible: .setTo(false)),
405+
using: dependencies
406+
)
407+
}
406408
}
407409

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

446451
/// Now that the onboarding process is completed we can store the `UserMetadata` for the Share and Notification
447452
/// extensions (prior to this point the account is in an invalid state so they can't be used)

Session/Utilities/DonationsManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class DonationsManager {
5757
/// case we _do_ want to show it)
5858
let appInstallationDate: Date = {
5959
guard !dependencies.hasSet(feature: .customFirstInstallDateTime) else {
60-
return Date(timeIntervalSince1970: dependencies[feature: .customFirstInstallDateTime] ?? 0)
60+
return Date(timeIntervalSince1970: dependencies[feature: .customFirstInstallDateTime])
6161
}
6262

6363
let attributes: [FileAttributeKey: Any]? = try? dependencies[singleton: .fileManager]

Session/Utilities/UIContextualAction+Utilities.swift

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,16 @@ public extension UIContextualAction {
227227
indexPath: indexPath,
228228
tableView: tableView
229229
) { _, _, completionHandler in
230-
if !isCurrentlyPinned,
231-
!dependencies[cache: .libSession].isSessionPro,
232-
let pinnedConversationsNumber: Int = dependencies[singleton: .storage].read({ db in
233-
try SessionThread
234-
.filter(SessionThread.Columns.pinnedPriority > 0)
235-
.fetchCount(db)
236-
}),
237-
pinnedConversationsNumber >= LibSession.PinnedConversationLimit
230+
if
231+
dependencies[feature: .sessionProEnabled],
232+
!isCurrentlyPinned,
233+
!dependencies[cache: .libSession].isSessionPro,
234+
let pinnedConversationsNumber: Int = dependencies[singleton: .storage].read({ db in
235+
try SessionThread
236+
.filter(SessionThread.Columns.pinnedPriority > 0)
237+
.fetchCount(db)
238+
}),
239+
pinnedConversationsNumber >= LibSession.PinnedConversationLimit
238240
{
239241
let sessionProModal: ModalHostingViewController = ModalHostingViewController(
240242
modal: ProCTAModal(
@@ -259,14 +261,13 @@ public extension UIContextualAction {
259261
// Delay the change to give the cell "unswipe" animation some time to complete
260262
DispatchQueue.global(qos: .default).asyncAfter(deadline: .now() + unswipeAnimationDelay) {
261263
dependencies[singleton: .storage].writeAsync { db in
262-
try SessionThread
263-
.filter(id: threadViewModel.threadId)
264-
.updateAllAndConfig(
265-
db,
266-
SessionThread.Columns.pinnedPriority
267-
.set(to: (isCurrentlyPinned ? 0 : 1)),
268-
using: dependencies
269-
)
264+
try SessionThread.updateVisibility(
265+
db,
266+
threadId: threadViewModel.threadId,
267+
isVisible: true,
268+
customPriority: (isCurrentlyPinned ? LibSession.visiblePriority : 1),
269+
using: dependencies
270+
)
270271
}
271272
}
272273
}

0 commit comments

Comments
 (0)