From 06e1c47ff47bd2a520087ece489f5a7f9248c36f Mon Sep 17 00:00:00 2001 From: 2458773093 <2458773093@protonmail.com> Date: Sat, 20 Jul 2019 02:45:14 +0300 Subject: [PATCH] group sidebar panel improvements --- app/controllers/api/v1/groups_controller.rb | 2 +- .../gabsocial/features/groups/sidebar_panel/index.js | 8 ++++++-- app/javascript/gabsocial/pages/groups_page.js | 2 -- .../styles/gabsocial/components/group-sidebar-panel.scss | 4 ++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/v1/groups_controller.rb b/app/controllers/api/v1/groups_controller.rb index 8231ef00..837540f6 100644 --- a/app/controllers/api/v1/groups_controller.rb +++ b/app/controllers/api/v1/groups_controller.rb @@ -14,7 +14,7 @@ class Api::V1::GroupsController < Api::BaseController when 'featured' @groups = Group.where(is_featured: true).limit(25).all when 'member' - @groups = Group.joins(:group_accounts).where(is_archived: false, group_accounts: { account: current_account }).all + @groups = Group.joins(:group_accounts).where(is_archived: false, group_accounts: { account: current_account }).order('group_accounts.unread_count DESC, group_accounts.id DESC').all when 'admin' @groups = Group.joins(:group_accounts).where(is_archived: false, group_accounts: { account: current_account, role: :admin }).all end diff --git a/app/javascript/gabsocial/features/groups/sidebar_panel/index.js b/app/javascript/gabsocial/features/groups/sidebar_panel/index.js index 21880178..88e74928 100644 --- a/app/javascript/gabsocial/features/groups/sidebar_panel/index.js +++ b/app/javascript/gabsocial/features/groups/sidebar_panel/index.js @@ -5,9 +5,11 @@ import { defineMessages, injectIntl } from 'react-intl'; import { connect } from 'react-redux'; import Item from './item'; import Icon from 'gabsocial/components/icon'; +import { Link } from 'react-router-dom'; const messages = defineMessages({ title: { id: 'groups.sidebar-panel.title', defaultMessage: 'Groups you\'re in' }, + show_all: { id: 'groups.sidebar-panel.show_all', defaultMessage: 'Show all' }, }); const mapStateToProps = (state, { id }) => ({ @@ -23,9 +25,10 @@ class GroupSidebarPanel extends ImmutablePureComponent { render() { const { intl, groupIds } = this.props; + const count = groupIds.count(); // Only when there are groups to show - if (groupIds.count() === 0) return null; + if (count === 0) return null; return (