mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
Removing dead code part 3 (#2264)
This commit is contained in:
@@ -31,18 +31,6 @@ extension String {
|
||||
|
||||
return string
|
||||
}
|
||||
|
||||
/// Calculates a numeric hash same as Element Web
|
||||
/// See original function here https://github.com/matrix-org/matrix-react-sdk/blob/321dd49db4fbe360fc2ff109ac117305c955b061/src/utils/FormattingUtils.js#L47
|
||||
var hashCode: Int32 {
|
||||
var hash: Int32 = 0
|
||||
|
||||
for character in self {
|
||||
let shiftedHash = hash << 5
|
||||
hash = shiftedHash.subtractingReportingOverflow(hash).partialValue + Int32(character.unicodeScalars[character.unicodeScalars.startIndex].value)
|
||||
}
|
||||
return abs(hash)
|
||||
}
|
||||
|
||||
var isASCII: Bool {
|
||||
allSatisfy(\.isASCII)
|
||||
|
||||
@@ -44,10 +44,6 @@ extension UNNotificationContent {
|
||||
@objc var roomID: String? {
|
||||
userInfo[NotificationConstants.UserInfoKey.roomIdentifier] as? String
|
||||
}
|
||||
|
||||
@objc var eventID: String? {
|
||||
userInfo[NotificationConstants.UserInfoKey.eventIdentifier] as? String
|
||||
}
|
||||
}
|
||||
|
||||
extension UNMutableNotificationContent {
|
||||
@@ -69,15 +65,6 @@ extension UNMutableNotificationContent {
|
||||
}
|
||||
}
|
||||
|
||||
override var eventID: String? {
|
||||
get {
|
||||
userInfo[NotificationConstants.UserInfoKey.eventIdentifier] as? String
|
||||
}
|
||||
set {
|
||||
userInfo[NotificationConstants.UserInfoKey.eventIdentifier] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
func addMediaAttachment(using mediaProvider: MediaProviderProtocol?,
|
||||
mediaSource: MediaSourceProxy) async -> UNMutableNotificationContent {
|
||||
guard let mediaProvider else {
|
||||
|
||||
@@ -47,17 +47,6 @@ extension URL: ExpressibleByStringLiteral {
|
||||
|
||||
return applicationSupportSessionsURL
|
||||
}
|
||||
|
||||
/// The base directory where all cache is stored.
|
||||
static var cacheBaseDirectory: URL {
|
||||
let url = appGroupContainerDirectory
|
||||
.appendingPathComponent("Library", isDirectory: true)
|
||||
.appendingPathComponent("Caches", isDirectory: true)
|
||||
|
||||
try? FileManager.default.createDirectoryIfNeeded(at: url)
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
/// The base directory where all application support data is stored.
|
||||
static var applicationSupportBaseDirectory: URL {
|
||||
|
||||
@@ -18,11 +18,6 @@ import Combine
|
||||
import UIKit
|
||||
|
||||
class ScrollViewAdapter: NSObject, UIScrollViewDelegate {
|
||||
enum ScrollDirection {
|
||||
case up
|
||||
case down
|
||||
}
|
||||
|
||||
var scrollView: UIScrollView? {
|
||||
didSet {
|
||||
oldValue?.delegate = nil
|
||||
@@ -42,13 +37,6 @@ class ScrollViewAdapter: NSObject, UIScrollViewDelegate {
|
||||
.init(isScrollingSubject)
|
||||
}
|
||||
|
||||
private let scrollDirectionSubject: PassthroughSubject<ScrollDirection, Never> = .init()
|
||||
var scrollDirection: AnyPublisher<ScrollDirection, Never> {
|
||||
scrollDirectionSubject
|
||||
.removeDuplicates()
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
private let isAtTopEdgeSubject: CurrentValueSubject<Bool, Never> = .init(false)
|
||||
var isAtTopEdge: CurrentValuePublisher<Bool, Never> {
|
||||
isAtTopEdgeSubject
|
||||
@@ -59,7 +47,6 @@ class ScrollViewAdapter: NSObject, UIScrollViewDelegate {
|
||||
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
didScrollSubject.send(())
|
||||
updateScrollDirection(scrollView)
|
||||
let insetContentOffset = scrollView.contentOffset.y + scrollView.contentInset.top
|
||||
isAtTopEdgeSubject.send(insetContentOffset >= 3)
|
||||
}
|
||||
@@ -97,18 +84,4 @@ class ScrollViewAdapter: NSObject, UIScrollViewDelegate {
|
||||
private func updateDidScroll(_ scrollView: UIScrollView) {
|
||||
isScrollingSubject.send(scrollView.isDragging || scrollView.isDecelerating)
|
||||
}
|
||||
|
||||
private func updateScrollDirection(_ scrollView: UIScrollView) {
|
||||
let velocity = scrollView.panGestureRecognizer.velocity(in: nil)
|
||||
|
||||
if velocity.y > Constant.scrollDirectionThreshold {
|
||||
scrollDirectionSubject.send(.up)
|
||||
} else if velocity.y < -Constant.scrollDirectionThreshold {
|
||||
scrollDirectionSubject.send(.down)
|
||||
}
|
||||
}
|
||||
|
||||
private enum Constant {
|
||||
static let scrollDirectionThreshold: CGFloat = 200
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,10 +43,6 @@ final class ShareToMapsAppActivity: UIActivity {
|
||||
type.activityTitle
|
||||
}
|
||||
|
||||
var activityCategory: UIActivity.Category {
|
||||
.action
|
||||
}
|
||||
|
||||
override var activityType: UIActivity.ActivityType {
|
||||
.shareToMapsApp
|
||||
}
|
||||
|
||||
@@ -75,19 +75,6 @@ extension UserPreference {
|
||||
convenience init<R: RawRepresentable>(key: R, defaultValue: T, storageType: StorageType) where R.RawValue == String {
|
||||
self.init(key: key.rawValue, defaultValue: defaultValue, storageType: storageType)
|
||||
}
|
||||
|
||||
/// Convenience initializer that also immediatelly stores the provided initialValue.
|
||||
/// The initial value is stored every time the app is launched.
|
||||
/// And will override any existing values.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - key: the raw representable key used to store the value, needs conform also to String
|
||||
/// - initialValue: the initial value that will be stored when the app is launched, the initialValue is also used as defaultValue
|
||||
/// - storageType: the storage type where the wrappedValue will be stored.
|
||||
convenience init<R: RawRepresentable>(key: R, initialValue: T, storageType: StorageType) where R.RawValue == String {
|
||||
self.init(key: key, defaultValue: initialValue, storageType: storageType)
|
||||
wrappedValue = initialValue
|
||||
}
|
||||
|
||||
convenience init(key: String, storageType: StorageType) where T: ExpressibleByNilLiteral {
|
||||
self.init(key: key, defaultValue: nil, storageType: storageType)
|
||||
|
||||
Reference in New Issue
Block a user