0
0
Fork 0

Add user notes on accounts (#14148)

* Add UserNote model

* Add UI for user notes

* Put comment in relationships entity

* Add API to create user notes

* Copy user notes to new account when receiving a Move activity

* Address some of the review remarks

* Replace modal by inline edition

* Please CodeClimate

* Button design changes

* Change design again

* Cancel note edition when pressing Escape

* Fixes

* Tweak design again

* Move “Add note” item, and allow users to add notes to themselves

* Rename UserNote into AccountNote, rename “comment” Relationship attribute to “note”
This commit is contained in:
ThibG 2020-06-30 19:19:50 +02:00 committed by GitHub
parent ce9ae9aa50
commit 65506bac3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 485 additions and 4 deletions

View file

@ -3,7 +3,7 @@
class AccountRelationshipsPresenter
attr_reader :following, :followed_by, :blocking, :blocked_by,
:muting, :requested, :domain_blocking,
:endorsed
:endorsed, :account_note
def initialize(account_ids, current_account_id, **options)
@account_ids = account_ids.map { |a| a.is_a?(Account) ? a.id : a.to_i }
@ -17,6 +17,7 @@ class AccountRelationshipsPresenter
@requested = cached[:requested].merge(Account.requested_map(@uncached_account_ids, @current_account_id))
@domain_blocking = cached[:domain_blocking].merge(Account.domain_blocking_map(@uncached_account_ids, @current_account_id))
@endorsed = cached[:endorsed].merge(Account.endorsed_map(@uncached_account_ids, @current_account_id))
@account_note = cached[:account_note].merge(Account.account_note_map(@uncached_account_ids, @current_account_id))
cache_uncached!
@ -28,6 +29,7 @@ class AccountRelationshipsPresenter
@requested.merge!(options[:requested_map] || {})
@domain_blocking.merge!(options[:domain_blocking_map] || {})
@endorsed.merge!(options[:endorsed_map] || {})
@account_note.merge!(options[:account_note_map] || {})
end
private
@ -44,6 +46,7 @@ class AccountRelationshipsPresenter
requested: {},
domain_blocking: {},
endorsed: {},
account_note: {},
}
@uncached_account_ids = []
@ -72,6 +75,7 @@ class AccountRelationshipsPresenter
requested: { account_id => requested[account_id] },
domain_blocking: { account_id => domain_blocking[account_id] },
endorsed: { account_id => endorsed[account_id] },
account_note: { account_id => account_note[account_id] },
}
Rails.cache.write("relationship:#{@current_account_id}:#{account_id}", maps_for_account, expires_in: 1.day)