mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-09-05 17:27:38 +00:00
Always embed status true URL
This commit is contained in:
parent
d61ce04dac
commit
7bb7bb5cb7
1 changed files with 6 additions and 11 deletions
|
@ -44,6 +44,10 @@ public class StatusEditorViewModel: ObservableObject {
|
||||||
|
|
||||||
@Published var visibility: Models.Visibility = .pub
|
@Published var visibility: Models.Visibility = .pub
|
||||||
|
|
||||||
|
private var embededStatusURL: URL? {
|
||||||
|
return embededStatus?.reblog?.url ?? embededStatus?.url
|
||||||
|
}
|
||||||
|
|
||||||
private var uploadTask: Task<Void, Never>?
|
private var uploadTask: Task<Void, Never>?
|
||||||
|
|
||||||
init(mode: Mode) {
|
init(mode: Mode) {
|
||||||
|
@ -86,14 +90,6 @@ public class StatusEditorViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func localURLforStatus(status: Status) -> URL? {
|
|
||||||
guard let server = client?.server else { return nil }
|
|
||||||
if status.url?.host == server.lowercased() {
|
|
||||||
return status.url
|
|
||||||
}
|
|
||||||
return URL(string: "https://\(server.lowercased())/@\(status.account.acct)/\(status.id)")
|
|
||||||
}
|
|
||||||
|
|
||||||
func prepareStatusText() {
|
func prepareStatusText() {
|
||||||
switch mode {
|
switch mode {
|
||||||
case let .replyTo(status):
|
case let .replyTo(status):
|
||||||
|
@ -107,7 +103,7 @@ public class StatusEditorViewModel: ObservableObject {
|
||||||
mediasImages = status.mediaAttachments.map{ .init(image: nil, mediaAttachement: $0, error: nil )}
|
mediasImages = status.mediaAttachments.map{ .init(image: nil, mediaAttachement: $0, error: nil )}
|
||||||
case let .quote(status):
|
case let .quote(status):
|
||||||
self.embededStatus = status
|
self.embededStatus = status
|
||||||
if let url = localURLforStatus(status: status) {
|
if let url = embededStatusURL {
|
||||||
statusText = .init(string: "\n\nFrom: @\(status.reblog?.account.acct ?? status.account.acct)\n\(url)")
|
statusText = .init(string: "\n\nFrom: @\(status.reblog?.account.acct ?? status.account.acct)\n\(url)")
|
||||||
selectedRange = .init(location: 0, length: 0)
|
selectedRange = .init(location: 0, length: 0)
|
||||||
}
|
}
|
||||||
|
@ -156,8 +152,7 @@ public class StatusEditorViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func checkEmbed() {
|
private func checkEmbed() {
|
||||||
if let embededStatus,
|
if let url = embededStatusURL,
|
||||||
let url = localURLforStatus(status: embededStatus),
|
|
||||||
!statusText.string.contains(url.absoluteString) {
|
!statusText.string.contains(url.absoluteString) {
|
||||||
self.embededStatus = nil
|
self.embededStatus = nil
|
||||||
self.mode = .new
|
self.mode = .new
|
||||||
|
|
Loading…
Reference in a new issue