Fix recent sorting difference with webapp (#7632)

This commit is contained in:
Daniel Espino García 2023-10-26 15:15:54 +02:00 committed by GitHub
parent 196372eeb4
commit 01fdd1f7d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -180,7 +180,9 @@ const sortChannelsByName = (notifyPropsPerChannel: Record<string, Partial<Channe
export const sortChannels = (sorting: CategorySorting, channelsWithMyChannel: ChannelWithMyChannel[], notifyPropsPerChannel: Record<string, Partial<ChannelNotifyProps>>, locale: string) => {
if (sorting === 'recent') {
return channelsWithMyChannel.sort((cwmA, cwmB) => {
return cwmB.myChannel.lastPostAt - cwmA.myChannel.lastPostAt;
const a = Math.max(cwmA.myChannel.lastPostAt, cwmA.channel.createAt);
const b = Math.max(cwmB.myChannel.lastPostAt, cwmB.channel.createAt);
return b - a;
}).map((cwm) => cwm.channel);
} else if (sorting === 'manual') {
return channelsWithMyChannel.sort((cwmA, cwmB) => {