mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-23 00:40:59 +00:00
Remove legacy migrations
This commit is contained in:
parent
d5896b95e9
commit
23a83d69cc
6 changed files with 9 additions and 64 deletions
|
@ -28,9 +28,6 @@ struct TimelineTab: View {
|
|||
@Query(sort: \LocalTimeline.creationDate, order: .reverse) var localTimelines: [LocalTimeline]
|
||||
@Query(sort: \TagGroup.creationDate, order: .reverse) var tagGroups: [TagGroup]
|
||||
|
||||
@AppStorage("remote_local_timeline") var legacyLocalTimelines: [String] = []
|
||||
@AppStorage("tag_groups") var legacyTagGroups: [LegacyTagGroup] = []
|
||||
|
||||
@AppStorage("last_timeline_filter") var lastTimelineFilter: TimelineFilter = .home
|
||||
|
||||
private let canFilterTimeline: Bool
|
||||
|
@ -56,8 +53,6 @@ struct TimelineTab: View {
|
|||
.id(client.id)
|
||||
}
|
||||
.onAppear {
|
||||
migrateUserPreferencesTimeline()
|
||||
migrateUserPreferencesTagGroups()
|
||||
routerPath.client = client
|
||||
if !didAppear, canFilterTimeline {
|
||||
didAppear = true
|
||||
|
@ -257,18 +252,4 @@ struct TimelineTab: View {
|
|||
timeline = .federated
|
||||
}
|
||||
}
|
||||
|
||||
func migrateUserPreferencesTimeline() {
|
||||
for instance in legacyLocalTimelines {
|
||||
context.insert(LocalTimeline(instance: instance))
|
||||
}
|
||||
legacyLocalTimelines = []
|
||||
}
|
||||
|
||||
func migrateUserPreferencesTagGroups() {
|
||||
for group in legacyTagGroups {
|
||||
context.insert(TagGroup(title: group.title, symbolName: group.sfSymbolName, tags: group.tags))
|
||||
}
|
||||
legacyTagGroups = []
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ public extension AppAccount {
|
|||
}
|
||||
|
||||
static func retrieveAll() -> [AppAccount] {
|
||||
migrateLegacyAccounts()
|
||||
let keychain = Self.keychain
|
||||
let decoder = JSONDecoder()
|
||||
let keys = keychain.allKeys
|
||||
|
@ -40,19 +39,6 @@ public extension AppAccount {
|
|||
return accounts
|
||||
}
|
||||
|
||||
static func migrateLegacyAccounts() {
|
||||
let keychain = KeychainSwift()
|
||||
let decoder = JSONDecoder()
|
||||
let keys = keychain.allKeys
|
||||
for key in keys {
|
||||
if let data = keychain.getData(key) {
|
||||
if let account = try? decoder.decode(AppAccount.self, from: data) {
|
||||
try? account.save()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func deleteAll() {
|
||||
let keychain = Self.keychain
|
||||
let keys = keychain.allKeys
|
||||
|
|
|
@ -105,10 +105,11 @@ struct ConversationMessageView: View {
|
|||
Button {
|
||||
Task {
|
||||
do {
|
||||
let status: Status = if isLiked {
|
||||
try await client.post(endpoint: Statuses.unfavorite(id: message.id))
|
||||
let status: Status
|
||||
if isLiked {
|
||||
status = try await client.post(endpoint: Statuses.unfavorite(id: message.id))
|
||||
} else {
|
||||
try await client.post(endpoint: Statuses.favorite(id: message.id))
|
||||
status = try await client.post(endpoint: Statuses.favorite(id: message.id))
|
||||
}
|
||||
withAnimation {
|
||||
isLiked = status.favourited == true
|
||||
|
@ -121,10 +122,11 @@ struct ConversationMessageView: View {
|
|||
}
|
||||
Button { Task {
|
||||
do {
|
||||
let status: Status = if isBookmarked {
|
||||
try await client.post(endpoint: Statuses.unbookmark(id: message.id))
|
||||
let status: Status
|
||||
if isBookmarked {
|
||||
status = try await client.post(endpoint: Statuses.unbookmark(id: message.id))
|
||||
} else {
|
||||
try await client.post(endpoint: Statuses.bookmark(id: message.id))
|
||||
status = try await client.post(endpoint: Statuses.bookmark(id: message.id))
|
||||
}
|
||||
withAnimation {
|
||||
isBookmarked = status.bookmarked == true
|
||||
|
|
|
@ -349,7 +349,7 @@ import SwiftUI
|
|||
}
|
||||
|
||||
public var totalNotificationsCount: Int {
|
||||
notificationsCount.compactMap(\.value).reduce(0, +)
|
||||
notificationsCount.compactMap{ $0.value }.reduce(0, +)
|
||||
}
|
||||
|
||||
public func reloadNotificationsCount(tokens: [OauthToken]) {
|
||||
|
|
|
@ -15,14 +15,3 @@ import SwiftUI
|
|||
creationDate = Date()
|
||||
}
|
||||
}
|
||||
|
||||
public struct LegacyTagGroup: Codable, Equatable, Hashable {
|
||||
public let title: String
|
||||
public let sfSymbolName: String
|
||||
public let main: String
|
||||
public let additional: [String]
|
||||
|
||||
public var tags: [String] {
|
||||
[main] + additional
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ import SwiftData
|
|||
import SwiftUI
|
||||
|
||||
struct DraftsListView: View {
|
||||
@AppStorage("draft_posts") public var legacyDraftPosts: [String] = []
|
||||
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(\.modelContext) private var context
|
||||
|
||||
|
@ -49,17 +47,6 @@ struct DraftsListView: View {
|
|||
.background(theme.secondaryBackgroundColor)
|
||||
.navigationTitle("status.editor.drafts.navigation-title")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.onAppear {
|
||||
migrateUserPreferencesDraft()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func migrateUserPreferencesDraft() {
|
||||
for draft in legacyDraftPosts {
|
||||
let newDraft = Draft(content: draft)
|
||||
context.insert(newDraft)
|
||||
}
|
||||
legacyDraftPosts = []
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue