Bio length -> 1024 characters
Increase the cybre.space profile bio text length limit to 1024 characters. Also modifies the account settings page to automatically resize the textbox to the size of the contained text, so that it's easier to type longer bios.
This commit is contained in:
		
							parent
							
								
									633d175146
								
							
						
					
					
						commit
						9a43dce739
					
				
					 2 changed files with 34 additions and 2 deletions
				
			
		|  | @ -20,6 +20,12 @@ window.addEventListener('message', e => { | |||
|       id: data.id, | ||||
|       height: document.getElementsByTagName('html')[0].scrollHeight, | ||||
|     }, '*'); | ||||
| 
 | ||||
|     if (document.fonts && document.fonts.ready) { | ||||
|       document.fonts.ready.then(sizeBioText); | ||||
|     } else { | ||||
|       sizeBioText(); | ||||
|     } | ||||
|   }); | ||||
| }); | ||||
| 
 | ||||
|  | @ -161,6 +167,12 @@ function main() { | |||
|       const message = (statusEl.dataset.spoiler === 'expanded') ? (messages['status.show_less'] || 'Show less') : (messages['status.show_more'] || 'Show more'); | ||||
|       spoilerLink.textContent = (new IntlMessageFormat(message, locale)).format(); | ||||
|     }); | ||||
| 
 | ||||
|     if (document.fonts && document.fonts.ready) { | ||||
|       document.fonts.ready.then(sizeBioText); | ||||
|     } else { | ||||
|       sizeBioText(); | ||||
|     } | ||||
|   }); | ||||
| 
 | ||||
|   delegate(document, '.webapp-btn', 'click', ({ target, button }) => { | ||||
|  | @ -291,6 +303,22 @@ function main() { | |||
|       } | ||||
|     }); | ||||
|   }); | ||||
| 
 | ||||
|   delegate(document, '#account_note', 'input', sizeBioText); | ||||
| 
 | ||||
|   function s500 izeBioText() { | ||||
|     const noteCounter = document.querySelector('.note-counter'); | ||||
|     const bioTextArea = document.querySelector('#account_note'); | ||||
| 
 | ||||
|     if (noteCounter) { | ||||
|       noteCounter.textContent = 1024 - length(bioTextArea.value); | ||||
|     } | ||||
| 
 | ||||
|     if (bioTextArea) { | ||||
|       bioTextArea.style.height = 'auto'; | ||||
|       bioTextArea.style.height = (bioTextArea.scrollHeight+3) + 'px'; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| loadPolyfills() | ||||
|  |  | |||
|  | @ -88,7 +88,8 @@ class Account < ApplicationRecord | |||
|   validates :username, format: { with: /\A[a-z0-9_]+\z/i }, length: { maximum: 30 }, if: -> { local? && will_save_change_to_username? && actor_type != 'Application' } | ||||
|   validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? } | ||||
|   validates :display_name, length: { maximum: 30 }, if: -> { local? && will_save_change_to_display_name? } | ||||
|   validates :note, note_length: { maximum: 500 }, if: -> { local? && will_save_change_to_note? } | ||||
|   validates :note, note_length: { maximum: 1024 }, if: -> { local? && will_save_change_to_note? } | ||||
|   validate :note_has_ten_newlines?, if: -> { local? && will_save_change_to_note? } | ||||
|   validates :fields, length: { maximum: 4 }, if: -> { local? && will_save_change_to_fields? } | ||||
| 
 | ||||
|   scope :remote, -> { where.not(domain: nil) } | ||||
|  | @ -346,7 +347,6 @@ class Account < ApplicationRecord | |||
|   rescue ActiveRecord::RecordInvalid | ||||
|     self.avatar = nil | ||||
|     self.header = nil | ||||
| 
 | ||||
|     save! | ||||
|   end | ||||
| 
 | ||||
|  | @ -384,6 +384,10 @@ class Account < ApplicationRecord | |||
|     @synchronization_uri_prefix ||= uri[/http(s?):\/\/[^\/]+\//] | ||||
|   end  | ||||
|    | ||||
|   def note_has_ten_newlines? | ||||
|     errors.add(:note, 'Bio can\'t have more then 10 newlines') unless note.count("\n") <= 10 | ||||
|   end | ||||
| 
 | ||||
|   class Field < ActiveModelSerializers::Model | ||||
|     attributes :name, :value, :verified_at, :account, :errors | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue