Fix errors and some warnings when building with Swift 5.8 (#952)

This commit is contained in:
Jed Fox 2023-03-01 08:58:12 -05:00 committed by GitHub
parent a0b318ad7b
commit b8f1304c56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 75 additions and 100 deletions

View File

@ -72,15 +72,6 @@
"version" : "4.2.2" "version" : "4.2.2"
} }
}, },
{
"identity" : "kingfisher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/onevcat/Kingfisher.git",
"state" : {
"revision" : "44e891bdb61426a95e31492a67c7c0dfad1f87c5",
"version" : "7.4.1"
}
},
{ {
"identity" : "metatextkit", "identity" : "metatextkit",
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
@ -216,15 +207,6 @@
"version" : "2.13.0" "version" : "2.13.0"
} }
}, },
{
"identity" : "thirdpartymailer",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vtourraine/ThirdPartyMailer.git",
"state" : {
"revision" : "44c1cfaa6969963f22691aa67f88a69e3b6d651f",
"version" : "2.1.0"
}
},
{ {
"identity" : "tocropviewcontroller", "identity" : "tocropviewcontroller",
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",

View File

@ -8,7 +8,7 @@
import os import os
import Foundation import Foundation
import Combine import Combine
import CoreData @_exported import CoreData
import MastodonCommon import MastodonCommon
public final class CoreDataStack { public final class CoreDataStack {

View File

@ -6,6 +6,7 @@
// //
import Foundation import Foundation
import Combine
public protocol StatusPublisher: ProgressReporting { public protocol StatusPublisher: ProgressReporting {
var state: Published<StatusPublisherState>.Publisher { get } var state: Published<StatusPublisherState>.Publisher { get }

View File

@ -8,10 +8,10 @@
import Foundation import Foundation
// https://gist.github.com/DougGregor/92a2e4f6e11f6d733fb5065e9d1c880f // https://gist.github.com/DougGregor/92a2e4f6e11f6d733fb5065e9d1c880f
extension Collection { extension Collection where Self: Sendable, Index: Sendable {
public func parallelMap<T>( public func parallelMap<T: Sendable>(
parallelism requestedParallelism: Int? = nil, parallelism requestedParallelism: Int? = nil,
_ transform: @escaping (Element) async throws -> T _ transform: @escaping @Sendable (Element) async throws -> T
) async rethrows -> [T] { ) async rethrows -> [T] {
let defaultParallelism = 2 let defaultParallelism = 2
let parallelism = requestedParallelism ?? defaultParallelism let parallelism = requestedParallelism ?? defaultParallelism
@ -57,7 +57,7 @@ extension Collection {
func parallelEach( func parallelEach(
parallelism requestedParallelism: Int? = nil, parallelism requestedParallelism: Int? = nil,
_ work: @escaping (Element) async throws -> Void _ work: @escaping @Sendable (Element) async throws -> Void
) async rethrows { ) async rethrows {
_ = try await parallelMap { _ = try await parallelMap {
try await work($0) try await work($0)

View File

@ -17,7 +17,7 @@ extension Mastodon.Entity {
/// 2021/1/28 /// 2021/1/28
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/account/) /// [Document](https://docs.joinmastodon.org/entities/account/)
public class Account: Codable { public final class Account: Codable, Sendable {
public typealias ID = String public typealias ID = String

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/28 /// 2021/1/28
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/activity/) /// [Document](https://docs.joinmastodon.org/entities/activity/)
public struct Activity: Codable { public struct Activity: Codable, Sendable {
public let week: Date public let week: Date
public let statuses: Int public let statuses: Int
public let logins: Int public let logins: Int

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/28 /// 2021/1/28
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/announcement/) /// [Document](https://docs.joinmastodon.org/entities/announcement/)
public struct Announcement: Codable { public struct Announcement: Codable, Sendable {
public typealias ID = String public typealias ID = String

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/28 /// 2021/1/28
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/announcementreaction/) /// [Document](https://docs.joinmastodon.org/entities/announcementreaction/)
public struct AnnouncementReaction: Codable { public struct AnnouncementReaction: Codable, Sendable {
// Base // Base
public let name: String public let name: String
public let count: Int public let count: Int

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/28 /// 2021/1/28
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/application/) /// [Document](https://docs.joinmastodon.org/entities/application/)
public struct Application: Codable { public struct Application: Codable, Sendable {
public let name: String public let name: String

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/28 /// 2021/1/28
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/attachment/) /// [Document](https://docs.joinmastodon.org/entities/attachment/)
public struct Attachment: Codable { public struct Attachment: Codable, Sendable {
public typealias ID = String public typealias ID = String
@ -48,7 +48,7 @@ extension Mastodon.Entity {
extension Mastodon.Entity.Attachment { extension Mastodon.Entity.Attachment {
public typealias AttachmentType = Type public typealias AttachmentType = Type
public enum `Type`: RawRepresentable, Codable { public enum `Type`: RawRepresentable, Codable, Sendable {
case unknown case unknown
case image case image
case gifv case gifv
@ -85,7 +85,7 @@ extension Mastodon.Entity.Attachment {
extension Mastodon.Entity.Attachment { extension Mastodon.Entity.Attachment {
/// # Reference /// # Reference
/// https://github.com/tootsuite/mastodon/blob/v3.3.0/app/models/media_attachment.rb /// https://github.com/tootsuite/mastodon/blob/v3.3.0/app/models/media_attachment.rb
public struct Meta: Codable { public struct Meta: Codable, Sendable {
public let original: Format? public let original: Format?
public let small: Format? public let small: Format?
public let focus: Focus? public let focus: Focus?
@ -122,7 +122,7 @@ extension Mastodon.Entity.Attachment {
} }
extension Mastodon.Entity.Attachment.Meta { extension Mastodon.Entity.Attachment.Meta {
public struct Format: Codable { public struct Format: Codable, Sendable {
public let width: Int? public let width: Int?
public let height: Int? public let height: Int?
public let size: String? public let size: String?
@ -142,7 +142,7 @@ extension Mastodon.Entity.Attachment.Meta {
} }
} }
public struct Focus: Codable { public struct Focus: Codable, Sendable {
public let x: Double public let x: Double
public let y: Double public let y: Double
} }

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/28 /// 2021/1/28
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/card/) /// [Document](https://docs.joinmastodon.org/entities/card/)
public struct Card: Codable { public struct Card: Codable, Sendable {
// Base // Base
public let url: String public let url: String
public let title: String public let title: String
@ -54,7 +54,7 @@ extension Mastodon.Entity {
} }
extension Mastodon.Entity.Card { extension Mastodon.Entity.Card {
public enum `Type`: RawRepresentable, Codable { public enum `Type`: RawRepresentable, Codable, Sendable {
case link case link
case photo case photo
case video case video

View File

@ -9,7 +9,7 @@ import Foundation
extension Mastodon.Entity { extension Mastodon.Entity {
public struct Category: Codable { public struct Category: Codable, Sendable {
public let category: Kind public let category: Kind
public let serversCount: Int public let serversCount: Int
@ -25,7 +25,7 @@ extension Mastodon.Entity {
/// # Reference /// # Reference
/// https://joinmastodon.org/communities /// https://joinmastodon.org/communities
public enum Kind: RawRepresentable, Codable { public enum Kind: RawRepresentable, Codable, Sendable {
case general case general
case regional case regional

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/28 /// 2021/1/28
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/context/) /// [Document](https://docs.joinmastodon.org/entities/context/)
public struct Context: Codable { public struct Context: Codable, Sendable {
public let ancestors: [Status] public let ancestors: [Status]
public let descendants: [Status] public let descendants: [Status]
} }

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/28 /// 2021/1/28
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/emoji/) /// [Document](https://docs.joinmastodon.org/entities/emoji/)
public struct Emoji: Codable { public struct Emoji: Codable, Sendable {
public let shortcode: String public let shortcode: String
public let url: String public let url: String
public let staticURL: String public let staticURL: String

View File

@ -17,7 +17,7 @@ extension Mastodon.Entity {
/// 2022/5/16 /// 2022/5/16
/// # Reference /// # Reference
/// [Document](TBD) /// [Document](TBD)
public class FamiliarFollowers: Codable { public class FamiliarFollowers: Codable, Sendable {
public let id: Mastodon.Entity.Account.ID public let id: Mastodon.Entity.Account.ID
public let accounts: [Mastodon.Entity.Account] public let accounts: [Mastodon.Entity.Account]
} }

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/28 /// 2021/1/28
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/field/) /// [Document](https://docs.joinmastodon.org/entities/field/)
public struct Field: Codable { public struct Field: Codable, Sendable {
public let name: String public let name: String
public let value: String public let value: String

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/28 /// 2021/1/28
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/history/) /// [Document](https://docs.joinmastodon.org/entities/history/)
public struct History: Codable { public struct History: Codable, Sendable {
/// UNIX timestamp on midnight of the given day /// UNIX timestamp on midnight of the given day
public let day: Date public let day: Date
public let uses: String public let uses: String

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2022/4/13 /// 2022/4/13
/// # Reference /// # Reference
/// [Document](TBD) /// [Document](TBD)
public struct Link: Codable { public struct Link: Codable, Sendable {
public let url: String public let url: String
public let title: String public let title: String
public let description: String public let description: String

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/28 /// 2021/1/28
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/mention/) /// [Document](https://docs.joinmastodon.org/entities/mention/)
public struct Mention: Codable { public struct Mention: Codable, Sendable {
public typealias ID = String public typealias ID = String

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/29 /// 2021/1/29
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/notification/) /// [Document](https://docs.joinmastodon.org/entities/notification/)
public struct Notification: Codable { public struct Notification: Codable, Sendable {
public typealias ID = String public typealias ID = String
public let id: ID public let id: ID
@ -38,7 +38,7 @@ extension Mastodon.Entity {
extension Mastodon.Entity.Notification { extension Mastodon.Entity.Notification {
public typealias NotificationType = Type public typealias NotificationType = Type
public enum `Type`: RawRepresentable, Codable { public enum `Type`: RawRepresentable, Codable, Sendable {
case follow case follow
case followRequest case followRequest
case mention case mention

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/2/24 /// 2021/2/24
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/poll/) /// [Document](https://docs.joinmastodon.org/entities/poll/)
public struct Poll: Codable { public struct Poll: Codable, Sendable {
public typealias ID = String public typealias ID = String
public let id: ID public let id: ID
@ -47,7 +47,7 @@ extension Mastodon.Entity {
} }
extension Mastodon.Entity.Poll { extension Mastodon.Entity.Poll {
public struct Option: Codable { public struct Option: Codable, Sendable {
public let title: String public let title: String
/// nil if results are not published yet /// nil if results are not published yet
public let votesCount: Int? public let votesCount: Int?

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/1/29 /// 2021/1/29
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/relationship/) /// [Document](https://docs.joinmastodon.org/entities/relationship/)
public struct Relationship: Codable { public struct Relationship: Codable, Sendable {
public typealias ID = String public typealias ID = String
public let id: ID public let id: ID

View File

@ -7,7 +7,7 @@
import Foundation import Foundation
extension Mastodon.Entity { extension Mastodon.Entity {
public struct SearchResult: Codable { public struct SearchResult: Codable, Sendable {
public init(accounts: [Mastodon.Entity.Account], statuses: [Mastodon.Entity.Status], hashtags: [Mastodon.Entity.Tag]) { public init(accounts: [Mastodon.Entity.Account], statuses: [Mastodon.Entity.Status], hashtags: [Mastodon.Entity.Tag]) {
self.accounts = accounts self.accounts = accounts
self.statuses = statuses self.statuses = statuses

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2021/2/3 /// 2021/2/3
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/source/) /// [Document](https://docs.joinmastodon.org/entities/source/)
public struct Source: Codable { public struct Source: Codable, Sendable {
// Base // Base
public let note: String public let note: String
@ -40,7 +40,7 @@ extension Mastodon.Entity {
} }
extension Mastodon.Entity.Source { extension Mastodon.Entity.Source {
public enum Privacy: RawRepresentable, Codable { public enum Privacy: RawRepresentable, Codable, Sendable {
case `public` case `public`
case unlisted case unlisted
case `private` case `private`

View File

@ -17,7 +17,7 @@ extension Mastodon.Entity {
/// 2021/2/23 /// 2021/2/23
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/status/) /// [Document](https://docs.joinmastodon.org/entities/status/)
public class Status: Codable { public final class Status: Codable, Sendable {
public typealias ID = String public typealias ID = String
@ -102,7 +102,7 @@ extension Mastodon.Entity {
} }
extension Mastodon.Entity.Status { extension Mastodon.Entity.Status {
public enum Visibility: RawRepresentable, Codable, Hashable { public enum Visibility: RawRepresentable, Codable, Hashable, Sendable {
case `public` case `public`
case unlisted case unlisted
case `private` case `private`

View File

@ -64,7 +64,7 @@ extension Mastodon.Entity {
} }
} }
public struct EmptySubscription: Codable { public struct EmptySubscription: Codable, Sendable {
} }
} }

View File

@ -9,7 +9,7 @@ import Foundation
extension Mastodon.Entity.V2 { extension Mastodon.Entity.V2 {
public struct SuggestionAccount: Codable { public struct SuggestionAccount: Codable, Sendable {
public let source: String public let source: String
public let account: Mastodon.Entity.Account public let account: Mastodon.Entity.Account

View File

@ -16,7 +16,7 @@ extension Mastodon.Entity {
/// 2022/11/22 /// 2022/11/22
/// # Reference /// # Reference
/// [Document](https://docs.joinmastodon.org/entities/tag/) /// [Document](https://docs.joinmastodon.org/entities/tag/)
public struct Tag: Hashable, Codable { public struct Tag: Hashable, Codable, Sendable {
// Base // Base
public let name: String public let name: String

View File

@ -8,7 +8,7 @@
import Foundation import Foundation
extension Mastodon.Entity { extension Mastodon.Entity {
public struct Translation: Codable { public struct Translation: Codable, Sendable {
public let content: String? public let content: String?
public let sourceLanguage: String? public let sourceLanguage: String?
public let provider: String? public let provider: String?

View File

@ -8,7 +8,7 @@
import Foundation import Foundation
extension Mastodon.Response { extension Mastodon.Response {
public struct Content<T> { public struct Content<T: Sendable>: Sendable {
// entity // entity
public let value: T public let value: T
@ -67,7 +67,7 @@ extension Mastodon.Response.Content {
} }
extension Mastodon.Response { extension Mastodon.Response {
public struct RateLimit { public struct RateLimit: Sendable {
public let limit: Int public let limit: Int
public let remaining: Int public let remaining: Int
@ -103,7 +103,7 @@ extension Mastodon.Response {
} }
extension Mastodon.Response { extension Mastodon.Response {
public struct Link { public struct Link: Sendable {
public let maxID: Mastodon.Entity.Status.ID? public let maxID: Mastodon.Entity.Status.ID?
public let minID: Mastodon.Entity.Status.ID? public let minID: Mastodon.Entity.Status.ID?
public let linkIDs: [String: Mastodon.Entity.Status.ID] public let linkIDs: [String: Mastodon.Entity.Status.ID]

View File

@ -5,7 +5,7 @@
// Created by Jed Fox on 2022-12-20. // Created by Jed Fox on 2022-12-20.
// //
import Foundation import CoreGraphics
extension CGSize: Hashable { extension CGSize: Hashable {
public func hash(into hasher: inout Hasher) { public func hash(into hasher: inout Hasher) {

View File

@ -9,6 +9,7 @@ import os.log
import UIKit import UIKit
import Combine import Combine
import PhotosUI import PhotosUI
import MastodonSDK
import MastodonCore import MastodonCore
import MastodonLocalization import MastodonLocalization
import func QuartzCore.CACurrentMediaTime import func QuartzCore.CACurrentMediaTime

View File

@ -8,6 +8,7 @@
import SwiftUI import SwiftUI
import MastodonAsset import MastodonAsset
import MastodonCore import MastodonCore
import Combine
public struct PollAddOptionRow: View { public struct PollAddOptionRow: View {

View File

@ -7,6 +7,7 @@
import os.log import os.log
import Foundation import Foundation
import Combine
import CoreData import CoreData
import CoreDataStack import CoreDataStack
import MastodonCore import MastodonCore

View File

@ -6,6 +6,7 @@
// //
import UIKit import UIKit
import Combine
public final class CircleAvatarButton: AvatarButton { public final class CircleAvatarButton: AvatarButton {

View File

@ -40,14 +40,12 @@ struct FollowersCountWidgetView: View {
private func viewForSmallWidgetNoChart(_ account: FollowersEntryAccountable) -> some View { private func viewForSmallWidgetNoChart(_ account: FollowersEntryAccountable) -> some View {
HStack { HStack {
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
if let avatarImage = account.avatarImage { Image(uiImage: account.avatarImage)
Image(uiImage: avatarImage) .resizable()
.resizable() .frame(width: 50, height: 50)
.frame(width: 50, height: 50) .cornerRadius(12)
.cornerRadius(12) .padding(.bottom, 8)
.padding(.bottom, 8)
}
Text(account.followersCount.asAbbreviatedCountString()) Text(account.followersCount.asAbbreviatedCountString())
.font(.largeTitle) .font(.largeTitle)
.lineLimit(1) .lineLimit(1)
@ -73,12 +71,10 @@ struct FollowersCountWidgetView: View {
private func viewForSmallWidgetYesChart(_ account: FollowersEntryAccountable) -> some View { private func viewForSmallWidgetYesChart(_ account: FollowersEntryAccountable) -> some View {
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
HStack { HStack {
if let avatarImage = account.avatarImage { Image(uiImage: account.avatarImage)
Image(uiImage: avatarImage) .resizable()
.resizable() .frame(width: 23, height: 23)
.frame(width: 23, height: 23) .cornerRadius(5)
.cornerRadius(5)
}
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text(account.displayNameWithFallback) Text(account.displayNameWithFallback)
.font(.caption) .font(.caption)

View File

@ -44,12 +44,10 @@ struct LatestFollowersWidgetView: View {
ForEach(accounts, id: \.acct) { account in ForEach(accounts, id: \.acct) { account in
HStack { HStack {
if let avatarImage = account.avatarImage { Image(uiImage: account.avatarImage)
Image(uiImage: avatarImage) .resizable()
.resizable() .frame(width: 32, height: 32)
.frame(width: 32, height: 32) .cornerRadius(5)
.cornerRadius(5)
}
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text(account.displayNameWithFallback) Text(account.displayNameWithFallback)
@ -87,12 +85,10 @@ struct LatestFollowersWidgetView: View {
ForEach(accounts, id: \.acct) { account in ForEach(accounts, id: \.acct) { account in
HStack { HStack {
if let avatarImage = account.avatarImage { Image(uiImage: account.avatarImage)
Image(uiImage: avatarImage) .resizable()
.resizable() .frame(width: 32, height: 32)
.frame(width: 32, height: 32) .cornerRadius(5)
.cornerRadius(5)
}
VStack(alignment: .leading) { VStack(alignment: .leading) {
HStack { HStack {

View File

@ -32,12 +32,10 @@ struct MultiFollowersCountWidgetView: View {
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
ForEach(accounts, id: \.acct) { account in ForEach(accounts, id: \.acct) { account in
HStack { HStack {
if let avatarImage = account.avatarImage { Image(uiImage: account.avatarImage)
Image(uiImage: avatarImage) .resizable()
.resizable() .frame(width: 32, height: 32)
.frame(width: 32, height: 32) .cornerRadius(5)
.cornerRadius(5)
}
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text(account.followersCount.asAbbreviatedCountString()) Text(account.followersCount.asAbbreviatedCountString())
.font(.title2) .font(.title2)
@ -67,12 +65,10 @@ struct MultiFollowersCountWidgetView: View {
]) { ]) {
ForEach(accounts, id: \.acct) { account in ForEach(accounts, id: \.acct) { account in
HStack { HStack {
if let avatarImage = account.avatarImage { Image(uiImage: account.avatarImage)
Image(uiImage: avatarImage) .resizable()
.resizable() .frame(width: 32, height: 32)
.frame(width: 32, height: 32) .cornerRadius(5)
.cornerRadius(5)
}
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text(account.followersCount.asAbbreviatedCountString()) Text(account.followersCount.asAbbreviatedCountString())
.font(.title2) .font(.title2)