mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 03:32:17 +08:00
FEATURE: new jump to channel menu (#22383)
This commit replaces two existing screens: - draft - channel selection modal Main features compared to existing solutions - features are now combined, meaning you can for example create multi users DM - it will show users with chat disabled - it shows unread state - hopefully a better look/feel - lots of small details and fixes... Other noticeable fixes - starting a DM with a user, even from the user card and clicking <kbd>Chat</kbd> will not show a green dot for the target user (or even the channel) until a message is actually sent - it should almost never do a full page reload anymore --------- Co-authored-by: Martin Brennan <mjrbrennan@gmail.com> Co-authored-by: Jordan Vidrine <30537603+jordanvidrine@users.noreply.github.com> Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com> Co-authored-by: Mark VanLandingham <markvanlan@gmail.com>
This commit is contained in:
@ -197,9 +197,7 @@ describe Chat::ChannelFetcher do
|
||||
|
||||
it "does not include DM channels" do
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, following: following).map(
|
||||
&:id
|
||||
),
|
||||
described_class.secured_public_channels(guardian, following: following).map(&:id),
|
||||
).to match_array([category_channel.id])
|
||||
end
|
||||
|
||||
@ -207,7 +205,6 @@ describe Chat::ChannelFetcher do
|
||||
expect(
|
||||
described_class.secured_public_channels(
|
||||
guardian,
|
||||
memberships,
|
||||
following: following,
|
||||
filter: "support",
|
||||
).map(&:id),
|
||||
@ -218,7 +215,6 @@ describe Chat::ChannelFetcher do
|
||||
expect(
|
||||
described_class.secured_public_channels(
|
||||
guardian,
|
||||
memberships,
|
||||
following: following,
|
||||
filter: "cool stuff",
|
||||
).map(&:id),
|
||||
@ -227,33 +223,29 @@ describe Chat::ChannelFetcher do
|
||||
|
||||
it "can filter by an array of slugs" do
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, slugs: ["support"]).map(
|
||||
&:id
|
||||
),
|
||||
described_class.secured_public_channels(guardian, slugs: ["support"]).map(&:id),
|
||||
).to match_array([category_channel.id])
|
||||
end
|
||||
|
||||
it "returns nothing if the array of slugs is empty" do
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, slugs: []).map(&:id),
|
||||
).to eq([])
|
||||
expect(described_class.secured_public_channels(guardian, slugs: []).map(&:id)).to eq([])
|
||||
end
|
||||
|
||||
it "can filter by status" do
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, status: "closed").map(&:id),
|
||||
described_class.secured_public_channels(guardian, status: "closed").map(&:id),
|
||||
).to match_array([])
|
||||
|
||||
category_channel.closed!(Discourse.system_user)
|
||||
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, status: "closed").map(&:id),
|
||||
described_class.secured_public_channels(guardian, status: "closed").map(&:id),
|
||||
).to match_array([category_channel.id])
|
||||
end
|
||||
|
||||
it "can filter by following" do
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, following: true).map(&:id),
|
||||
described_class.secured_public_channels(guardian, following: true).map(&:id),
|
||||
).to be_blank
|
||||
end
|
||||
|
||||
@ -262,21 +254,19 @@ describe Chat::ChannelFetcher do
|
||||
another_channel = Fabricate(:category_channel)
|
||||
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, following: false).map(&:id),
|
||||
described_class.secured_public_channels(guardian, following: false).map(&:id),
|
||||
).to match_array([category_channel.id, another_channel.id])
|
||||
end
|
||||
|
||||
it "ensures offset is >= 0" do
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, offset: -235).map(&:id),
|
||||
described_class.secured_public_channels(guardian, offset: -235).map(&:id),
|
||||
).to match_array([category_channel.id])
|
||||
end
|
||||
|
||||
it "ensures limit is > 0" do
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, limit: -1, offset: 0).map(
|
||||
&:id
|
||||
),
|
||||
described_class.secured_public_channels(guardian, limit: -1, offset: 0).map(&:id),
|
||||
).to match_array([category_channel.id])
|
||||
end
|
||||
|
||||
@ -284,17 +274,15 @@ describe Chat::ChannelFetcher do
|
||||
over_limit = Chat::ChannelFetcher::MAX_PUBLIC_CHANNEL_RESULTS + 1
|
||||
over_limit.times { Fabricate(:category_channel) }
|
||||
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, limit: over_limit).length,
|
||||
).to eq(Chat::ChannelFetcher::MAX_PUBLIC_CHANNEL_RESULTS)
|
||||
expect(described_class.secured_public_channels(guardian, limit: over_limit).length).to eq(
|
||||
Chat::ChannelFetcher::MAX_PUBLIC_CHANNEL_RESULTS,
|
||||
)
|
||||
end
|
||||
|
||||
it "does not show the user category channels they cannot access" do
|
||||
category_channel.update!(chatable: private_category)
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, following: following).map(
|
||||
&:id
|
||||
),
|
||||
described_class.secured_public_channels(guardian, following: following).map(&:id),
|
||||
).to be_empty
|
||||
end
|
||||
|
||||
@ -303,9 +291,7 @@ describe Chat::ChannelFetcher do
|
||||
|
||||
it "only returns channels where the user is a member and is following the channel" do
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, following: following).map(
|
||||
&:id
|
||||
),
|
||||
described_class.secured_public_channels(guardian, following: following).map(&:id),
|
||||
).to be_empty
|
||||
|
||||
Chat::UserChatChannelMembership.create!(
|
||||
@ -315,9 +301,7 @@ describe Chat::ChannelFetcher do
|
||||
)
|
||||
|
||||
expect(
|
||||
described_class.secured_public_channels(guardian, memberships, following: following).map(
|
||||
&:id
|
||||
),
|
||||
described_class.secured_public_channels(guardian, following: following).map(&:id),
|
||||
).to match_array([category_channel.id])
|
||||
end
|
||||
|
||||
@ -369,9 +353,9 @@ describe Chat::ChannelFetcher do
|
||||
direct_message_channel1.update!(last_message_sent_at: 1.day.ago)
|
||||
direct_message_channel2.update!(last_message_sent_at: 1.hour.ago)
|
||||
|
||||
expect(
|
||||
described_class.secured_direct_message_channels(user1.id, memberships, guardian).map(&:id),
|
||||
).to eq([direct_message_channel2.id, direct_message_channel1.id])
|
||||
expect(described_class.secured_direct_message_channels(user1.id, guardian).map(&:id)).to eq(
|
||||
[direct_message_channel2.id, direct_message_channel1.id],
|
||||
)
|
||||
end
|
||||
|
||||
it "does not include direct message channels where the user is a member but not a direct_message_user" do
|
||||
@ -384,7 +368,7 @@ describe Chat::ChannelFetcher do
|
||||
Chat::DirectMessageUser.create!(direct_message: dm_channel1, user: user2)
|
||||
|
||||
expect(
|
||||
described_class.secured_direct_message_channels(user1.id, memberships, guardian).map(&:id),
|
||||
described_class.secured_direct_message_channels(user1.id, guardian).map(&:id),
|
||||
).not_to include(direct_message_channel1.id)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user