Retain 640 character limit
This commit is contained in:
parent
9bcb7630b3
commit
d2ba53bc3f
3 changed files with 10 additions and 6 deletions
|
@ -100,7 +100,7 @@ class ComposeForm extends ImmutablePureComponent {
|
||||||
const fulltext = this.getFulltextForCharacterCounting();
|
const fulltext = this.getFulltextForCharacterCounting();
|
||||||
const isOnlyWhitespace = fulltext.length !== 0 && fulltext.trim().length === 0;
|
const isOnlyWhitespace = fulltext.length !== 0 && fulltext.trim().length === 0;
|
||||||
|
|
||||||
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 500 || (isOnlyWhitespace && !anyMedia));
|
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 640 || (isOnlyWhitespace && !anyMedia));
|
||||||
};
|
};
|
||||||
|
|
||||||
handleSubmit = (e) => {
|
handleSubmit = (e) => {
|
||||||
|
@ -297,7 +297,7 @@ class ComposeForm extends ImmutablePureComponent {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='character-counter__wrapper'>
|
<div className='character-counter__wrapper'>
|
||||||
<CharacterCounter max={500} text={this.getFulltextForCharacterCounting()} />
|
<CharacterCounter max={640} text={this.getFulltextForCharacterCounting()} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,7 +11,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
attributes :domain, :title, :version, :source_url, :description,
|
attributes :domain, :title, :version, :source_url, :description,
|
||||||
:usage, :thumbnail, :languages, :configuration,
|
:usage, :thumbnail, :languages, :configuration,
|
||||||
:registrations
|
:registrations, :max_post_chars
|
||||||
|
|
||||||
has_one :contact, serializer: ContactSerializer
|
has_one :contact, serializer: ContactSerializer
|
||||||
has_many :rules, serializer: REST::RuleSerializer
|
has_many :rules, serializer: REST::RuleSerializer
|
||||||
|
@ -89,6 +89,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def max_post_chars
|
||||||
|
640
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def registrations_enabled?
|
def registrations_enabled?
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe NoteLengthValidator do
|
describe NoteLengthValidator do
|
||||||
subject { described_class.new(attributes: { note: true }, maximum: 500) }
|
subject { described_class.new(attributes: { note: true }, maximum: 640) }
|
||||||
|
|
||||||
describe '#validate' do
|
describe '#validate' do
|
||||||
it 'adds an error when text is over 500 characters' do
|
it 'adds an error when text is over 640 characters' do
|
||||||
text = 'a' * 520
|
text = 'a' * 650
|
||||||
account = instance_double(Account, note: text, errors: activemodel_errors)
|
account = instance_double(Account, note: text, errors: activemodel_errors)
|
||||||
|
|
||||||
subject.validate_each(account, 'note', text)
|
subject.validate_each(account, 'note', text)
|
||||||
|
|
Loading…
Reference in a new issue