mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-22 16:31:00 +00:00
Properly JSON encode image ALT fix #1492
This commit is contained in:
parent
c0b34d352b
commit
9ed785db0e
2 changed files with 19 additions and 8 deletions
|
@ -2,7 +2,7 @@ import Foundation
|
|||
|
||||
public enum Media: Endpoint {
|
||||
case medias
|
||||
case media(id: String, description: String?)
|
||||
case media(id: String, json: MediaDescriptionData)
|
||||
|
||||
public func path() -> String {
|
||||
switch self {
|
||||
|
@ -14,14 +14,25 @@ public enum Media: Endpoint {
|
|||
}
|
||||
|
||||
public func queryItems() -> [URLQueryItem]? {
|
||||
return nil
|
||||
}
|
||||
|
||||
public var jsonValue: Encodable? {
|
||||
switch self {
|
||||
case let .media(_, description):
|
||||
if let description {
|
||||
return [.init(name: "description", value: description)]
|
||||
}
|
||||
return nil
|
||||
case let .media(_, json):
|
||||
return json
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct MediaDescriptionData: Encodable, Sendable {
|
||||
public let description: String?
|
||||
|
||||
public init(description: String?) {
|
||||
self.description = description
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -674,7 +674,7 @@ public class StatusEditorViewModel: NSObject, ObservableObject {
|
|||
}
|
||||
do {
|
||||
let newAttachement: MediaAttachment = try await client.get(endpoint: Media.media(id: mediaAttachement.id,
|
||||
description: nil))
|
||||
json: .init(description: nil)))
|
||||
if newAttachement.url != nil {
|
||||
let oldContainer = mediasImages[index]
|
||||
mediasImages[index] = .init(image: oldContainer.image,
|
||||
|
@ -695,7 +695,7 @@ public class StatusEditorViewModel: NSObject, ObservableObject {
|
|||
if let index = indexOf(container: container) {
|
||||
do {
|
||||
let media: MediaAttachment = try await client.put(endpoint: Media.media(id: attachment.id,
|
||||
description: description))
|
||||
json: .init(description: description)))
|
||||
mediasImages[index] = .init(image: nil,
|
||||
movieTransferable: nil,
|
||||
gifTransferable: nil,
|
||||
|
|
Loading…
Reference in a new issue