mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-11 08:35:26 +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 {
|
.onAppear {
|
||||||
viewModel.client = client
|
viewModel.client = client
|
||||||
|
viewModel.currentAccount = currentAccount.account
|
||||||
viewModel.prepareStatusText()
|
viewModel.prepareStatusText()
|
||||||
if !client.isAuth {
|
if !client.isAuth {
|
||||||
dismiss()
|
dismiss()
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class StatusEditorViewModel: ObservableObject {
|
||||||
let generator = UINotificationFeedbackGenerator()
|
let generator = UINotificationFeedbackGenerator()
|
||||||
|
|
||||||
var client: Client?
|
var client: Client?
|
||||||
|
var currentAccount: Account?
|
||||||
|
|
||||||
@Published var statusText = NSMutableAttributedString(string: "") {
|
@Published var statusText = NSMutableAttributedString(string: "") {
|
||||||
didSet {
|
didSet {
|
||||||
|
@ -40,6 +41,7 @@ public class StatusEditorViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Published var mediasImages: [ImageContainer] = []
|
@Published var mediasImages: [ImageContainer] = []
|
||||||
|
@Published var replyToStatus: Status?
|
||||||
@Published var embededStatus: Status?
|
@Published var embededStatus: Status?
|
||||||
|
|
||||||
@Published var visibility: Models.Visibility = .pub
|
@Published var visibility: Models.Visibility = .pub
|
||||||
|
@ -93,8 +95,14 @@ public class StatusEditorViewModel: ObservableObject {
|
||||||
func prepareStatusText() {
|
func prepareStatusText() {
|
||||||
switch mode {
|
switch mode {
|
||||||
case let .replyTo(status):
|
case let .replyTo(status):
|
||||||
statusText = .init(string: "@\(status.reblog?.account.acct ?? status.account.acct) ")
|
var mentionString = "@\(status.reblog?.account.acct ?? status.account.acct)"
|
||||||
selectedRange = .init(location: statusText.string.utf16.count, length: 0)
|
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):
|
case let .edit(status):
|
||||||
statusText = .init(status.content.asSafeAttributedString)
|
statusText = .init(status.content.asSafeAttributedString)
|
||||||
selectedRange = .init(location: statusText.string.utf16.count, length: 0)
|
selectedRange = .init(location: statusText.string.utf16.count, length: 0)
|
||||||
|
|
Loading…
Reference in a new issue