mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-17 02:05:13 +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 {
|
public enum Media: Endpoint {
|
||||||
case medias
|
case medias
|
||||||
case media(id: String, description: String?)
|
case media(id: String, json: MediaDescriptionData)
|
||||||
|
|
||||||
public func path() -> String {
|
public func path() -> String {
|
||||||
switch self {
|
switch self {
|
||||||
|
@ -14,14 +14,25 @@ public enum Media: Endpoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
public func queryItems() -> [URLQueryItem]? {
|
public func queryItems() -> [URLQueryItem]? {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
public var jsonValue: Encodable? {
|
||||||
switch self {
|
switch self {
|
||||||
case let .media(_, description):
|
case let .media(_, json):
|
||||||
if let description {
|
return json
|
||||||
return [.init(name: "description", value: description)]
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
default:
|
default:
|
||||||
return nil
|
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 {
|
do {
|
||||||
let newAttachement: MediaAttachment = try await client.get(endpoint: Media.media(id: mediaAttachement.id,
|
let newAttachement: MediaAttachment = try await client.get(endpoint: Media.media(id: mediaAttachement.id,
|
||||||
description: nil))
|
json: .init(description: nil)))
|
||||||
if newAttachement.url != nil {
|
if newAttachement.url != nil {
|
||||||
let oldContainer = mediasImages[index]
|
let oldContainer = mediasImages[index]
|
||||||
mediasImages[index] = .init(image: oldContainer.image,
|
mediasImages[index] = .init(image: oldContainer.image,
|
||||||
|
@ -695,7 +695,7 @@ public class StatusEditorViewModel: NSObject, ObservableObject {
|
||||||
if let index = indexOf(container: container) {
|
if let index = indexOf(container: container) {
|
||||||
do {
|
do {
|
||||||
let media: MediaAttachment = try await client.put(endpoint: Media.media(id: attachment.id,
|
let media: MediaAttachment = try await client.put(endpoint: Media.media(id: attachment.id,
|
||||||
description: description))
|
json: .init(description: description)))
|
||||||
mediasImages[index] = .init(image: nil,
|
mediasImages[index] = .init(image: nil,
|
||||||
movieTransferable: nil,
|
movieTransferable: nil,
|
||||||
gifTransferable: nil,
|
gifTransferable: nil,
|
||||||
|
|
Loading…
Reference in a new issue