mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-23 15:40:37 +00:00
Mention everyone in reply
This commit is contained in:
parent
2bb68c915d
commit
639227be89
2 changed files with 11 additions and 2 deletions
|
@ -48,6 +48,7 @@ public struct StatusEditorView: View {
|
|||
}
|
||||
.onAppear {
|
||||
viewModel.client = client
|
||||
viewModel.currentAccount = currentAccount.account
|
||||
viewModel.prepareStatusText()
|
||||
if !client.isAuth {
|
||||
dismiss()
|
||||
|
|
|
@ -17,6 +17,7 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
let generator = UINotificationFeedbackGenerator()
|
||||
|
||||
var client: Client?
|
||||
var currentAccount: Account?
|
||||
|
||||
@Published var statusText = NSMutableAttributedString(string: "") {
|
||||
didSet {
|
||||
|
@ -40,6 +41,7 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
}
|
||||
}
|
||||
@Published var mediasImages: [ImageContainer] = []
|
||||
@Published var replyToStatus: Status?
|
||||
@Published var embededStatus: Status?
|
||||
|
||||
@Published var visibility: Models.Visibility = .pub
|
||||
|
@ -93,8 +95,14 @@ public class StatusEditorViewModel: ObservableObject {
|
|||
func prepareStatusText() {
|
||||
switch mode {
|
||||
case let .replyTo(status):
|
||||
statusText = .init(string: "@\(status.reblog?.account.acct ?? status.account.acct) ")
|
||||
selectedRange = .init(location: statusText.string.utf16.count, length: 0)
|
||||
var mentionString = "@\(status.reblog?.account.acct ?? status.account.acct)"
|
||||
for mention in status.mentions where mention.acct != currentAccount?.acct {
|
||||
mentionString += " @\(mention.acct)"
|
||||
}
|
||||
mentionString += " "
|
||||
replyToStatus = status
|
||||
statusText = .init(string: mentionString)
|
||||
selectedRange = .init(location: mentionString.utf16.count, length: 0)
|
||||
case let .edit(status):
|
||||
statusText = .init(status.content.asSafeAttributedString)
|
||||
selectedRange = .init(location: statusText.string.utf16.count, length: 0)
|
||||
|
|
Loading…
Reference in a new issue