Multi file uploads (#4358)

* Allow MediaPickerScreen users to select the media selection mode (single or multiple)

* Fix cancellation

* Add support for multiple media URLs on the MediaUploadPreviewScreen.

* Support processing more URLs on the `MediaUploadingPreprocessor` and sending more on the `MediaUploadPreviewScreen`

* Add feature flag for `multipleAttachmentUploadEnabled`

* Add a label showing the current preview item index in the MediaUploadPreviewScreen

* Add support for dragging and dropping or pasting multiple items at the same time.

* Support sharing more than one file through the share extension.

* Limit the number of items that can be shared in one go to 5.

* Fix unit tests

* Fix incorrect fatal error when dealing with single selection media pickers.

* Document the `multipleAttachmentUploadEnabled` usage in the context of the MediaPicker.

* Use a task group for processing selected media in the photo library picker.

* Use a task group for processing multiple selected media in the MediaUploadingPreprocessor

* Switch the maximum number of items that can be shared to 10.

* Allow multiple items to be pasted at the same time.
This commit is contained in:
Stefan Ceriu
2025-07-30 15:44:05 +03:00
committed by GitHub
parent 01033cf53e
commit df335bd2b1
39 changed files with 466 additions and 266 deletions
@@ -16,11 +16,13 @@ import SwiftUI
protocol CommonSettingsProtocol {
var logLevel: LogLevel { get }
var traceLogPacks: Set<TraceLogPack> { get }
var bugReportRageshakeURL: RemotePreference<RageshakeConfiguration> { get }
var enableOnlySignedDeviceIsolationMode: Bool { get }
var enableKeyShareOnInvite: Bool { get }
var hideQuietNotificationAlerts: Bool { get }
var threadsEnabled: Bool { get }
var bugReportRageshakeURL: RemotePreference<RageshakeConfiguration> { get }
var hideQuietNotificationAlerts: Bool { get }
var multipleAttachmentUploadEnabled: Bool { get }
}
/// Store Element specific app settings.
@@ -59,6 +61,7 @@ final class AppSettings {
case threadsEnabled
case developerOptionsEnabled
case sharePosEnabledV2
case multipleAttachmentUploadEnabled
// Doug's tweaks 🔧
case hideUnreadMessagesBadge
@@ -70,6 +73,16 @@ final class AppSettings {
/// UserDefaults to be used on reads and writes.
private static var store: UserDefaults! = UserDefaults(suiteName: suiteName)
/// Whether or not the app is a development build that isn't in production.
static var isDevelopmentBuild: Bool = {
#if DEBUG
true
#else
let apps = ["io.element.elementx.nightly", "io.element.elementx.pr"]
return apps.contains(InfoPlistReader.main.baseBundleIdentifier)
#endif
}()
#if IS_MAIN_APP
static func resetAllSettings() {
@@ -135,16 +148,6 @@ final class AppSettings {
// MARK: - Application
/// Whether or not the app is a development build that isn't in production.
static var isDevelopmentBuild: Bool = {
#if DEBUG
true
#else
let apps = ["io.element.elementx.nightly", "io.element.elementx.pr"]
return apps.contains(InfoPlistReader.main.baseBundleIdentifier)
#endif
}()
/// The last known version of the app that was launched on this device, which is
/// used to detect when migrations should be run. When `nil` the app may have been
/// deleted between runs so should clear data in the shared container and keychain.
@@ -362,6 +365,8 @@ final class AppSettings {
@UserPreference(key: UserDefaultsKeys.traceLogPacks, defaultValue: [], storageType: .userDefaults(store))
var traceLogPacks: Set<TraceLogPack>
let bugReportRageshakeURL: RemotePreference<RageshakeConfiguration> = .init(Secrets.rageshakeURL.map { .url(URL(string: $0)!) } ?? .disabled) // swiftlint:disable:this force_unwrapping
/// Configuration to enable only signed device isolation mode for crypto. In this mode only devices signed by their owner will be considered in e2ee rooms.
@UserPreference(key: UserDefaultsKeys.enableOnlySignedDeviceIsolationMode, defaultValue: false, storageType: .userDefaults(store))
var enableOnlySignedDeviceIsolationMode
@@ -370,13 +375,14 @@ final class AppSettings {
@UserPreference(key: UserDefaultsKeys.enableKeyShareOnInvite, defaultValue: false, storageType: .userDefaults(store))
var enableKeyShareOnInvite
@UserPreference(key: UserDefaultsKeys.hideQuietNotificationAlerts, defaultValue: false, storageType: .userDefaults(store))
var hideQuietNotificationAlerts
@UserPreference(key: UserDefaultsKeys.threadsEnabled, defaultValue: false, storageType: .userDefaults(store))
var threadsEnabled
let bugReportRageshakeURL: RemotePreference<RageshakeConfiguration> = .init(Secrets.rageshakeURL.map { .url(URL(string: $0)!) } ?? .disabled) // swiftlint:disable:this force_unwrapping
@UserPreference(key: UserDefaultsKeys.hideQuietNotificationAlerts, defaultValue: false, storageType: .userDefaults(store))
var hideQuietNotificationAlerts
@UserPreference(key: UserDefaultsKeys.multipleAttachmentUploadEnabled, defaultValue: isDevelopmentBuild, storageType: .userDefaults(store))
var multipleAttachmentUploadEnabled
}
extension AppSettings: CommonSettingsProtocol { }