mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-06-05 13:28:50 +00:00
Swiftformat
This commit is contained in:
parent
06629cc397
commit
83e4e74329
22 changed files with 171 additions and 169 deletions
|
@ -5,9 +5,9 @@ import Env
|
||||||
import Foundation
|
import Foundation
|
||||||
import Models
|
import Models
|
||||||
import Network
|
import Network
|
||||||
|
import Nuke
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Timeline
|
import Timeline
|
||||||
import Nuke
|
|
||||||
|
|
||||||
struct SettingsTabs: View {
|
struct SettingsTabs: View {
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
|
|
@ -4,7 +4,6 @@ import SwiftUI
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
class EditAccountViewModel: ObservableObject {
|
class EditAccountViewModel: ObservableObject {
|
||||||
|
|
||||||
class FieldEditViewModel: ObservableObject, Identifiable {
|
class FieldEditViewModel: ObservableObject, Identifiable {
|
||||||
let id = UUID().uuidString
|
let id = UUID().uuidString
|
||||||
@Published var name: String = ""
|
@Published var name: String = ""
|
||||||
|
@ -44,7 +43,7 @@ class EditAccountViewModel: ObservableObject {
|
||||||
isBot = account.bot
|
isBot = account.bot
|
||||||
isLocked = account.locked
|
isLocked = account.locked
|
||||||
isDiscoverable = account.discoverable ?? false
|
isDiscoverable = account.discoverable ?? false
|
||||||
fields = account.source?.fields.map{ .init(name: $0.name, value: $0.value.asRawText) } ?? []
|
fields = account.source?.fields.map { .init(name: $0.name, value: $0.value.asRawText) } ?? []
|
||||||
withAnimation {
|
withAnimation {
|
||||||
isLoading = false
|
isLoading = false
|
||||||
}
|
}
|
||||||
|
@ -60,7 +59,7 @@ class EditAccountViewModel: ObservableObject {
|
||||||
bot: isBot,
|
bot: isBot,
|
||||||
locked: isLocked,
|
locked: isLocked,
|
||||||
discoverable: isDiscoverable,
|
discoverable: isDiscoverable,
|
||||||
fieldsAttributes: fields.map{ .init(name: $0.name, value: $0.value)})
|
fieldsAttributes: fields.map { .init(name: $0.name, value: $0.value) })
|
||||||
let response = try await client?.patch(endpoint: Accounts.updateCredentials(json: data))
|
let response = try await client?.patch(endpoint: Accounts.updateCredentials(json: data))
|
||||||
if response?.statusCode != 200 {
|
if response?.statusCode != 200 {
|
||||||
saveError = true
|
saveError = true
|
||||||
|
|
|
@ -17,8 +17,8 @@ public struct AppAccountsSelectorView: View {
|
||||||
var showNotificationBadge: Bool {
|
var showNotificationBadge: Bool {
|
||||||
accountsViewModel
|
accountsViewModel
|
||||||
.filter { $0.account?.id != currentAccount.account?.id }
|
.filter { $0.account?.id != currentAccount.account?.id }
|
||||||
.compactMap{ $0.appAccount.oauthToken }
|
.compactMap { $0.appAccount.oauthToken }
|
||||||
.map{ preferences.getNotificationsCount(for: $0) }
|
.map { preferences.getNotificationsCount(for: $0) }
|
||||||
.reduce(0, +) > 0
|
.reduce(0, +) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ public class QuickLook: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Published public private(set) var urls: [URL] = []
|
@Published public private(set) var urls: [URL] = []
|
||||||
@Published public private(set) var isPreparing: Bool = false
|
@Published public private(set) var isPreparing: Bool = false
|
||||||
@Published public private(set) var latestError: Error?
|
@Published public private(set) var latestError: Error?
|
||||||
|
@ -73,7 +74,7 @@ public class QuickLook: ObservableObject {
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
private func cleanup(urls: [URL]) {
|
private func cleanup(urls _: [URL]) {
|
||||||
try? FileManager.default.removeItem(at: quickLookDir)
|
try? FileManager.default.removeItem(at: quickLookDir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,8 @@ public struct UpdateCredentialsData: Encodable, Sendable {
|
||||||
bot: Bool,
|
bot: Bool,
|
||||||
locked: Bool,
|
locked: Bool,
|
||||||
discoverable: Bool,
|
discoverable: Bool,
|
||||||
fieldsAttributes: [FieldData]) {
|
fieldsAttributes: [FieldData])
|
||||||
|
{
|
||||||
self.displayName = displayName
|
self.displayName = displayName
|
||||||
self.note = note
|
self.note = note
|
||||||
self.source = source
|
self.source = source
|
||||||
|
@ -204,5 +205,4 @@ public struct UpdateCredentialsData: Encodable, Sendable {
|
||||||
}
|
}
|
||||||
self.fieldsAttributes = fieldAttributes
|
self.fieldsAttributes = fieldAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,6 @@ public extension URL {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extension UIImage {
|
extension UIImage {
|
||||||
func resized(to size: CGSize) -> UIImage {
|
func resized(to size: CGSize) -> UIImage {
|
||||||
UIGraphicsImageRenderer(size: size).image { _ in
|
UIGraphicsImageRenderer(size: size).image { _ in
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import SwiftUI
|
|
||||||
import Models
|
import Models
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
class StatusEmbedCache {
|
class StatusEmbedCache {
|
||||||
|
@ -8,7 +8,7 @@ class StatusEmbedCache {
|
||||||
|
|
||||||
private var cache: [URL: Status] = [:]
|
private var cache: [URL: Status] = [:]
|
||||||
|
|
||||||
private init() { }
|
private init() {}
|
||||||
|
|
||||||
func set(url: URL, status: Status) {
|
func set(url: URL, status: Status) {
|
||||||
cache[url] = status
|
cache[url] = status
|
||||||
|
|
|
@ -99,7 +99,8 @@ public class StatusRowViewModel: ObservableObject {
|
||||||
isFiltered = filter != nil
|
isFiltered = filter != nil
|
||||||
|
|
||||||
if let url = embededStatusURL(),
|
if let url = embededStatusURL(),
|
||||||
let embed = StatusEmbedCache.shared.get(url: url) {
|
let embed = StatusEmbedCache.shared.get(url: url)
|
||||||
|
{
|
||||||
isEmbedLoading = false
|
isEmbedLoading = false
|
||||||
embeddedStatus = embed
|
embeddedStatus = embed
|
||||||
}
|
}
|
||||||
|
@ -159,7 +160,8 @@ public class StatusRowViewModel: ObservableObject {
|
||||||
let content = status.reblog?.content ?? status.content
|
let content = status.reblog?.content ?? status.content
|
||||||
if !content.statusesURLs.isEmpty,
|
if !content.statusesURLs.isEmpty,
|
||||||
let url = content.statusesURLs.first,
|
let url = content.statusesURLs.first,
|
||||||
client.hasConnection(with: url) {
|
client.hasConnection(with: url)
|
||||||
|
{
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -167,7 +169,8 @@ public class StatusRowViewModel: ObservableObject {
|
||||||
|
|
||||||
func loadEmbeddedStatus() async {
|
func loadEmbeddedStatus() async {
|
||||||
guard embeddedStatus == nil,
|
guard embeddedStatus == nil,
|
||||||
let url = embededStatusURL() else {
|
let url = embededStatusURL()
|
||||||
|
else {
|
||||||
if isEmbedLoading {
|
if isEmbedLoading {
|
||||||
isEmbedLoading = false
|
isEmbedLoading = false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue