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 (
@@ -36,7 +39,8 @@ class GroupSidebarPanel extends ImmutablePureComponent {
- {groupIds.map(groupId => )} + {groupIds.slice(0, 10).map(groupId => )} + {count > 10 && {intl.formatMessage(messages.show_all)}}
diff --git a/app/javascript/gabsocial/pages/groups_page.js b/app/javascript/gabsocial/pages/groups_page.js index 2cbaa481..141a530f 100644 --- a/app/javascript/gabsocial/pages/groups_page.js +++ b/app/javascript/gabsocial/pages/groups_page.js @@ -7,7 +7,6 @@ import WhoToFollowPanel from '../features/ui/components/who_to_follow_panel'; import LinkFooter from '../features/ui/components/link_footer'; import PromoPanel from '../features/ui/components/promo_panel'; import UserPanel from '../features/ui/components/user_panel'; -import GroupSidebarPanel from '../features/groups/sidebar_panel'; const mapStateToProps = state => ({ account: state.getIn(['accounts', me]), @@ -43,7 +42,6 @@ class GroupsPage extends ImmutablePureComponent {
-
diff --git a/app/javascript/styles/gabsocial/components/group-sidebar-panel.scss b/app/javascript/styles/gabsocial/components/group-sidebar-panel.scss index a812ac12..9b750f2e 100644 --- a/app/javascript/styles/gabsocial/components/group-sidebar-panel.scss +++ b/app/javascript/styles/gabsocial/components/group-sidebar-panel.scss @@ -1,6 +1,10 @@ .group-sidebar-panel { &__items { padding: 0 15px 15px; + + &__show-all { + color: $primary-text-color; + } } &__item {