Added unique photos and videos tab to profile

• Added:
- unique photos and videos tab to profile
- mediaType/media_type query string in api/statuses_controller

• Updated:
- /media to redirect to /photos
- AccountGallery, selector to accept mediaType and update on change in componentWillReceiveProps

• Removed:
- Generic "media" tab

• Todo:
- Create index for MediaAttachment.type
This commit is contained in:
mgabdev
2020-06-08 19:38:36 -04:00
parent 1f78bc6879
commit a5e99dd7c3
6 changed files with 70 additions and 25 deletions

View File

@@ -52,11 +52,21 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
# Also, Avoid getting slow by not narrowing down by `statuses.account_id`.
# When narrowing down by `statuses.account_id`, `index_statuses_20180106` will be used
# and the table will be joined by `Merge Semi Join`, so the query will be slow.
@account.statuses.joins(:media_attachments).merge(@account.media_attachments).permitted_for(@account, current_account)
@account.statuses.joins(:media_attachments)
.merge(account_media_ids_query)
.permitted_for(@account, current_account)
.paginate_by_max_id(limit_param(DEFAULT_STATUSES_LIMIT), params[:max_id], params[:since_id])
.reorder(id: :desc).distinct(:id).pluck(:id)
end
def account_media_ids_query
if params[:media_type] == 'video'
@account.media_attachments.where(type: 2)
else
@account.media_attachments.where.not(type: 2)
end
end
def pinned_scope
@account.pinned_statuses
end