Merge branch 'dev' into fix-disappearing-messages-control-message

pull/1038/head
Ryan ZHAO 7 months ago
commit bfa059f415

@ -5030,59 +5030,7 @@
developmentRegion = en; developmentRegion = en;
hasScannedForEncodings = 0; hasScannedForEncodings = 0;
knownRegions = ( knownRegions = (
en, Base
de,
es,
fr,
pt_BR,
ru,
zh_CN,
Base,
it,
fa,
pl,
ja,
"vi-VN",
"id-ID",
sk,
nl,
"zh-Hant",
hi,
fi,
hr,
sv,
th,
si,
ar,
uk,
be,
el,
"zh-TW",
ku,
sl,
da,
eo,
bg,
"es-ES",
cs,
ko,
fil,
"ne-NP",
no,
nb,
hu,
tr,
"pt-BR",
vi,
lv,
lt,
"zh-CN",
"si-LK",
id,
"sv-SE",
bn,
"pt-PT",
ro,
); );
mainGroup = D221A07E169C9E5E00537ABF; mainGroup = D221A07E169C9E5E00537ABF;
packageReferences = ( packageReferences = (
@ -5266,7 +5214,7 @@
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */
FD0B1FA92CA3805C00F60F46 /* Ensure InfoPlist.xcstrings updated */ = { 9471CAA62CACFB0600090FB7 /* Generate Licenses Plist */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1; alwaysOutOfDate = 1;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -5276,17 +5224,17 @@
); );
inputPaths = ( inputPaths = (
); );
name = "Ensure InfoPlist.xcstrings updated"; name = "Generate Licenses Plist";
outputFileListPaths = ( outputFileListPaths = (
); );
outputPaths = ( outputPaths = (
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Scripts/LintLocalizableStrings.swift\" update\n"; shellScript = "\"${SRCROOT}/Scripts/GenerateLicenses.swift\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
9471CAA62CACFB0600090FB7 /* Generate Licenses Plist */ = { FD0B1FA92CA3805C00F60F46 /* Ensure InfoPlist.xcstrings updated */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1; alwaysOutOfDate = 1;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -5296,14 +5244,14 @@
); );
inputPaths = ( inputPaths = (
); );
name = "Generate Licenses Plist"; name = "Ensure InfoPlist.xcstrings updated";
outputFileListPaths = ( outputFileListPaths = (
); );
outputPaths = ( outputPaths = (
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Scripts/GenerateLicenses.swift\"\n"; shellScript = "\"${SRCROOT}/Scripts/LintLocalizableStrings.swift\" update\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
FD5E93D32C12D3990038C25A /* Add App Group To Build Info Plist */ = { FD5E93D32C12D3990038C25A /* Add App Group To Build Info Plist */ = {
@ -6655,7 +6603,6 @@
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
STRIP_INSTALLED_PRODUCT = NO; STRIP_INSTALLED_PRODUCT = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
@ -6731,7 +6678,6 @@
SDKROOT = iphoneos; SDKROOT = iphoneos;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_COMPILATION_MODE = wholemodule; SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = ""; SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
@ -6789,7 +6735,6 @@
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
STRIP_INSTALLED_PRODUCT = NO; STRIP_INSTALLED_PRODUCT = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1; TARGETED_DEVICE_FAMILY = 1;
@ -6867,7 +6812,6 @@
SDKROOT = iphoneos; SDKROOT = iphoneos;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_COMPILATION_MODE = wholemodule; SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1; TARGETED_DEVICE_FAMILY = 1;
@ -7732,6 +7676,7 @@
); );
"OTHER_SWIFT_FLAGS[arch=*]" = "-D DEBUG"; "OTHER_SWIFT_FLAGS[arch=*]" = "-D DEBUG";
SDKROOT = iphoneos; SDKROOT = iphoneos;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.0;
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
}; };
@ -7806,6 +7751,7 @@
); );
SDKROOT = iphoneos; SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule; SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.0;
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
@ -7873,7 +7819,6 @@
RUN_CLANG_STATIC_ANALYZER = YES; RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
STRIP_INSTALLED_PRODUCT = NO; STRIP_INSTALLED_PRODUCT = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "Session/Meta/Signal-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Session/Meta/Signal-Bridging-Header.h";
SWIFT_OBJC_INTERFACE_HEADER_NAME = "Session-Swift.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = "Session-Swift.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@ -7940,7 +7885,6 @@
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "";
RUN_CLANG_STATIC_ANALYZER = YES; RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_BRIDGING_HEADER = "Session/Meta/Signal-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Session/Meta/Signal-Bridging-Header.h";
SWIFT_OBJC_INTERFACE_HEADER_NAME = "Session-Swift.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = "Session-Swift.h";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
@ -8297,6 +8241,7 @@
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
@ -8361,6 +8306,7 @@
SDKROOT = iphoneos; SDKROOT = iphoneos;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_COMPILATION_MODE = wholemodule; SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";

File diff suppressed because it is too large Load Diff

@ -610,10 +610,6 @@ extension Attachment {
} }
public static func originalFilePath(id: String, mimeType: String, sourceFilename: String?) -> String? { public static func originalFilePath(id: String, mimeType: String, sourceFilename: String?) -> String? {
// Store the file in a subdirectory whose name is the uniqueId of this attachment,
// to avoid collisions between multiple attachments with the same name
let attachmentFolder: String = Attachment.attachmentsFolder.appending("/\(id)")
if let sourceFilename: String = sourceFilename, !sourceFilename.isEmpty { if let sourceFilename: String = sourceFilename, !sourceFilename.isEmpty {
// Ensure that the filename is a valid filesystem name, // Ensure that the filename is a valid filesystem name,
// replacing invalid characters with an underscore. // replacing invalid characters with an underscore.
@ -647,6 +643,10 @@ extension Attachment {
targetFileExtension = targetFileExtension.lowercased() targetFileExtension = targetFileExtension.lowercased()
if !targetFileExtension.isEmpty { if !targetFileExtension.isEmpty {
// Store the file in a subdirectory whose name is the uniqueId of this attachment,
// to avoid collisions between multiple attachments with the same name
let attachmentFolder: String = Attachment.attachmentsFolder.appending("/\(id)")
guard case .success = Result(try FileSystem.ensureDirectoryExists(at: attachmentFolder)) else { guard case .success = Result(try FileSystem.ensureDirectoryExists(at: attachmentFolder)) else {
return nil return nil
} }
@ -660,7 +660,7 @@ extension Attachment {
UTType.fileExtensionDefault UTType.fileExtensionDefault
).lowercased() ).lowercased()
return attachmentFolder.appending("/\(id).\(targetFileExtension)") return Attachment.attachmentsFolder.appending("/\(id).\(targetFileExtension)")
} }
public static func localRelativeFilePath(from originalFilePath: String?) -> String? { public static func localRelativeFilePath(from originalFilePath: String?) -> String? {

@ -25,42 +25,30 @@ extension Setting {
// MARK: - Numeric Setting // MARK: - Numeric Setting
fileprivate init?<T: Numeric>(key: String, value: T?) { fileprivate init?<T: Numeric>(key: String, value: T?) {
guard let value: T = value else { return nil } guard var value: T = value else { return nil }
var targetValue: T = value
self.key = key self.key = key
self.value = Data(bytes: &targetValue, count: MemoryLayout.size(ofValue: targetValue)) self.value = withUnsafeBytes(of: &value) { Data($0) }
} }
fileprivate func value<T: Numeric>(as type: T.Type) -> T? { fileprivate func value<T: Numeric>(as type: T.Type) -> T? {
// Note: The 'assumingMemoryBound' is essentially going to try to convert
// the memory into the provided type so can result in invalid data being
// returned if the type is incorrect. But it does seem safer than the 'load'
// method which crashed under certain circumstances (an `Int` value of 0)
return value.withUnsafeBytes { return value.withUnsafeBytes {
$0.baseAddress?.assumingMemoryBound(to: T.self).pointee $0.loadUnaligned(as: T.self)
} }
} }
// MARK: - Bool Setting // MARK: - Bool Setting
fileprivate init?(key: String, value: Bool?) { fileprivate init?(key: String, value: Bool?) {
guard let value: Bool = value else { return nil } guard var value: Bool = value else { return nil }
var targetValue: Bool = value
self.key = key self.key = key
self.value = Data(bytes: &targetValue, count: MemoryLayout.size(ofValue: targetValue)) self.value = withUnsafeBytes(of: &value) { Data($0) }
} }
public func unsafeValue(as type: Bool.Type) -> Bool? { public func unsafeValue(as type: Bool.Type) -> Bool? {
// Note: The 'assumingMemoryBound' is essentially going to try to convert
// the memory into the provided type so can result in invalid data being
// returned if the type is incorrect. But it does seem safer than the 'load'
// method which crashed under certain circumstances (an `Int` value of 0)
return value.withUnsafeBytes { return value.withUnsafeBytes {
$0.baseAddress?.assumingMemoryBound(to: Bool.self).pointee $0.loadUnaligned(as: Bool.self)
} }
} }

@ -123,7 +123,7 @@ public extension UTType {
let mimeType: String = preferredMIMEType, let mimeType: String = preferredMIMEType,
let fileExtension: String = UTType.genericExtensionTypesToMimeTypes let fileExtension: String = UTType.genericExtensionTypesToMimeTypes
.first(where: { _, value in value == mimeType })? .first(where: { _, value in value == mimeType })?
.value .key
else { return preferredFilenameExtension } else { return preferredFilenameExtension }
return fileExtension return fileExtension

Loading…
Cancel
Save