Skip to content

Commit

Permalink
stop console spam if no 1st message
Browse files Browse the repository at this point in the history
  • Loading branch information
LoV432 committed Feb 23, 2024
1 parent aacfb81 commit 46b4852
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/components/ChatBubbles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ export function OlderMessagesButton({
chatStoreRef: React.MutableRefObject<dbReturnAllMessages>;
}) {
const activeServer = useAtomValue(activeServerStore);
const [firstMessageId, setFirstMessageId] = useState<
number | { error: boolean }
>({ error: true });
const [firstMessageId, setFirstMessageId] = useState<number | { error: any }>(
{ error: true }
);
const [isLoading, setIsLoading] = useState(false);
const shouldLoadButton = chatStoreRef.current[0]?.id != firstMessageId;
async function updateOlderMessages() {
Expand Down
1 change: 1 addition & 0 deletions app/lib/get-server-messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export async function getFirstMessageId(selectedServerIndex: number) {
const firstMessageId = (await db.query(
`SELECT id FROM server_messages WHERE server_id=${config.servers[selectedServerIndex].chatLoggerId} ORDER BY id ASC LIMIT 1`
)) as RowDataPacket[][];
if (firstMessageId[0].length === 0) return { error: 'No messages' };
return firstMessageId[0][0].id as number;
} catch (err) {
console.log(err);
Expand Down

0 comments on commit 46b4852

Please sign in to comment.