This commit is contained in:
Thomas Ricouard 2024-08-01 08:58:54 +02:00
parent 2a3da72239
commit a72f290038
38 changed files with 209 additions and 207 deletions

View file

@ -1,4 +1,5 @@
import AppAccount import AppAccount
import AuthenticationServices
import Combine import Combine
import DesignSystem import DesignSystem
import Env import Env
@ -7,7 +8,6 @@ import Network
import NukeUI import NukeUI
import SafariServices import SafariServices
import SwiftUI import SwiftUI
import AuthenticationServices
@MainActor @MainActor
struct AddAccountView: View { struct AddAccountView: View {

View file

@ -29,11 +29,11 @@ public struct DefaultListEntityQuery: EntityQuery {
var account var account
public func entities(for _: [ListEntity.ID]) async throws -> [ListEntity] { public func entities(for _: [ListEntity.ID]) async throws -> [ListEntity] {
await fetchLists().map{ .init(list: $0 )} await fetchLists().map { .init(list: $0) }
} }
public func suggestedEntities() async throws -> [ListEntity] { public func suggestedEntities() async throws -> [ListEntity] {
await fetchLists().map{ .init(list: $0 )} await fetchLists().map { .init(list: $0) }
} }
public func defaultResult() async -> ListEntity? { public func defaultResult() async -> ListEntity? {

View file

@ -10,12 +10,12 @@ struct AccountWidgetProvider: AppIntentTimelineProvider {
.init(date: Date(), account: .placeholder(), avatar: nil) .init(date: Date(), account: .placeholder(), avatar: nil)
} }
func snapshot(for configuration: AccountWidgetConfiguration, in context: Context) async -> AccountWidgetEntry { func snapshot(for configuration: AccountWidgetConfiguration, in _: Context) async -> AccountWidgetEntry {
let account = await fetchAccount(configuration: configuration) let account = await fetchAccount(configuration: configuration)
return .init(date: Date(), account: account, avatar: nil) return .init(date: Date(), account: account, avatar: nil)
} }
func timeline(for configuration: AccountWidgetConfiguration, in context: Context) async -> Timeline<AccountWidgetEntry> { func timeline(for configuration: AccountWidgetConfiguration, in _: Context) async -> Timeline<AccountWidgetEntry> {
let account = await fetchAccount(configuration: configuration) let account = await fetchAccount(configuration: configuration)
let images = try? await loadImages(urls: [account.avatar]) let images = try? await loadImages(urls: [account.avatar])
return .init(entries: [.init(date: Date(), account: account, avatar: images?.first?.value)], return .init(entries: [.init(date: Date(), account: account, avatar: images?.first?.value)],

View file

@ -11,7 +11,6 @@ struct AccountWidgetView: View {
@Environment(\.widgetFamily) var family @Environment(\.widgetFamily) var family
@Environment(\.redactionReasons) var redacted @Environment(\.redactionReasons) var redacted
var body: some View { var body: some View {
VStack(alignment: .center, spacing: 4) { VStack(alignment: .center, spacing: 4) {
if let avatar = entry.avatar { if let avatar = entry.avatar {

View file

@ -85,7 +85,7 @@ import SwiftUI
private(set) var statuses: [Status] = [] private(set) var statuses: [Status] = []
var statusesMedias: [MediaStatus] { var statusesMedias: [MediaStatus] {
statuses.filter{ !$0.mediaAttachments.isEmpty }.flatMap{ $0.asMediaStatus} statuses.filter { !$0.mediaAttachments.isEmpty }.flatMap { $0.asMediaStatus }
} }
var boosts: [Status] = [] var boosts: [Status] = []

View file

@ -1,10 +1,10 @@
import SwiftUI
import DesignSystem import DesignSystem
import NukeUI
import Env import Env
import MediaUI import MediaUI
import Models import Models
import Network import Network
import NukeUI
import SwiftUI
@MainActor @MainActor
public struct AccountDetailMediaGridView: View { public struct AccountDetailMediaGridView: View {
@ -18,7 +18,7 @@ public struct AccountDetailMediaGridView: View {
public init(account: Account, initialMediaStatuses: [MediaStatus]) { public init(account: Account, initialMediaStatuses: [MediaStatus]) {
self.account = account self.account = account
self.mediaStatuses = initialMediaStatuses mediaStatuses = initialMediaStatuses
} }
public var body: some View { public var body: some View {
@ -26,7 +26,8 @@ public struct AccountDetailMediaGridView: View {
LazyVGrid(columns: [.init(.flexible(minimum: 100), spacing: 4), LazyVGrid(columns: [.init(.flexible(minimum: 100), spacing: 4),
.init(.flexible(minimum: 100), spacing: 4), .init(.flexible(minimum: 100), spacing: 4),
.init(.flexible(minimum: 100), spacing: 4)], .init(.flexible(minimum: 100), spacing: 4)],
spacing: 4) { spacing: 4)
{
ForEach(mediaStatuses) { status in ForEach(mediaStatuses) { status in
GeometryReader { proxy in GeometryReader { proxy in
if let url = status.attachment.url { if let url = status.attachment.url {
@ -111,6 +112,6 @@ public struct AccountDetailMediaGridView: View {
excludeReplies: true, excludeReplies: true,
excludeReblogs: true, excludeReblogs: true,
pinned: nil)) pinned: nil))
mediaStatuses.append(contentsOf: newStatuses.flatMap{ $0.asMediaStatus }) mediaStatuses.append(contentsOf: newStatuses.flatMap { $0.asMediaStatus })
} }
} }

View file

@ -3,8 +3,8 @@ import SwiftUI
#if canImport(_Translation_SwiftUI) #if canImport(_Translation_SwiftUI)
import Translation import Translation
extension View { public extension View {
public func addTranslateView(isPresented: Binding<Bool>, text: String) -> some View { func addTranslateView(isPresented: Binding<Bool>, text: String) -> some View {
if #available(iOS 17.4, *) { if #available(iOS 17.4, *) {
return self.translationPresentation(isPresented: isPresented, text: text) return self.translationPresentation(isPresented: isPresented, text: text)
} else { } else {

View file

@ -137,7 +137,7 @@ public enum SettingsStartingPoint {
public var path: [RouterDestination] = [] public var path: [RouterDestination] = []
public var presentedSheet: SheetDestination? public var presentedSheet: SheetDestination?
public static var settingsStartingPoint: SettingsStartingPoint? = nil public static var settingsStartingPoint: SettingsStartingPoint?
public init() {} public init() {}

View file

@ -149,8 +149,6 @@ import SwiftUI
case .statuses: case .statuses:
self.results[searchQuery]?.statuses.append(contentsOf: newPageResults.statuses) self.results[searchQuery]?.statuses.append(contentsOf: newPageResults.statuses)
} }
} catch { } catch {}
}
} }
} }

View file

@ -9,6 +9,7 @@ public struct Card: Codable, Identifiable, Equatable, Hashable {
public var id: String { public var id: String {
url url
} }
public let name: String public let name: String
public let url: String public let url: String
public let account: Account? public let account: Account?

View file

@ -79,7 +79,7 @@ public final class Status: AnyStatus, Codable, Identifiable, Equatable, Hashable
} }
public var asMediaStatus: [MediaStatus] { public var asMediaStatus: [MediaStatus] {
mediaAttachments.map{ .init(status: self, attachment: $0)} mediaAttachments.map { .init(status: self, attachment: $0) }
} }
public init(id: String, content: HTMLString, account: Account, createdAt: ServerDate, editedAt: ServerDate?, reblog: ReblogStatus?, mediaAttachments: [MediaAttachment], mentions: [Mention], repliesCount: Int, reblogsCount: Int, favouritesCount: Int, card: Card?, favourited: Bool?, reblogged: Bool?, pinned: Bool?, bookmarked: Bool?, emojis: [Emoji], url: String?, application: Application?, inReplyToId: String?, inReplyToAccountId: String?, visibility: Visibility, poll: Poll?, spoilerText: HTMLString, filtered: [Filtered]?, sensitive: Bool, language: String?) { public init(id: String, content: HTMLString, account: Account, createdAt: ServerDate, editedAt: ServerDate?, reblog: ReblogStatus?, mediaAttachments: [MediaAttachment], mentions: [Mention], repliesCount: Int, reblogsCount: Int, favouritesCount: Int, card: Card?, favourited: Bool?, reblogged: Bool?, pinned: Bool?, bookmarked: Bool?, emojis: [Emoji], url: String?, application: Application?, inReplyToId: String?, inReplyToAccountId: String?, visibility: Visibility, poll: Poll?, spoilerText: HTMLString, filtered: [Filtered]?, sensitive: Bool, language: String?) {

View file

@ -4,7 +4,6 @@ public enum Profile: Endpoint {
case deleteAvatar case deleteAvatar
case deleteHeader case deleteHeader
public func path() -> String { public func path() -> String {
switch self { switch self {
case .deleteAvatar: case .deleteAvatar:

View file

@ -194,7 +194,7 @@ extension StatusEditor {
} }
} }
private func makeErrorView(error: ServerError) -> some View { private func makeErrorView(error _: ServerError) -> some View {
ZStack { ZStack {
placeholderView placeholderView
Text("status.editor.error.upload") Text("status.editor.error.upload")

View file

@ -379,16 +379,18 @@ import SwiftUI
} }
var hasShown = false var hasShown = false
#if canImport(_Translation_SwiftUI) #if canImport(_Translation_SwiftUI)
if translation == nil, if translation == nil,
#available(iOS 17.4, *) { #available(iOS 17.4, *)
{
showAppleTranslation = true showAppleTranslation = true
hasShown = true hasShown = true
} }
#endif #endif
if !hasShown, if !hasShown,
translation == nil { translation == nil
{
if preferredTranslationType == .useDeepl { if preferredTranslationType == .useDeepl {
deeplTranslationError = true deeplTranslationError = true
} else { } else {

View file

@ -313,7 +313,8 @@ extension TimelineViewModel: StatusesFetcher {
guard !newStatuses.isEmpty, guard !newStatuses.isEmpty,
isTimelineVisible, isTimelineVisible,
!Task.isCancelled, !Task.isCancelled,
initialTimeline == timeline else { initialTimeline == timeline
else {
canStreamEvents = true canStreamEvents = true
return return
} }
@ -347,7 +348,8 @@ extension TimelineViewModel: StatusesFetcher {
if let topStatus = topStatus, if let topStatus = topStatus,
visibileStatuses.contains(where: { $0.id == topStatus.id }), visibileStatuses.contains(where: { $0.id == topStatus.id }),
scrollToTopVisible { scrollToTopVisible
{
updateTimelineWithScrollToTop(newStatuses: newStatuses, statuses: statuses, nextPageState: nextPageState) updateTimelineWithScrollToTop(newStatuses: newStatuses, statuses: statuses, nextPageState: nextPageState)
} else { } else {
updateTimelineWithAnimation(statuses: statuses, nextPageState: nextPageState) updateTimelineWithAnimation(statuses: statuses, nextPageState: nextPageState)
@ -381,7 +383,7 @@ extension TimelineViewModel: StatusesFetcher {
var allStatuses: [Status] = [] var allStatuses: [Status] = []
var latestMinId = minId var latestMinId = minId
do { do {
for _ in 1...maxPages { for _ in 1 ... maxPages {
if Task.isCancelled { break } if Task.isCancelled { break }
let newStatuses: [Status] = try await client.get(endpoint: timeline.endpoint( let newStatuses: [Status] = try await client.get(endpoint: timeline.endpoint(