Chats: use compareId to sort messages (fix Pleroma)

This commit is contained in:
Alex Gleason 2022-08-29 16:21:00 -05:00
parent fc81cda6bb
commit 2f5caad67f
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 2 additions and 5 deletions

View File

@ -2,6 +2,7 @@ import { useInfiniteQuery, useMutation } from '@tanstack/react-query';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import snackbar from 'soapbox/actions/snackbar'; import snackbar from 'soapbox/actions/snackbar';
import compareId from 'soapbox/compare_id';
import { useChatContext } from 'soapbox/contexts/chat-context'; import { useChatContext } from 'soapbox/contexts/chat-context';
import { useApi, useAppDispatch } from 'soapbox/hooks'; import { useApi, useAppDispatch } from 'soapbox/hooks';
@ -37,11 +38,7 @@ export interface IChatMessage {
pending?: boolean pending?: boolean
} }
const reverseOrder = (a: IChat, b: IChat): number => { const reverseOrder = (a: IChat, b: IChat): number => compareId(a.id, b.id);
if (Number(a.id) < Number(b.id)) return -1;
if (Number(a.id) > Number(b.id)) return 1;
return 0;
};
const useChatMessages = (chatId: string) => { const useChatMessages = (chatId: string) => {
const api = useApi(); const api = useApi();