Switch Everything and Mentions Tabs order (IOS-240) (#1258)
* Switch Everything and Mentions Tabs order (IOS-240) * Swap switch category (IOS-240)
This commit is contained in:
parent
bfc20655c4
commit
0e207cf65d
@ -224,9 +224,9 @@ extension NotificationViewController {
|
||||
|
||||
switch category {
|
||||
case .mentions:
|
||||
scrollToPage(.first, animated: true, completion: nil)
|
||||
case .everything:
|
||||
scrollToPage(.last, animated: true, completion: nil)
|
||||
case .everything:
|
||||
scrollToPage(.first, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,14 +31,18 @@ final class NotificationViewModel {
|
||||
|
||||
private var lastPageIndex: Int {
|
||||
get {
|
||||
UserDefaults.shared.getLastSelectedNotificationsTab(
|
||||
guard let selectedTabName = UserDefaults.shared.getLastSelectedNotificationsTabName(
|
||||
accessToken: authContext.mastodonAuthenticationBox.userAuthorization.accessToken
|
||||
)
|
||||
), let scope = APIService.MastodonNotificationScope(rawValue: selectedTabName) else {
|
||||
return 0
|
||||
}
|
||||
|
||||
return APIService.MastodonNotificationScope.allCases.firstIndex(of: scope) ?? 0
|
||||
}
|
||||
set {
|
||||
UserDefaults.shared.setLastSelectedNotificationsTab(
|
||||
UserDefaults.shared.setLastSelectedNotificationsTabName(
|
||||
accessToken: authContext.mastodonAuthenticationBox.userAuthorization.accessToken,
|
||||
value: newValue
|
||||
value: APIService.MastodonNotificationScope.allCases[newValue].rawValue
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -38,14 +38,14 @@ extension UserDefaults {
|
||||
let count = getNotificationCountWithAccessToken(accessToken: accessToken)
|
||||
setNotificationCountWithAccessToken(accessToken: accessToken, value: count + 1)
|
||||
}
|
||||
|
||||
@objc public func getLastSelectedNotificationsTab(accessToken: String) -> Int {
|
||||
|
||||
@objc public func getLastSelectedNotificationsTabName(accessToken: String) -> String? {
|
||||
let prefix = UserDefaults.notificationsLastTabIndexKeyPrefix
|
||||
let key = UserDefaults.deriveKey(from: accessToken, prefix: prefix)
|
||||
return integer(forKey: key)
|
||||
return object(forKey: key) as? String
|
||||
}
|
||||
|
||||
@objc public func setLastSelectedNotificationsTab(accessToken: String, value: Int) {
|
||||
@objc public func setLastSelectedNotificationsTabName(accessToken: String, value: String?) {
|
||||
let prefix = UserDefaults.notificationsLastTabIndexKeyPrefix
|
||||
let key = UserDefaults.deriveKey(from: accessToken, prefix: prefix)
|
||||
setValue(value, forKey: key)
|
||||
|
@ -14,9 +14,9 @@ import OSLog
|
||||
|
||||
extension APIService {
|
||||
|
||||
public enum MastodonNotificationScope: Hashable, CaseIterable {
|
||||
case mentions
|
||||
public enum MastodonNotificationScope: String, Hashable, CaseIterable {
|
||||
case everything
|
||||
case mentions
|
||||
|
||||
public var includeTypes: [MastodonNotificationType]? {
|
||||
switch self {
|
||||
|
Loading…
x
Reference in New Issue
Block a user