mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +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: \LocalTimeline.creationDate, order: .reverse) var localTimelines: [LocalTimeline]
|
||||||
@Query(sort: \TagGroup.creationDate, order: .reverse) var tagGroups: [TagGroup]
|
@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
|
@AppStorage("last_timeline_filter") var lastTimelineFilter: TimelineFilter = .home
|
||||||
|
|
||||||
private let canFilterTimeline: Bool
|
private let canFilterTimeline: Bool
|
||||||
|
@ -56,8 +53,6 @@ struct TimelineTab: View {
|
||||||
.id(client.id)
|
.id(client.id)
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
migrateUserPreferencesTimeline()
|
|
||||||
migrateUserPreferencesTagGroups()
|
|
||||||
routerPath.client = client
|
routerPath.client = client
|
||||||
if !didAppear, canFilterTimeline {
|
if !didAppear, canFilterTimeline {
|
||||||
didAppear = true
|
didAppear = true
|
||||||
|
@ -257,18 +252,4 @@ struct TimelineTab: View {
|
||||||
timeline = .federated
|
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] {
|
static func retrieveAll() -> [AppAccount] {
|
||||||
migrateLegacyAccounts()
|
|
||||||
let keychain = Self.keychain
|
let keychain = Self.keychain
|
||||||
let decoder = JSONDecoder()
|
let decoder = JSONDecoder()
|
||||||
let keys = keychain.allKeys
|
let keys = keychain.allKeys
|
||||||
|
@ -40,19 +39,6 @@ public extension AppAccount {
|
||||||
return accounts
|
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() {
|
static func deleteAll() {
|
||||||
let keychain = Self.keychain
|
let keychain = Self.keychain
|
||||||
let keys = keychain.allKeys
|
let keys = keychain.allKeys
|
||||||
|
|
|
@ -105,10 +105,11 @@ struct ConversationMessageView: View {
|
||||||
Button {
|
Button {
|
||||||
Task {
|
Task {
|
||||||
do {
|
do {
|
||||||
let status: Status = if isLiked {
|
let status: Status
|
||||||
try await client.post(endpoint: Statuses.unfavorite(id: message.id))
|
if isLiked {
|
||||||
|
status = try await client.post(endpoint: Statuses.unfavorite(id: message.id))
|
||||||
} else {
|
} else {
|
||||||
try await client.post(endpoint: Statuses.favorite(id: message.id))
|
status = try await client.post(endpoint: Statuses.favorite(id: message.id))
|
||||||
}
|
}
|
||||||
withAnimation {
|
withAnimation {
|
||||||
isLiked = status.favourited == true
|
isLiked = status.favourited == true
|
||||||
|
@ -121,10 +122,11 @@ struct ConversationMessageView: View {
|
||||||
}
|
}
|
||||||
Button { Task {
|
Button { Task {
|
||||||
do {
|
do {
|
||||||
let status: Status = if isBookmarked {
|
let status: Status
|
||||||
try await client.post(endpoint: Statuses.unbookmark(id: message.id))
|
if isBookmarked {
|
||||||
|
status = try await client.post(endpoint: Statuses.unbookmark(id: message.id))
|
||||||
} else {
|
} else {
|
||||||
try await client.post(endpoint: Statuses.bookmark(id: message.id))
|
status = try await client.post(endpoint: Statuses.bookmark(id: message.id))
|
||||||
}
|
}
|
||||||
withAnimation {
|
withAnimation {
|
||||||
isBookmarked = status.bookmarked == true
|
isBookmarked = status.bookmarked == true
|
||||||
|
|
|
@ -349,7 +349,7 @@ import SwiftUI
|
||||||
}
|
}
|
||||||
|
|
||||||
public var totalNotificationsCount: Int {
|
public var totalNotificationsCount: Int {
|
||||||
notificationsCount.compactMap(\.value).reduce(0, +)
|
notificationsCount.compactMap{ $0.value }.reduce(0, +)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func reloadNotificationsCount(tokens: [OauthToken]) {
|
public func reloadNotificationsCount(tokens: [OauthToken]) {
|
||||||
|
|
|
@ -15,14 +15,3 @@ import SwiftUI
|
||||||
creationDate = Date()
|
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
|
import SwiftUI
|
||||||
|
|
||||||
struct DraftsListView: View {
|
struct DraftsListView: View {
|
||||||
@AppStorage("draft_posts") public var legacyDraftPosts: [String] = []
|
|
||||||
|
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
@Environment(\.modelContext) private var context
|
@Environment(\.modelContext) private var context
|
||||||
|
|
||||||
|
@ -49,17 +47,6 @@ struct DraftsListView: View {
|
||||||
.background(theme.secondaryBackgroundColor)
|
.background(theme.secondaryBackgroundColor)
|
||||||
.navigationTitle("status.editor.drafts.navigation-title")
|
.navigationTitle("status.editor.drafts.navigation-title")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.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