UX: sort chat channels by activity in desktop drawer (#28822)
This change sorts the desktop chat channels by activity in drawer mode, and keeps sidebar channel list sorted by slug.
This commit is contained in:
parent
f6ba5ed4d9
commit
e9b7663798
|
@ -33,6 +33,12 @@ export default class ChannelsListPublic extends Component {
|
||||||
return this.chatChannelsManager.hasThreadedChannels;
|
return this.chatChannelsManager.hasThreadedChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get channelList() {
|
||||||
|
return this.args.sortByActivity === true
|
||||||
|
? this.chatChannelsManager.publicMessageChannelsByActivity
|
||||||
|
: this.chatChannelsManager.publicMessageChannels;
|
||||||
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
toggleChannelSection(section) {
|
toggleChannelSection(section) {
|
||||||
this.args.toggleSection(section);
|
this.args.toggleSection(section);
|
||||||
|
@ -103,7 +109,7 @@ export default class ChannelsListPublic extends Component {
|
||||||
@showCTA={{this.chatChannelsManager.displayPublicChannels}}
|
@showCTA={{this.chatChannelsManager.displayPublicChannels}}
|
||||||
/>
|
/>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#each this.chatChannelsManager.publicMessageChannels as |channel|}}
|
{{#each this.channelList as |channel|}}
|
||||||
<ChatChannelRow
|
<ChatChannelRow
|
||||||
@channel={{channel}}
|
@channel={{channel}}
|
||||||
@options={{hash settingsButton=true}}
|
@options={{hash settingsButton=true}}
|
||||||
|
|
|
@ -22,7 +22,7 @@ export default class ChatDrawerRoutesChannels extends Component {
|
||||||
|
|
||||||
{{#if this.chatStateManager.isDrawerExpanded}}
|
{{#if this.chatStateManager.isDrawerExpanded}}
|
||||||
<div class="chat-drawer-content">
|
<div class="chat-drawer-content">
|
||||||
<ChannelsListPublic />
|
<ChannelsListPublic @sortByActivity={{true}} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ChatFooter />
|
<ChatFooter />
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default class ChatRoutesChannels extends Component {
|
||||||
</navbar.Actions>
|
</navbar.Actions>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
|
|
||||||
<ChannelsListPublic />
|
<ChannelsListPublic @sortByActivity={{true}} />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,16 +125,16 @@ export default class ChatChannelsManager extends Service {
|
||||||
|
|
||||||
@cached
|
@cached
|
||||||
get publicMessageChannels() {
|
get publicMessageChannels() {
|
||||||
const channels = this.channels.filter(
|
return this.channels
|
||||||
(channel) =>
|
.filter(
|
||||||
channel.isCategoryChannel && channel.currentUserMembership.following
|
(channel) =>
|
||||||
);
|
channel.isCategoryChannel && channel.currentUserMembership.following
|
||||||
|
)
|
||||||
|
.sort((a, b) => a?.slug?.localeCompare?.(b?.slug));
|
||||||
|
}
|
||||||
|
|
||||||
if (this.site.mobileView) {
|
get publicMessageChannelsByActivity() {
|
||||||
return this.#sortChannelsByActivity(channels);
|
return this.#sortChannelsByActivity(this.publicMessageChannels);
|
||||||
} else {
|
|
||||||
return channels.sort((a, b) => a?.slug?.localeCompare?.(b?.slug));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@cached
|
@cached
|
||||||
|
|
|
@ -50,7 +50,19 @@ RSpec.describe "List channels | sidebar", type: :system do
|
||||||
channel_2.add(current_user)
|
channel_2.add(current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sorts them by slug" do
|
it "sorts them by slug when all channels are read" do
|
||||||
|
visit("/")
|
||||||
|
|
||||||
|
expect(page.find("#sidebar-section-content-chat-channels li:nth-child(1)")).to have_css(
|
||||||
|
".channel-#{channel_2.id}",
|
||||||
|
)
|
||||||
|
expect(page.find("#sidebar-section-content-chat-channels li:nth-child(2)")).to have_css(
|
||||||
|
".channel-#{channel_1.id}",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "sorts them by slug when channel has unread messages" do
|
||||||
|
Fabricate(:chat_message, chat_channel: channel_1)
|
||||||
visit("/")
|
visit("/")
|
||||||
|
|
||||||
expect(page.find("#sidebar-section-content-chat-channels li:nth-child(1)")).to have_css(
|
expect(page.find("#sidebar-section-content-chat-channels li:nth-child(1)")).to have_css(
|
||||||
|
|
Loading…
Reference in New Issue