Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Akkoma support #2253

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion IceCubesApp/App/Tabs/Settings/InstanceInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ public struct InstanceInfoSection: View {
public var body: some View {
Section("instance.info.section.info") {
LabeledContent("instance.info.name", value: instance.title)
Text(instance.shortDescription)
if instance.shortDescription != nil {
Text(instance.shortDescription!)
} else if instance.description != nil {
Text(instance.description!)
}
LabeledContent("instance.info.email", value: instance.email)
LabeledContent("instance.info.version") {
Text(instance.version).monospaced()
Expand Down
2 changes: 1 addition & 1 deletion Packages/Models/Sources/Models/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public final class Account: Codable, Identifiable, Hashable, Sendable, Equatable
}

public struct Source: Codable, Equatable, Sendable {
public let privacy: Visibility
public let privacy: Visibility?
public let sensitive: Bool
public let language: String?
public let note: String
Expand Down
4 changes: 2 additions & 2 deletions Packages/Models/Sources/Models/Card.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public struct Card: Codable, Identifiable, Equatable, Hashable {
public let providerName: String?
public let type: String
public let image: URL?
public let width: CGFloat
public let height: CGFloat
public let width: CGFloat?
public let height: CGFloat?
public let history: [History]?
public let authors: [CardAuthor]?
}
Expand Down
3 changes: 2 additions & 1 deletion Packages/Models/Sources/Models/Instance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public struct Instance: Codable, Sendable {
}

public let title: String
public let shortDescription: String
public let description: String?
public let shortDescription: String?
public let email: String
public let version: String
public let stats: Stats
Expand Down
20 changes: 18 additions & 2 deletions Packages/Models/Sources/Models/Tag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,27 @@ public struct Tag: Codable, Identifiable, Equatable, Hashable {
public let history: [History]

public var totalUses: Int {
history.compactMap { Int($0.uses) }.reduce(0, +)
return history.compactMap { Int($0.uses) }.reduce(0, +)
}

public var totalAccounts: Int {
history.compactMap { Int($0.accounts) }.reduce(0, +)
return history.compactMap { Int($0.accounts) }.reduce(0, +)
}

public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
name = try container.decode(String.self, forKey: .name)
url = try container.decode(String.self, forKey: .url)
do {
history = try container.decode([History].self, forKey: .history)
} catch DecodingError.keyNotFound {
history = []
}
do {
following = try container.decode(Bool.self, forKey: .following)
} catch DecodingError.keyNotFound {
following = false
}
}
}

Expand Down
20 changes: 13 additions & 7 deletions Packages/Network/Sources/Network/Endpoint/Apps.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import Foundation
import Models

private struct InstanceAppRequest: Codable, Sendable {
public let clientName: String
public let redirectUris: String
public let scopes: String
public let website: String
}

public enum Apps: Endpoint {
case registerApp

Expand All @@ -10,16 +17,15 @@ public enum Apps: Endpoint {
"apps"
}
}

public func queryItems() -> [URLQueryItem]? {
nil
}

public var jsonValue: Encodable? {
switch self {
case .registerApp:
[
.init(name: "client_name", value: AppInfo.clientName),
.init(name: "redirect_uris", value: AppInfo.scheme),
.init(name: "scopes", value: AppInfo.scopes),
.init(name: "website", value: AppInfo.weblink),
]
InstanceAppRequest(clientName: AppInfo.clientName, redirectUris: AppInfo.scheme, scopes: AppInfo.scopes, website: AppInfo.weblink)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public struct StatusRowCardView: View {
@ViewBuilder
private func defaultLinkPreview(_ title: String, _ url: URL) -> some View {
if let imageURL = card.image {
DefaultPreviewImage(url: imageURL, originalWidth: card.width, originalHeight: card.height)
DefaultPreviewImage(url: imageURL, originalWidth: card.width ?? 0, originalHeight: card.height ?? 0)
}

VStack(alignment: .leading, spacing: 4) {
Expand Down