mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-23 07:36:48 +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
|
||||
|
||||
private var embededStatusURL: URL? {
|
||||
return embededStatus?.reblog?.url ?? embededStatus?.url
|
||||
}
|
||||
|
||||
private var uploadTask: Task<Void, Never>?
|
||||
|
||||
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() {
|
||||
switch mode {
|
||||
case let .replyTo(status):
|
||||
|
@ -107,7 +103,7 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
mediasImages = status.mediaAttachments.map{ .init(image: nil, mediaAttachement: $0, error: nil )}
|
||||
case let .quote(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)")
|
||||
selectedRange = .init(location: 0, length: 0)
|
||||
}
|
||||
|
@ -156,8 +152,7 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
}
|
||||
|
||||
private func checkEmbed() {
|
||||
if let embededStatus,
|
||||
let url = localURLforStatus(status: embededStatus),
|
||||
if let url = embededStatusURL,
|
||||
!statusText.string.contains(url.absoluteString) {
|
||||
self.embededStatus = nil
|
||||
self.mode = .new
|
||||
|
|
Loading…
Reference in a new issue