* Don't add my own handle (#1254) * Remove CoreData-stuff (#1254( * Remove MastodonMentionContainer (#1254) This is a left over from the status-refactoring. The Core Data-persistence-stuff for Status needed that, but as we don't use that any more say byebye
This commit is contained in:
parent
484d72fbdd
commit
13cc2bdbec
|
@ -35,7 +35,7 @@ extension Status.Property {
|
|||
deletedAt: nil,
|
||||
attachments: entity.mastodonAttachments,
|
||||
emojis: entity.mastodonEmojis,
|
||||
mentions: entity.mastodonMentions
|
||||
mentions: []
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
//
|
||||
// MastodonMentionContainer.swift
|
||||
// Mastodon
|
||||
//
|
||||
// Created by MainasuK on 2022-1-17.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreDataStack
|
||||
import MastodonSDK
|
||||
|
||||
public protocol MastodonMentionContainer {
|
||||
var mentions: [Mastodon.Entity.Mention]? { get }
|
||||
}
|
||||
|
||||
extension MastodonMentionContainer {
|
||||
public var mastodonMentions: [MastodonMention] {
|
||||
return mentions.flatMap { mentions in
|
||||
mentions.map { MastodonMention(mention: $0) }
|
||||
} ?? []
|
||||
}
|
||||
}
|
||||
|
||||
extension Mastodon.Entity.Status: MastodonMentionContainer { }
|
|
@ -36,7 +36,7 @@ extension Mastodon.Entity {
|
|||
public let application: Application?
|
||||
|
||||
// Rendering
|
||||
public let mentions: [Mention]?
|
||||
public let mentions: [Mention]
|
||||
public let tags: [Tag]
|
||||
public let emojis: [Emoji]
|
||||
|
||||
|
|
|
@ -193,34 +193,31 @@ public final class ComposeContentViewModel: NSObject, ObservableObject {
|
|||
let initialContentWithSpace = initialContent.isEmpty ? "" : initialContent + " "
|
||||
switch destination {
|
||||
case .reply(let record):
|
||||
context.managedObjectContext.performAndWait {
|
||||
let status = record.entity
|
||||
let author = authContext.mastodonAuthenticationBox.authentication.account()
|
||||
|
||||
var mentionAccts: [String] = []
|
||||
if author?.id != status.account.id {
|
||||
mentionAccts.append("@" + status.account.acct)
|
||||
}
|
||||
let mentions = status.mentions ?? []
|
||||
.filter { author?.id != $0.id }
|
||||
for mention in mentions {
|
||||
let acct = "@" + mention.acct
|
||||
guard !mentionAccts.contains(acct) else { continue }
|
||||
mentionAccts.append(acct)
|
||||
}
|
||||
for acct in mentionAccts {
|
||||
UITextChecker.learnWord(acct)
|
||||
}
|
||||
if let spoilerText = status.spoilerText, !spoilerText.isEmpty {
|
||||
self.isContentWarningActive = true
|
||||
self.contentWarning = spoilerText
|
||||
}
|
||||
|
||||
let initialComposeContent = mentionAccts.joined(separator: " ")
|
||||
let preInsertedContent = initialComposeContent.isEmpty ? "" : initialComposeContent + " "
|
||||
self.initialContent = preInsertedContent + initialContentWithSpace
|
||||
self.content = preInsertedContent + initialContentWithSpace
|
||||
let status = record.entity
|
||||
let author = authContext.mastodonAuthenticationBox.authentication.account()
|
||||
|
||||
var mentionAccts: [String] = []
|
||||
if author?.id != status.account.id {
|
||||
mentionAccts.append("@" + status.account.acct)
|
||||
}
|
||||
let mentions = status.mentions.filter { author?.id != $0.id }
|
||||
for mention in mentions {
|
||||
let acct = "@" + mention.acct
|
||||
guard !mentionAccts.contains(acct) else { continue }
|
||||
mentionAccts.append(acct)
|
||||
}
|
||||
for acct in mentionAccts {
|
||||
UITextChecker.learnWord(acct)
|
||||
}
|
||||
if let spoilerText = status.spoilerText, !spoilerText.isEmpty {
|
||||
self.isContentWarningActive = true
|
||||
self.contentWarning = spoilerText
|
||||
}
|
||||
|
||||
let initialComposeContent = mentionAccts.joined(separator: " ")
|
||||
let preInsertedContent = initialComposeContent.isEmpty ? "" : initialComposeContent + " "
|
||||
self.initialContent = preInsertedContent + initialContentWithSpace
|
||||
self.content = preInsertedContent + initialContentWithSpace
|
||||
case .topLevel:
|
||||
self.initialContent = initialContentWithSpace
|
||||
self.content = initialContentWithSpace
|
||||
|
|
Loading…
Reference in New Issue