diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 3bc7bd3d4..d2a18306b 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -138,6 +138,7 @@ 76EB054018170B33006006FC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EB03C318170B33006006FC /* AppDelegate.m */; }; 7B4C75CB26B37E0F0000AC89 /* UnsendRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4C75CA26B37E0F0000AC89 /* UnsendRequest.swift */; }; 7B4C75CD26BB92060000AC89 /* DeletedMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4C75CC26BB92060000AC89 /* DeletedMessageView.swift */; }; + 7B7CB18B270591630079FF93 /* ShareLogsModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B7CB18A270591630079FF93 /* ShareLogsModal.swift */; }; 7BC01A3E241F40AB00BC7C55 /* NotificationServiceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BC01A3D241F40AB00BC7C55 /* NotificationServiceExtension.swift */; }; 7BC01A42241F40AB00BC7C55 /* SessionNotificationServiceExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 7BC01A3B241F40AB00BC7C55 /* SessionNotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 7BDCFC08242186E700641C39 /* NotificationServiceExtensionContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDCFC07242186E700641C39 /* NotificationServiceExtensionContext.swift */; }; @@ -1103,6 +1104,7 @@ 7B2DB2AD26F1B0FF0035B509 /* si */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = si; path = si.lproj/Localizable.strings; sourceTree = ""; }; 7B4C75CA26B37E0F0000AC89 /* UnsendRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnsendRequest.swift; sourceTree = ""; }; 7B4C75CC26BB92060000AC89 /* DeletedMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeletedMessageView.swift; sourceTree = ""; }; + 7B7CB18A270591630079FF93 /* ShareLogsModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareLogsModal.swift; sourceTree = ""; }; 7BC01A3B241F40AB00BC7C55 /* SessionNotificationServiceExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = SessionNotificationServiceExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 7BC01A3D241F40AB00BC7C55 /* NotificationServiceExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationServiceExtension.swift; sourceTree = ""; }; 7BC01A3F241F40AB00BC7C55 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -2772,6 +2774,7 @@ B886B4A62398B23E00211ABE /* QRCodeVC.swift */, B86BD08523399CEF000F5AE3 /* SeedModal.swift */, B8CCF6422397711F0091D419 /* SettingsVC.swift */, + 7B7CB18A270591630079FF93 /* ShareLogsModal.swift */, ); path = Settings; sourceTree = ""; @@ -4767,6 +4770,7 @@ 3496955D219B605E00DCFE74 /* PhotoCollectionPickerController.swift in Sources */, 34B0796D1FCF46B100E248C2 /* MainAppContext.m in Sources */, 34A8B3512190A40E00218A25 /* MediaAlbumView.swift in Sources */, + 7B7CB18B270591630079FF93 /* ShareLogsModal.swift in Sources */, 4C4AEC4520EC343B0020E72B /* DismissableTextField.swift in Sources */, 3496955E219B605E00DCFE74 /* PhotoLibrary.swift in Sources */, C3A76A8D25DB83F90074CB90 /* PermissionMissingModal.swift in Sources */, diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index cc4445e25..fe75af3e7 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -167,7 +167,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat Storage.read { transaction in unreadCount = self.thread.unreadMessageCount(transaction: transaction) } - let clampedUnreadCount = min(unreadCount, UInt(kConversationInitialMaxRangeSize)) + let clampedUnreadCount = min(unreadCount, UInt(kConversationInitialMaxRangeSize), UInt(viewItems.endIndex)) unreadViewItems = clampedUnreadCount != 0 ? [ConversationViewItem](viewItems[viewItems.endIndex - Int(clampedUnreadCount) ..< viewItems.endIndex]) : [] } @@ -443,6 +443,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat func markAllAsRead() { guard let lastSortID = viewItems.last?.interaction.sortId else { return } OWSReadReceiptManager.shared().markAsReadLocally(beforeSortId: lastSortID, thread: thread) + SSKEnvironment.shared.disappearingMessagesJob.cleanupMessagesWhichFailedToStartExpiringFromNow() } func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { diff --git a/Session/Conversations/Message Cells/Content Views/QuoteView.swift b/Session/Conversations/Message Cells/Content Views/QuoteView.swift index e3c45e9cb..a32e07724 100644 --- a/Session/Conversations/Message Cells/Content Views/QuoteView.swift +++ b/Session/Conversations/Message Cells/Content Views/QuoteView.swift @@ -167,7 +167,7 @@ final class QuoteView : UIView { if !hasAttachments { mainStackView.addArrangedSubview(lineView) } else { - let isAudio = MIMETypeUtil.isAudio(attachments.first!.contentType!) + let isAudio = MIMETypeUtil.isAudio(attachments.first!.contentType ?? "") let fallbackImageName = isAudio ? "attachment_audio" : "actionsheet_document_black" let fallbackImage = UIImage(named: fallbackImageName)?.withTint(.white)?.resizedImage(to: CGSize(width: iconSize, height: iconSize)) let imageView = UIImageView(image: thumbnail ?? fallbackImage) diff --git a/Session/Meta/AppEnvironment.swift b/Session/Meta/AppEnvironment.swift index 2aa581a91..805df0d81 100644 --- a/Session/Meta/AppEnvironment.swift +++ b/Session/Meta/AppEnvironment.swift @@ -36,6 +36,9 @@ import SignalUtilitiesKit @objc public var backup: OWSBackup + + @objc + public var fileLogger: DDFileLogger // Stored properties cannot be marked as `@available`, only classes and functions. // Instead, store a private `Any` and wrap it with a public `@available` getter @@ -56,6 +59,7 @@ import SignalUtilitiesKit self.backup = OWSBackup() self.backupLazyRestore = BackupLazyRestore() self._userNotificationActionHandler = UserNotificationActionHandler() + self.fileLogger = DDFileLogger() super.init() @@ -66,5 +70,12 @@ import SignalUtilitiesKit public func setup() { // Hang certain singletons on SSKEnvironment too. SSKEnvironment.shared.notificationsManager = notificationPresenter + setupLogFiles() + } + + private func setupLogFiles() { + fileLogger.rollingFrequency = kDayInterval // Refresh everyday + fileLogger.logFileManager.maximumNumberOfLogFiles = 3 // Save 3 days' log files + DDLog.add(fileLogger) } } diff --git a/Session/Meta/Translations/de.lproj/Localizable.strings b/Session/Meta/Translations/de.lproj/Localizable.strings index 50b71fb77..75a37c6a9 100644 --- a/Session/Meta/Translations/de.lproj/Localizable.strings +++ b/Session/Meta/Translations/de.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Link-Vorschau aktivieren?"; "modal_link_previews_explanation" = "Das Aktivieren von Link-Vorschauen zeigt Vorschaubilder für URLs, die Sie senden und empfangen. Dies kann nützlich sein, aber Session muss verlinkte Webseiten kontaktieren, um Vorschaubilder zu generieren. Du kannst die Link-Vorschau in den Session-Einstellungen immer deaktivieren."; "modal_link_previews_button_title" = "Aktivieren"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Mit Session teilen"; "vc_share_loading_message" = "Anlagen werden vorbereitet..."; "vc_share_sending_message" = "Wird gesendet ..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Mitglieder hinzufügen"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/en.lproj/Localizable.strings b/Session/Meta/Translations/en.lproj/Localizable.strings index d5f10cc5b..86277878a 100644 --- a/Session/Meta/Translations/en.lproj/Localizable.strings +++ b/Session/Meta/Translations/en.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Enable Link Previews?"; "modal_link_previews_explanation" = "Enabling link previews will show previews for URLs you send and receive. This can be useful, but Session will need to contact linked websites to generate previews. You can always disable link previews in Session's settings."; "modal_link_previews_button_title" = "Enable"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Share to Session"; "vc_share_loading_message" = "Preparing attachments..."; "vc_share_sending_message" = "Sending..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Add Members"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/es.lproj/Localizable.strings b/Session/Meta/Translations/es.lproj/Localizable.strings index 4317d8ca7..11726392c 100644 --- a/Session/Meta/Translations/es.lproj/Localizable.strings +++ b/Session/Meta/Translations/es.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "¿Habilitar Previsualizaciones de Enlace?"; "modal_link_previews_explanation" = "Activar vista previa de enlaces mostrará las vistas previas para las URL que envíe y reciba. Esto puede ser útil, pero Session tendrá que ponerse en contacto con los sitios web enlazados para generar vistas previas. Siempre puedes desactivar las vistas previas de enlaces en la configuración de Session."; "modal_link_previews_button_title" = "Activar"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Compartir en Session"; "vc_share_loading_message" = "Preparando archivos adjuntos..."; "vc_share_sending_message" = "Enviando..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Añadir Miembros"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/fa.lproj/Localizable.strings b/Session/Meta/Translations/fa.lproj/Localizable.strings index 7f2645bbe..eb1e06929 100644 --- a/Session/Meta/Translations/fa.lproj/Localizable.strings +++ b/Session/Meta/Translations/fa.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "فعال‌سازی پیش‌نمایش لینک؟"; "modal_link_previews_explanation" = "Enabling link previews will show previews for URLs you send and receive. This can be useful, but Session will need to contact linked websites to generate previews. You can always disable link previews in Session's settings."; "modal_link_previews_button_title" = "فعال سازی"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "اشتراک گذاری با Session"; "vc_share_loading_message" = "آماده سازی پیوست‌ها..."; "vc_share_sending_message" = "در حال ارسال..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Add Members"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/fi.lproj/Localizable.strings b/Session/Meta/Translations/fi.lproj/Localizable.strings index 319c43001..630a92fc6 100644 --- a/Session/Meta/Translations/fi.lproj/Localizable.strings +++ b/Session/Meta/Translations/fi.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Ota linkkien esikatselu käyttöön?"; "modal_link_previews_explanation" = "Enabling link previews will show previews for URLs you send and receive. This can be useful, but Session will need to contact linked websites to generate previews. You can always disable link previews in Session's settings."; "modal_link_previews_button_title" = "Ota käyttöön"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Jaa Sessioniin"; "vc_share_loading_message" = "Valmistellaan liitteitä..."; "vc_share_sending_message" = "Lähetetään..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Lisää jäseniä"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/fr.lproj/Localizable.strings b/Session/Meta/Translations/fr.lproj/Localizable.strings index 81a7d62d9..3904fc388 100644 --- a/Session/Meta/Translations/fr.lproj/Localizable.strings +++ b/Session/Meta/Translations/fr.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Activer les aperçus de lien?"; "modal_link_previews_explanation" = "L'activation des aperçus de lien affichera des aperçus pour les URL que vous envoyez et recevez. Cela peut être utile, mais Session devra contacter les sites Web liés pour générer des aperçus. Vous pouvez toujours désactiver les aperçus de lien dans les paramètres de Session."; "modal_link_previews_button_title" = "Activer"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Partager en Session"; "vc_share_loading_message" = "Préparation des pièces jointes ..."; "vc_share_sending_message" = "Envoi..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Ajouter des membres"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/hi.lproj/Localizable.strings b/Session/Meta/Translations/hi.lproj/Localizable.strings index 01a613910..5fb80be9c 100644 --- a/Session/Meta/Translations/hi.lproj/Localizable.strings +++ b/Session/Meta/Translations/hi.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "लिंक पूर्वावलोकन सक्षम करें?"; "modal_link_previews_explanation" = "लिंक पूर्वावलोकन सक्षम करने से आपके द्वारा भेजे और प्राप्त किए जाने वाले URL के पूर्वावलोकन दिखाई देंगे. यह उपयोगी हो सकता है, लेकिन Session को पूर्वावलोकन उत्पन्न करने के लिए लिंक की गई वेबसाइटों से संपर्क करने की आवश्यकता होगी। आप कभी भी Session की सेटिंग में लिंक पूर्वावलोकन अक्षम कर सकते हैं।"; "modal_link_previews_button_title" = "सक्षम करें"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "सत्र में साझा करें"; "vc_share_loading_message" = "अटैचमेंट तैयार किए जा रहे हैं..."; "vc_share_sending_message" = "भेजा जा रहा है..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "सदस्य जोड़ें"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/hr.lproj/Localizable.strings b/Session/Meta/Translations/hr.lproj/Localizable.strings index 67906feec..f00a6d2b1 100644 --- a/Session/Meta/Translations/hr.lproj/Localizable.strings +++ b/Session/Meta/Translations/hr.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Omogući preglede poveznica?"; "modal_link_previews_explanation" = "Omogućavanjem pregleda poveznica prikazat će se pregledi za URL-ove koje šaljete i primate. To može biti korisno, ali Session će trebati kontaktirati povezane web stranice kako bi generirao preglede. Uvijek možete onemogućiti preglede poveznica u postavkama Session-a."; "modal_link_previews_button_title" = "Uključi"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Podijeli sa Session-om"; "vc_share_loading_message" = "Priprema privitaka..."; "vc_share_sending_message" = "Slanje..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Dodaj članove"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/id-ID.lproj/Localizable.strings b/Session/Meta/Translations/id-ID.lproj/Localizable.strings index 24b7fbfb7..27f04eb17 100644 --- a/Session/Meta/Translations/id-ID.lproj/Localizable.strings +++ b/Session/Meta/Translations/id-ID.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Enable Link Previews?"; "modal_link_previews_explanation" = "Enabling link previews will show previews for URLs you send and receive. This can be useful, but Session will need to contact linked websites to generate previews. You can always disable link previews in Session's settings."; "modal_link_previews_button_title" = "Enable"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Share to Session"; "vc_share_loading_message" = "Preparing attachments..."; "vc_share_sending_message" = "Sending..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Add Members"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/it.lproj/Localizable.strings b/Session/Meta/Translations/it.lproj/Localizable.strings index fdce7ea5a..8d98bbe76 100644 --- a/Session/Meta/Translations/it.lproj/Localizable.strings +++ b/Session/Meta/Translations/it.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Abilitare Anteprima Link?"; "modal_link_previews_explanation" = "Abilitando le anteprime dei collegamenti Session mostrerà le anteprime degli URL che invii e ricevi. Questo può essere utile, ma Session dovrà contattare i siti web collegati per generare le anteprime. Puoi sempre disabilitare le anteprime dei link nelle impostazioni di Session."; "modal_link_previews_button_title" = "Abilita"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Condividi con Session"; "vc_share_loading_message" = "Preparazione allegati..."; "vc_share_sending_message" = "Invio..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Aggiungi membri"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/ja.lproj/Localizable.strings b/Session/Meta/Translations/ja.lproj/Localizable.strings index b5392771a..aa668b546 100644 --- a/Session/Meta/Translations/ja.lproj/Localizable.strings +++ b/Session/Meta/Translations/ja.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "リンクプレビューを有効にしますか?"; "modal_link_previews_explanation" = "リンクプレビューを有効すると、URLを送受信する場合にプレビューが表示されます。これは便利ですが、プレビューを作成するのにSessionはそのウェブサイトに接続する必要があります。Sessionの設定から、リンクプレビューをいつでも無効にできます。"; "modal_link_previews_button_title" = "有効にする"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Sessionと共有"; "vc_share_loading_message" = "添付ファイルを準備しています..."; "vc_share_sending_message" = "送信中…"; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "メンバーを追加する"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/nl.lproj/Localizable.strings b/Session/Meta/Translations/nl.lproj/Localizable.strings index c47613ed3..256148640 100644 --- a/Session/Meta/Translations/nl.lproj/Localizable.strings +++ b/Session/Meta/Translations/nl.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Linkvoorbeeld inschakelen?"; "modal_link_previews_explanation" = "Link previews inschakelen zal previews tonen voor URLs die u verstuurt en ontvangt. Dit kan nuttig zijn, maar Session moet contact opnemen met gekoppelde websites om previews te genereren. U kunt links altijd uitschakelen in de Session’s-instellingen."; "modal_link_previews_button_title" = "Inschakelen"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Delen naar de Session"; "vc_share_loading_message" = "Bijlagen voorbereiden..."; "vc_share_sending_message" = "Aan het verzenden..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Voeg deelnemers toe"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/pl.lproj/Localizable.strings b/Session/Meta/Translations/pl.lproj/Localizable.strings index 560858e0f..bcfe6f24f 100644 --- a/Session/Meta/Translations/pl.lproj/Localizable.strings +++ b/Session/Meta/Translations/pl.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Włączyć podgląd linków?"; "modal_link_previews_explanation" = "Włączanie podglądów linków wyświetli podgląd dla adresów URL które wysyłasz i otrzymujesz. Może to być użyteczne, ale Session będzie musiał się połączyć ze stronami których linki wysyłasz aby wygenerować podgląd. Możesz zawsze wyłączyć podgląd linków w ustawieniach Session."; "modal_link_previews_button_title" = "Włącz"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Udostępnij w Session"; "vc_share_loading_message" = "Przygotowywanie załączników..."; "vc_share_sending_message" = "Wysyłanie..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Dodaj użytkowników"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/pt_BR.lproj/Localizable.strings b/Session/Meta/Translations/pt_BR.lproj/Localizable.strings index e315fbc08..d01dc8ae8 100644 --- a/Session/Meta/Translations/pt_BR.lproj/Localizable.strings +++ b/Session/Meta/Translations/pt_BR.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Ativar pré-visualizações de link?"; "modal_link_previews_explanation" = "Ativar a pré-visualização de links irá mostrar as URLs que você receber e enviar. Isto pode ser útil, o Session precisa se conectar aos sites vinculados gerar as prévias. Você poderá desabiliatar esta opção nas configurações do Session."; "modal_link_previews_button_title" = "Ativar"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Compartilhar no Session"; "vc_share_loading_message" = "Preparando anexos..."; "vc_share_sending_message" = "Enviando..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Adicionar Membros"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/ru.lproj/Localizable.strings b/Session/Meta/Translations/ru.lproj/Localizable.strings index 56b90b7ef..7638277bf 100644 --- a/Session/Meta/Translations/ru.lproj/Localizable.strings +++ b/Session/Meta/Translations/ru.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Включить предварительный просмотр ссылок?"; "modal_link_previews_explanation" = "Включение предпросмотра ссылок покажет превью для отправляемых и получаемых ссылок. Это может быть полезно, но Session нужно будет соединиться с сайтами, связанными с ссылками, чтобы сгенерировать предпросмотр. Вы всегда можете отключить предпросмотр ссылок в настройках Session."; "modal_link_previews_button_title" = "Включить"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Поделиться в Session"; "vc_share_loading_message" = "Подготовка вложений..."; "vc_share_sending_message" = "Отправка..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Добавить участников"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/si.lproj/Localizable.strings b/Session/Meta/Translations/si.lproj/Localizable.strings index d5f10cc5b..86277878a 100644 --- a/Session/Meta/Translations/si.lproj/Localizable.strings +++ b/Session/Meta/Translations/si.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Enable Link Previews?"; "modal_link_previews_explanation" = "Enabling link previews will show previews for URLs you send and receive. This can be useful, but Session will need to contact linked websites to generate previews. You can always disable link previews in Session's settings."; "modal_link_previews_button_title" = "Enable"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Share to Session"; "vc_share_loading_message" = "Preparing attachments..."; "vc_share_sending_message" = "Sending..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Add Members"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/sk.lproj/Localizable.strings b/Session/Meta/Translations/sk.lproj/Localizable.strings index f7f2222d1..a576bf501 100644 --- a/Session/Meta/Translations/sk.lproj/Localizable.strings +++ b/Session/Meta/Translations/sk.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Povoliť náhľad odkazov?"; "modal_link_previews_explanation" = "Enabling link previews will show previews for URLs you send and receive. This can be useful, but Session will need to contact linked websites to generate previews. You can always disable link previews in Session's settings."; "modal_link_previews_button_title" = "Povoliť"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Share to Session"; "vc_share_loading_message" = "Pripravujú sa prílohy..."; "vc_share_sending_message" = "Odosiela sa..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Pridať členov"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/sv.lproj/Localizable.strings b/Session/Meta/Translations/sv.lproj/Localizable.strings index 8a36b41ff..9cb625b39 100644 --- a/Session/Meta/Translations/sv.lproj/Localizable.strings +++ b/Session/Meta/Translations/sv.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Aktivera förhandsgranskningar av länkar?"; "modal_link_previews_explanation" = "Om du aktiverar länkförhandsvisningar visas förhandsvisningar för URL: er du skickar och tar emot. Detta kan vara användbart, men sessionen måste kontakta länkade webbplatser för att generera förhandsvisningar. Du kan alltid inaktivera länkförhandsvisningar i sessionsinställningarna."; "modal_link_previews_button_title" = "Aktivera"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Dela i Session"; "vc_share_loading_message" = "Förbereder bilagor..."; "vc_share_sending_message" = "Skickar..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Lägg till medlemmar"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/th.lproj/Localizable.strings b/Session/Meta/Translations/th.lproj/Localizable.strings index aeb9632f3..154ddbf7f 100644 --- a/Session/Meta/Translations/th.lproj/Localizable.strings +++ b/Session/Meta/Translations/th.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "เปิดใช้งานการแสดงตัวอย่างลิงค์"; "modal_link_previews_explanation" = "การเปิดใช้งานการแสดงตัวอย่างลิงค์จะแสดงตัวอย่างสำหรับ URL ที่คุณส่งและรับ สิ่งนี้มีประโยชน์ แต่Sessionจะต้องติดต่อเว็บไซต์ที่เชื่อมโยงเพื่อสร้างตัวอย่าง คุณสามารถปิดการแสดงตัวอย่างลิงก์ได้ตลอดเวลาในการตั้งค่าของSession"; "modal_link_previews_button_title" = "เปิดใช้งาน"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "เชิญมาใช้ Session"; "vc_share_loading_message" = "รวบรวมสิ่งแนบ..."; "vc_share_sending_message" = "กำลังส่ง..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "เพิ่มสมาชิก"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/vi-VN.lproj/Localizable.strings b/Session/Meta/Translations/vi-VN.lproj/Localizable.strings index de5deaede..fe322da91 100644 --- a/Session/Meta/Translations/vi-VN.lproj/Localizable.strings +++ b/Session/Meta/Translations/vi-VN.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "Enable Link Previews?"; "modal_link_previews_explanation" = "Enabling link previews will show previews for URLs you send and receive. This can be useful, but Session will need to contact linked websites to generate previews. You can always disable link previews in Session's settings."; "modal_link_previews_button_title" = "Enable"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "Share to Session"; "vc_share_loading_message" = "Preparing attachments..."; "vc_share_sending_message" = "Sending..."; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "Add Members"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings b/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings index e337ac3bf..25e63d471 100644 --- a/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings +++ b/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "是否要啟用連結預覽?"; "modal_link_previews_explanation" = "啟用連結預覽將會讓您送出與接收的 URLs 啟用預覽,這是一項好用的功能,但是 Session 會需要連結這些網站來產生預覽,您可以隨時關閉連結預覽功能。"; "modal_link_previews_button_title" = "啟用"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "分享至 Session"; "vc_share_loading_message" = "準備附件中⋯"; "vc_share_sending_message" = "傳送中⋯"; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "新增成員"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Meta/Translations/zh_CN.lproj/Localizable.strings b/Session/Meta/Translations/zh_CN.lproj/Localizable.strings index 2e01912ef..810a534ad 100644 --- a/Session/Meta/Translations/zh_CN.lproj/Localizable.strings +++ b/Session/Meta/Translations/zh_CN.lproj/Localizable.strings @@ -538,6 +538,8 @@ "modal_link_previews_title" = "是否启用链接预览?"; "modal_link_previews_explanation" = "链接预览将为您发送或收到的URL生成预览内容。 该功能非常实用,但Session需要访问该链接指向的网站以生成预览。您可以随后在会话设置中禁用该功能。"; "modal_link_previews_button_title" = "启用"; +"modal_share_logs_title" = "Share Logs"; +"modal_share_logs_explanation" = "Would you like to export your application logs to be able to share for troubleshooting?"; "vc_share_title" = "分享到 Session"; "vc_share_loading_message" = "正在准备附件......"; "vc_share_sending_message" = "正在发送…"; @@ -545,6 +547,7 @@ "vc_conversation_settings_invite_button_title" = "添加成员"; "vc_settings_faq_button_title" = "FAQ"; "vc_settings_survey_button_title" = "Feedback / Survey"; +"vc_settings_support_button_title" = "Support"; "modal_send_seed_title" = "Warning"; "modal_send_seed_explanation" = "This is your recovery phrase. If you send it to someone they'll have full access to your account."; "modal_send_seed_send_button_title" = "Send"; diff --git a/Session/Notifications/AppNotifications.swift b/Session/Notifications/AppNotifications.swift index c482720cd..8199d1b4c 100644 --- a/Session/Notifications/AppNotifications.swift +++ b/Session/Notifications/AppNotifications.swift @@ -181,6 +181,7 @@ public class NotificationPresenter: NSObject, NotificationsProtocol { let senderName = Storage.shared.getContact(with: incomingMessage.authorId, using: transaction)?.displayName(for: context) ?? incomingMessage.authorId let notificationTitle: String? + let previewType = preferences.notificationPreviewType(with: transaction) switch previewType { case .noNameNoPreview: notificationTitle = nil diff --git a/Session/Notifications/UserNotificationsAdaptee.swift b/Session/Notifications/UserNotificationsAdaptee.swift index 45b9c2a5c..8d8b6ec21 100644 --- a/Session/Notifications/UserNotificationsAdaptee.swift +++ b/Session/Notifications/UserNotificationsAdaptee.swift @@ -108,15 +108,6 @@ extension UserNotificationPresenterAdaptee: NotificationPresenterAdaptee { cancelNotification(identifier: notificationIdentifier) } - let trigger: UNNotificationTrigger? - let checkForCancel = category == .incomingMessage - if checkForCancel { - assert(userInfo[AppNotificationUserInfoKey.threadId] != nil) - trigger = UNTimeIntervalNotificationTrigger(timeInterval: kNotificationDelayForRemoteRead, repeats: false) - } else { - trigger = nil - } - if shouldPresentNotification(category: category, userInfo: userInfo) { if let displayableTitle = title?.filterForDisplay { content.title = displayableTitle @@ -129,7 +120,7 @@ extension UserNotificationPresenterAdaptee: NotificationPresenterAdaptee { Logger.debug("supressing notification body") } - let request = UNNotificationRequest(identifier: notificationIdentifier, content: content, trigger: trigger) + let request = UNNotificationRequest(identifier: notificationIdentifier, content: content, trigger: nil) Logger.debug("presenting notification with identifier: \(notificationIdentifier)") notificationCenter.add(request) diff --git a/Session/Settings/SettingsVC.swift b/Session/Settings/SettingsVC.swift index 45eb282c3..53febc939 100644 --- a/Session/Settings/SettingsVC.swift +++ b/Session/Settings/SettingsVC.swift @@ -1,3 +1,4 @@ +import UIKit final class SettingsVC : BaseVC, AvatarViewHelperDelegate { private var profilePictureToBeUploaded: UIImage? @@ -90,6 +91,15 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate { return result }() + private lazy var supportButton: UIButton = { + let result = UIButton() + result.setTitle(NSLocalizedString("vc_settings_support_button_title", comment: ""), for: UIControl.State.normal) + result.setTitleColor(Colors.text, for: UIControl.State.normal) + result.titleLabel!.font = .boldSystemFont(ofSize: Values.smallFontSize) + result.addTarget(self, action: #selector(shareLogs), for: UIControl.Event.touchUpInside) + return result + }() + private lazy var helpTranslateButton: UIButton = { let result = UIButton() result.setTitle(NSLocalizedString("vc_settings_help_us_translate_button_title", comment: ""), for: UIControl.State.normal) @@ -187,7 +197,7 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate { logoContainer.pin(.bottom, to: .bottom, of: logoImageView) logoImageView.centerXAnchor.constraint(equalTo: logoContainer.centerXAnchor, constant: -2).isActive = true // Main stack view - let stackView = UIStackView(arrangedSubviews: [ topStackView, settingButtonsStackView, inviteButton, faqButton, surveyButton, helpTranslateButton, logoContainer, versionLabel ]) + let stackView = UIStackView(arrangedSubviews: [ topStackView, settingButtonsStackView, inviteButton, faqButton, surveyButton, supportButton, helpTranslateButton, logoContainer, versionLabel ]) stackView.axis = .vertical stackView.spacing = Values.largeSpacing stackView.alignment = .fill @@ -487,6 +497,13 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate { UIApplication.shared.open(url) } + @objc private func shareLogs() { + let shareLogsModal = ShareLogsModal() + shareLogsModal.modalPresentationStyle = .overFullScreen + shareLogsModal.modalTransitionStyle = .crossDissolve + present(shareLogsModal, animated: true, completion: nil) + } + @objc private func helpTranslate() { let url = URL(string: "https://crowdin.com/project/session-ios")! UIApplication.shared.open(url) diff --git a/Session/Settings/ShareLogsModal.swift b/Session/Settings/ShareLogsModal.swift new file mode 100644 index 000000000..9e8408528 --- /dev/null +++ b/Session/Settings/ShareLogsModal.swift @@ -0,0 +1,68 @@ +import SignalUtilitiesKit + +final class ShareLogsModal : Modal { + + // MARK: Lifecycle + init() { + super.init(nibName: nil, bundle: nil) + } + + override init(nibName: String?, bundle: Bundle?) { + preconditionFailure("Use init(url:) instead.") + } + + required init?(coder: NSCoder) { + preconditionFailure("Use init(url:) instead.") + } + + override func populateContentView() { + // Title + let titleLabel = UILabel() + titleLabel.textColor = Colors.text + titleLabel.font = .boldSystemFont(ofSize: Values.largeFontSize) + titleLabel.text = NSLocalizedString("modal_share_logs_title", comment: "") + titleLabel.textAlignment = .center + // Message + let messageLabel = UILabel() + messageLabel.textColor = Colors.text.withAlphaComponent(Values.mediumOpacity) + messageLabel.font = .systemFont(ofSize: Values.smallFontSize) + messageLabel.text = NSLocalizedString("modal_share_logs_explanation", comment: "") + messageLabel.numberOfLines = 0 + messageLabel.lineBreakMode = .byWordWrapping + messageLabel.textAlignment = .center + // Open button + let shareButton = UIButton() + shareButton.set(.height, to: Values.mediumButtonHeight) + shareButton.layer.cornerRadius = Modal.buttonCornerRadius + shareButton.backgroundColor = Colors.buttonBackground + shareButton.titleLabel!.font = .systemFont(ofSize: Values.smallFontSize) + shareButton.setTitleColor(Colors.text, for: UIControl.State.normal) + shareButton.setTitle(NSLocalizedString("share", comment: ""), for: UIControl.State.normal) + shareButton.addTarget(self, action: #selector(shareLogs), for: UIControl.Event.touchUpInside) + // Button stack view + let buttonStackView = UIStackView(arrangedSubviews: [ cancelButton, shareButton ]) + buttonStackView.axis = .horizontal + buttonStackView.spacing = Values.mediumSpacing + buttonStackView.distribution = .fillEqually + // Main stack view + let mainStackView = UIStackView(arrangedSubviews: [ titleLabel, messageLabel, buttonStackView ]) + mainStackView.axis = .vertical + mainStackView.spacing = Values.largeSpacing + contentView.addSubview(mainStackView) + mainStackView.pin(.leading, to: .leading, of: contentView, withInset: Values.largeSpacing) + mainStackView.pin(.top, to: .top, of: contentView, withInset: Values.largeSpacing) + contentView.pin(.trailing, to: .trailing, of: mainStackView, withInset: Values.largeSpacing) + contentView.pin(.bottom, to: .bottom, of: mainStackView, withInset: Values.largeSpacing) + } + + // MARK: Interaction + @objc private func shareLogs() { + let logFilePaths = AppEnvironment.shared.fileLogger.logFileManager.sortedLogFilePaths + if let latestLogFilePath = logFilePaths.last { + let latestLogFileURL = URL(fileURLWithPath: latestLogFilePath) + self.dismiss(animated: true, completion: { + AttachmentSharing.showShareUI(for: latestLogFileURL) + }) + } + } +} diff --git a/SessionMessagingKit/Database/Storage+Contacts.swift b/SessionMessagingKit/Database/Storage+Contacts.swift index 5581de050..3591d4d5e 100644 --- a/SessionMessagingKit/Database/Storage+Contacts.swift +++ b/SessionMessagingKit/Database/Storage+Contacts.swift @@ -25,8 +25,8 @@ extension Storage { @objc(setContact:usingTransaction:) public func setContact(_ contact: Contact, using transaction: Any) { - let oldContact = getContact(with: contact.sessionID) let transaction = transaction as! YapDatabaseReadWriteTransaction + let oldContact = getContact(with: contact.sessionID, using: transaction) if contact.sessionID == getUserHexEncodedPublicKey() { contact.isTrusted = true // Always trust ourselves } diff --git a/SessionMessagingKit/Database/Storage+Messaging.swift b/SessionMessagingKit/Database/Storage+Messaging.swift index 0a6a84f99..e02363de7 100644 --- a/SessionMessagingKit/Database/Storage+Messaging.swift +++ b/SessionMessagingKit/Database/Storage+Messaging.swift @@ -32,8 +32,9 @@ extension Storage { var recipients: [String] = [] if let syncTarget = message.syncTarget { recipients.append(syncTarget) - } else if let thread = thread as? TSGroupThread, thread.isClosedGroup { - recipients = thread.groupModel.groupMemberIds + } else if let thread = thread as? TSGroupThread { + if thread.isClosedGroup { recipients = thread.groupModel.groupMemberIds } + else { recipients.append(LKGroupUtilities.getDecodedGroupID(thread.groupModel.groupId)) } } recipients.forEach { recipient in tsOutgoingMessage.update(withSentRecipient: recipient, wasSentByUD: true, transaction: transaction) diff --git a/SessionMessagingKit/Database/Storage+Shared.swift b/SessionMessagingKit/Database/Storage+Shared.swift index 17de9059d..b2752d29d 100644 --- a/SessionMessagingKit/Database/Storage+Shared.swift +++ b/SessionMessagingKit/Database/Storage+Shared.swift @@ -39,7 +39,7 @@ extension Storage { guard let userPublicKey = getUserPublicKey() else { return nil } var result: Contact? Storage.read { transaction in - result = Storage.shared.getContact(with: userPublicKey) + result = Storage.shared.getContact(with: userPublicKey, using: transaction) } return result } diff --git a/SessionMessagingKit/Database/TSDatabaseView.m b/SessionMessagingKit/Database/TSDatabaseView.m index 9d1073fc3..42be55700 100644 --- a/SessionMessagingKit/Database/TSDatabaseView.m +++ b/SessionMessagingKit/Database/TSDatabaseView.m @@ -278,15 +278,8 @@ NSString *const TSLazyRestoreAttachmentsGroup = @"TSLazyRestoreAttachmentsGroup" TSThread *thread1 = (TSThread *)object1; TSThread *thread2 = (TSThread *)object2; if ([group isEqualToString:TSArchiveGroup] || [group isEqualToString:TSInboxGroup]) { - - TSInteraction *_Nullable lastInteractionForInbox1 = - [thread1 lastInteractionForInboxWithTransaction:transaction]; - NSDate *date1 = lastInteractionForInbox1 ? lastInteractionForInbox1.receivedAtDate : thread1.creationDate; - - TSInteraction *_Nullable lastInteractionForInbox2 = - [thread2 lastInteractionForInboxWithTransaction:transaction]; - NSDate *date2 = lastInteractionForInbox2 ? lastInteractionForInbox2.receivedAtDate : thread2.creationDate; - + NSDate *date1 = thread1.lastInteractionDate ?: thread1.creationDate; + NSDate *date2 = thread2.lastInteractionDate ?: thread2.creationDate; return [date1 compare:date2]; } diff --git a/SessionMessagingKit/Jobs/JobQueue.swift b/SessionMessagingKit/Jobs/JobQueue.swift index e661189e5..159641522 100644 --- a/SessionMessagingKit/Jobs/JobQueue.swift +++ b/SessionMessagingKit/Jobs/JobQueue.swift @@ -7,6 +7,8 @@ public final class JobQueue : NSObject, JobDelegate { internal static var currentlyExecutingJobs: Set = [] + private let internalQueue: DispatchQueue = DispatchQueue(label:"executingJobQueue") + @objc public static let shared = JobQueue() @objc public func add(_ job: Job, using transaction: Any) { @@ -47,7 +49,7 @@ public final class JobQueue : NSObject, JobDelegate { } public func handleJobSucceeded(_ job: Job) { - given(job.id) { JobQueue.currentlyExecutingJobs.remove($0) } + given(job.id) { removeExecutingJob($0) } SNMessagingKitConfiguration.shared.storage.write(with: { transaction in SNMessagingKitConfiguration.shared.storage.markJobAsSucceeded(job, using: transaction) }, completion: { @@ -56,7 +58,7 @@ public final class JobQueue : NSObject, JobDelegate { } public func handleJobFailed(_ job: Job, with error: Error) { - given(job.id) { JobQueue.currentlyExecutingJobs.remove($0) } + given(job.id) { removeExecutingJob($0) } job.failureCount += 1 let storage = SNMessagingKitConfiguration.shared.storage guard !storage.isJobCanceled(job) else { return SNLog("\(type(of: job)) canceled.") } @@ -78,7 +80,7 @@ public final class JobQueue : NSObject, JobDelegate { } public func handleJobFailedPermanently(_ job: Job, with error: Error) { - given(job.id) { JobQueue.currentlyExecutingJobs.remove($0) } + given(job.id) { removeExecutingJob($0) } job.failureCount += 1 let storage = SNMessagingKitConfiguration.shared.storage storage.write(with: { transaction in @@ -91,6 +93,10 @@ public final class JobQueue : NSObject, JobDelegate { }) }) } + + private func removeExecutingJob(_ jobID: String) { + let _ = internalQueue.sync { JobQueue.currentlyExecutingJobs.remove(jobID) } + } private func getRetryInterval(for job: Job) -> TimeInterval { // Arbitrary backoff factor... diff --git a/SessionMessagingKit/Messages/Control Messages/ConfigurationMessage.swift b/SessionMessagingKit/Messages/Control Messages/ConfigurationMessage.swift index e27b50f92..20dcc7ee6 100644 --- a/SessionMessagingKit/Messages/Control Messages/ConfigurationMessage.swift +++ b/SessionMessagingKit/Messages/Control Messages/ConfigurationMessage.swift @@ -243,6 +243,6 @@ extension ConfigurationMessage { } } - public override var description: String { displayName! } + public override var description: String { displayName ?? "" } } } diff --git a/SessionMessagingKit/Sending & Receiving/Expiration/OWSDisappearingMessagesJob.h b/SessionMessagingKit/Sending & Receiving/Expiration/OWSDisappearingMessagesJob.h index 26ad356f6..fa43294a4 100644 --- a/SessionMessagingKit/Sending & Receiving/Expiration/OWSDisappearingMessagesJob.h +++ b/SessionMessagingKit/Sending & Receiving/Expiration/OWSDisappearingMessagesJob.h @@ -49,6 +49,7 @@ NS_ASSUME_NONNULL_BEGIN // and continue cleaning in the background. - (void)startIfNecessary; +- (void)cleanupMessagesWhichFailedToStartExpiringFromNow; - (void)cleanupMessagesWhichFailedToStartExpiringWithTransaction:(YapDatabaseReadWriteTransaction *)transaction; @end diff --git a/SessionMessagingKit/Sending & Receiving/Expiration/OWSDisappearingMessagesJob.m b/SessionMessagingKit/Sending & Receiving/Expiration/OWSDisappearingMessagesJob.m index 8e6dfbcfb..31e797171 100644 --- a/SessionMessagingKit/Sending & Receiving/Expiration/OWSDisappearingMessagesJob.m +++ b/SessionMessagingKit/Sending & Receiving/Expiration/OWSDisappearingMessagesJob.m @@ -329,6 +329,17 @@ void AssertIsOnDisappearingMessagesQueue() #pragma mark - Cleanup +- (void)cleanupMessagesWhichFailedToStartExpiringFromNow +{ + [LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { + [self.disappearingMessagesFinder + enumerateMessagesWhichFailedToStartExpiringWithBlock:^(TSMessage *_Nonnull message) { + [self startAnyExpirationForMessage:message expirationStartedAt:[NSDate millisecondTimestamp] transaction:transaction]; + } + transaction:transaction]; + }]; +} + - (void)cleanupMessagesWhichFailedToStartExpiringWithTransaction:(YapDatabaseReadWriteTransaction *)transaction { [self.disappearingMessagesFinder diff --git a/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift b/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift index ba761cc26..74103fc2f 100644 --- a/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift +++ b/SessionMessagingKit/Sending & Receiving/MessageReceiver+Handling.swift @@ -189,10 +189,10 @@ extension MessageReceiver { let storage = SNMessagingKitConfiguration.shared.storage let transaction = transaction as! YapDatabaseReadWriteTransaction // Profile - var userProfileKy: OWSAES256Key? = nil - if let profileKey = message.profileKey { userProfileKy = OWSAES256Key(data: profileKey) } + var userProfileKey: OWSAES256Key? = nil + if let profileKey = message.profileKey { userProfileKey = OWSAES256Key(data: profileKey) } updateProfileIfNeeded(publicKey: userPublicKey, name: message.displayName, profilePictureURL: message.profilePictureURL, - profileKey: userProfileKy, sentTimestamp: message.sentTimestamp!, transaction: transaction) + profileKey: userProfileKey, sentTimestamp: message.sentTimestamp!, transaction: transaction) // Initial configuration sync if !UserDefaults.standard[.hasSyncedInitialConfiguration] { UserDefaults.standard[.hasSyncedInitialConfiguration] = true @@ -280,8 +280,10 @@ extension MessageReceiver { // Update profile if needed if let profile = message.profile { let sessionID = message.sender! + var contactProfileKey: OWSAES256Key? = nil + if let profileKey = profile.profileKey { contactProfileKey = OWSAES256Key(data: profileKey) } updateProfileIfNeeded(publicKey: sessionID, name: profile.displayName, profilePictureURL: profile.profilePictureURL, - profileKey: given(profile.profileKey) { OWSAES256Key(data: $0)! }, sentTimestamp: message.sentTimestamp!, transaction: transaction) + profileKey: contactProfileKey, sentTimestamp: message.sentTimestamp!, transaction: transaction) } // Get or create thread guard let threadID = storage.getOrCreateThread(for: message.syncTarget ?? message.sender!, groupPublicKey: message.groupPublicKey, openGroupID: openGroupID, using: transaction) else { throw Error.noThread } @@ -330,8 +332,6 @@ extension MessageReceiver { let thread = TSThread.fetch(uniqueId: threadID, transaction: transaction) { // Mark previous messages as read if there is a sync message OWSReadReceiptManager.shared().markAsReadLocally(beforeSortId: tsOutgoingMessage.sortId, thread: thread) - // Start expiration for sync messages - OWSDisappearingMessagesJob.shared().startAnyExpiration(for: tsOutgoingMessage, expirationStartedAt: NSDate.millisecondTimestamp(), transaction: transaction) } // Notify the user if needed guard (isMainAppAndActive || isBackgroundPoll), let tsIncomingMessage = TSMessage.fetch(uniqueId: tsMessageID, transaction: transaction) as? TSIncomingMessage, diff --git a/SessionMessagingKit/Threads/TSThread.h b/SessionMessagingKit/Threads/TSThread.h index 7ed517919..aa333d245 100644 --- a/SessionMessagingKit/Threads/TSThread.h +++ b/SessionMessagingKit/Threads/TSThread.h @@ -18,6 +18,7 @@ BOOL IsNoteToSelfEnabled(void); @property (nonatomic) BOOL shouldBeVisible; @property (nonatomic, readonly) NSDate *creationDate; +@property (nonatomic, readonly, nullable) NSDate *lastInteractionDate; @property (nonatomic, readonly) TSInteraction *lastInteraction; @property (atomic, readonly) BOOL isMuted; @property (atomic, readonly, nullable) NSDate *mutedUntilDate; diff --git a/SessionMessagingKit/Threads/TSThread.m b/SessionMessagingKit/Threads/TSThread.m index dbfa1ecd4..8d4b81770 100644 --- a/SessionMessagingKit/Threads/TSThread.m +++ b/SessionMessagingKit/Threads/TSThread.m @@ -21,6 +21,7 @@ BOOL IsNoteToSelfEnabled(void) @interface TSThread () @property (nonatomic) NSDate *creationDate; +@property (nonatomic, nullable) NSDate *lastInteractionDate; @property (nonatomic, nullable) NSNumber *archivedAsOfMessageSortId; @property (nonatomic, copy, nullable) NSString *messageDraft; @property (atomic, nullable) NSDate *mutedUntilDate; @@ -355,6 +356,8 @@ BOOL IsNoteToSelfEnabled(void) if (![self.class shouldInteractionAppearInInbox:lastMessage]) { return; } + + _lastInteractionDate = lastMessage.receivedAtDate; if (!self.shouldBeVisible) { self.shouldBeVisible = YES; diff --git a/SessionMessagingKit/Utilities/OWSPreferences.h b/SessionMessagingKit/Utilities/OWSPreferences.h index f69dbb286..8fdafd1b1 100644 --- a/SessionMessagingKit/Utilities/OWSPreferences.h +++ b/SessionMessagingKit/Utilities/OWSPreferences.h @@ -3,6 +3,10 @@ // #import +#import +#import +#import +#import NS_ASSUME_NONNULL_BEGIN @@ -47,6 +51,7 @@ extern NSString *const OWSPreferencesCallLoggingDidChangeNotification; - (void)setScreenSecurity:(BOOL)flag; - (NotificationType)notificationPreviewType; +- (NotificationType)notificationPreviewTypeWithTransaction:(YapDatabaseReadTransaction *)transaction; - (void)setNotificationPreviewType:(NotificationType)type; - (NSString *)nameForNotificationPreviewType:(NotificationType)notificationType; diff --git a/SessionMessagingKit/Utilities/OWSPreferences.m b/SessionMessagingKit/Utilities/OWSPreferences.m index 645b73a02..29def0003 100644 --- a/SessionMessagingKit/Utilities/OWSPreferences.m +++ b/SessionMessagingKit/Utilities/OWSPreferences.m @@ -3,10 +3,6 @@ // #import "OWSPreferences.h" -#import -#import -#import -#import NS_ASSUME_NONNULL_BEGIN @@ -384,6 +380,17 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste } } +- (NotificationType)notificationPreviewTypeWithTransaction:(YapDatabaseReadTransaction *)transaction +{ + NSNumber *preference = [self tryGetValueForKey:OWSPreferencesKeyNotificationPreviewType transaction:transaction]; + + if (preference) { + return [preference unsignedIntegerValue]; + } else { + return NotificationNamePreview; + } +} + - (NSString *)nameForNotificationPreviewType:(NotificationType)notificationType { switch (notificationType) { diff --git a/SessionShareExtension/ThreadPickerVC.swift b/SessionShareExtension/ThreadPickerVC.swift index 939a67594..75355d23a 100644 --- a/SessionShareExtension/ThreadPickerVC.swift +++ b/SessionShareExtension/ThreadPickerVC.swift @@ -36,6 +36,7 @@ final class ThreadPickerVC : UIViewController, UITableViewDataSource, UITableVie // MARK: Lifecycle override func viewDidLoad() { super.viewDidLoad() + setupNavBar() // Gradient view.backgroundColor = .clear let gradient = Gradients.defaultBackground @@ -68,6 +69,17 @@ final class ThreadPickerVC : UIViewController, UITableViewDataSource, UITableVie reload() } + private func setupNavBar() { + guard let navigationBar = navigationController?.navigationBar else { return } + if #available(iOS 15.0, *) { + let appearance = UINavigationBarAppearance() + appearance.configureWithOpaqueBackground() + appearance.backgroundColor = Colors.navigationBarBackground + navigationBar.standardAppearance = appearance; + navigationBar.scrollEdgeAppearance = navigationBar.standardAppearance + } + } + // MARK: Table View Data Source func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return Int(threadCount) @@ -109,16 +121,14 @@ final class ThreadPickerVC : UIViewController, UITableViewDataSource, UITableVie } shareVC!.dismiss(animated: true, completion: nil) ModalActivityIndicatorViewController.present(fromViewController: shareVC!, canCancel: false, message: NSLocalizedString("vc_share_sending_message", comment: "")) { activityIndicator in - Storage.write { transaction in - MessageSender.sendNonDurably(message, with: attachments, in: self.selectedThread!, using: transaction).done { [weak self] _ in - guard let self = self else { return } - activityIndicator.dismiss { } - self.shareVC!.shareViewWasCompleted() - }.catch { [weak self] error in - guard let self = self else { return } - activityIndicator.dismiss { } - self.shareVC!.shareViewFailed(error: error) - } + MessageSender.sendNonDurably(message, with: attachments, in: self.selectedThread!).done { [weak self] _ in + guard let self = self else { return } + activityIndicator.dismiss { } + self.shareVC!.shareViewWasCompleted() + }.catch { [weak self] error in + guard let self = self else { return } + activityIndicator.dismiss { } + self.shareVC!.shareViewFailed(error: error) } } } diff --git a/SignalUtilitiesKit/Media Viewing & Editing/MediaMessageView.swift b/SignalUtilitiesKit/Media Viewing & Editing/MediaMessageView.swift index 7c13aae4e..443f5fc80 100644 --- a/SignalUtilitiesKit/Media Viewing & Editing/MediaMessageView.swift +++ b/SignalUtilitiesKit/Media Viewing & Editing/MediaMessageView.swift @@ -269,7 +269,7 @@ public class MediaMessageView: UIView, OWSAudioPlayerDelegate { private func createGenericPreview() { var subviews = [UIView]() - let imageView = createHeroImageView(imageName: "file-thin-black-filled-large") + let imageView = createHeroImageView(imageName: "actionsheet_document_black") subviews.append(imageView) let fileNameLabel = createFileNameLabel() diff --git a/SignalUtilitiesKit/Messaging/Sending & Receiving/MessageSender+Convenience.swift b/SignalUtilitiesKit/Messaging/Sending & Receiving/MessageSender+Convenience.swift index 177cdb65d..3297ce14e 100644 --- a/SignalUtilitiesKit/Messaging/Sending & Receiving/MessageSender+Convenience.swift +++ b/SignalUtilitiesKit/Messaging/Sending & Receiving/MessageSender+Convenience.swift @@ -67,4 +67,38 @@ extension MessageSender { let destination = Message.Destination.from(thread) return MessageSender.send(message, to: destination, using: transaction) } + + public static func sendNonDurably(_ message: VisibleMessage, with attachments: [SignalAttachment], in thread: TSThread) -> Promise { + Storage.writeSync{ transaction in + prep(attachments, for: message, using: transaction) + } + let attachments = message.attachmentIDs.compactMap { TSAttachment.fetch(uniqueId: $0) as? TSAttachmentStream } + let attachmentsToUpload = attachments.filter { !$0.isUploaded } + let attachmentUploadPromises: [Promise] = attachmentsToUpload.map { stream in + let storage = SNMessagingKitConfiguration.shared.storage + if let v2OpenGroup = storage.getV2OpenGroup(for: thread.uniqueId!) { + let (promise, seal) = Promise.pending() + AttachmentUploadJob.upload(stream, using: { data in return OpenGroupAPIV2.upload(data, to: v2OpenGroup.room, on: v2OpenGroup.server) }, encrypt: false, onSuccess: { seal.fulfill(()) }, onFailure: { seal.reject($0) }) + return promise + } else { + let (promise, seal) = Promise.pending() + AttachmentUploadJob.upload(stream, using: FileServerAPIV2.upload, encrypt: true, onSuccess: { seal.fulfill(()) }, onFailure: { seal.reject($0) }) + return promise + } + } + let (promise, seal) = Promise.pending() + let results = when(resolved: attachmentUploadPromises).wait() + let errors = results.compactMap { result -> Swift.Error? in + if case .rejected(let error) = result { return error } else { return nil } + } + if let error = errors.first { seal.reject(error) } + Storage.write{ transaction in + sendNonDurably(message, in: thread, using: transaction).done { + seal.fulfill(()) + }.catch { error in + seal.reject(error) + } + } + return promise + } }