feat: restore post compose limit

This commit is contained in:
CMK 2022-11-14 19:14:46 +08:00
parent 4d03e114ca
commit 25f4a6b082
1 changed files with 26 additions and 0 deletions

View File

@ -229,6 +229,32 @@ public final class ComposeContentViewModel: NSObject, ObservableObject {
break
}
// set limit
let _configuration: Mastodon.Entity.Instance.Configuration? = {
var configuration: Mastodon.Entity.Instance.Configuration? = nil
context.managedObjectContext.performAndWait {
guard let authentication = authContext.mastodonAuthenticationBox.authenticationRecord.object(in: context.managedObjectContext)
else { return }
configuration = authentication.instance?.configuration
}
return configuration
}()
if let configuration = _configuration {
// set character limit
if let maxCharacters = configuration.statuses?.maxCharacters {
maxTextInputLimit = maxCharacters
}
// set media limit
if let maxMediaAttachments = configuration.statuses?.maxMediaAttachments {
maxMediaAttachmentLimit = maxMediaAttachments
}
// set poll option limit
if let maxOptions = configuration.polls?.maxOptions {
maxPollOptionLimit = maxOptions
}
// TODO: more limit
}
bind()
}