feat: have messages array always reverse
This commit is contained in:
parent
1d0fde3e36
commit
c10e083771
1 changed files with 2 additions and 4 deletions
|
@ -19,20 +19,18 @@
|
|||
import type { MessageResponse } from '~/types/interfaces';
|
||||
import scrollToBottom from '~/utils/scrollToBottom';
|
||||
|
||||
const props = defineProps<{ channelUrl: string, amount?: number, offset?: number, reverse?: boolean }>();
|
||||
const props = defineProps<{ channelUrl: string, amount?: number, offset?: number }>();
|
||||
|
||||
const messagesRes: MessageResponse[] | undefined = await fetchWithApi(
|
||||
`${props.channelUrl}/messages`,
|
||||
{ query: { "amount": props.amount ?? 100, "offset": props.offset ?? 0 } }
|
||||
);
|
||||
if (messagesRes && props.reverse) {
|
||||
if (messagesRes) {
|
||||
messagesRes.reverse();
|
||||
}
|
||||
|
||||
const messages = ref<MessageResponse[]>([]);
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
const messageInput = ref<string>();
|
||||
|
||||
const messagesElement = ref<HTMLDivElement>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue