Skip to content
Snippets Groups Projects
Commit 14f7fd11 authored by Guilherme Gazzo's avatar Guilherme Gazzo
Browse files

regression: `Sidepanel` sort requires refresh after room update (#33370)

parent 72599700
No related branches found
No related tags found
No related merge requests found
import type { IRoom } from '@rocket.chat/core-typings'; import type { IRoom } from '@rocket.chat/core-typings';
import { useEndpoint } from '@rocket.chat/ui-contexts'; import { useEndpoint } from '@rocket.chat/ui-contexts';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import type { Mongo } from 'meteor/mongo';
import { useEffect, useMemo } from 'react'; import { useEffect, useMemo } from 'react';
import { ChatRoom } from '../../../../../app/models/client'; import { ChatRoom } from '../../../../../app/models/client';
...@@ -12,7 +13,7 @@ const sortRoomByLastMessage = (a: IRoom, b: IRoom) => { ...@@ -12,7 +13,7 @@ const sortRoomByLastMessage = (a: IRoom, b: IRoom) => {
if (!b.lm) { if (!b.lm) {
return -1; return -1;
} }
return new Date(b.lm).toUTCString().localeCompare(new Date(a.lm).toUTCString()); return b.lm.getTime() - a.lm.getTime();
}; };
export const useTeamsListChildrenUpdate = ( export const useTeamsListChildrenUpdate = (
...@@ -23,7 +24,7 @@ export const useTeamsListChildrenUpdate = ( ...@@ -23,7 +24,7 @@ export const useTeamsListChildrenUpdate = (
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const query = useMemo(() => { const query = useMemo(() => {
const query: Parameters<typeof ChatRoom.find>[0] = { const query: Mongo.Selector<IRoom> = {
$or: [ $or: [
{ {
_id: parentRid, _id: parentRid,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment