completed migrate to tauri-sql

This commit is contained in:
Ren Amamiya
2023-04-18 19:15:04 +07:00
parent fc1101f97b
commit c72798507e
40 changed files with 321 additions and 476 deletions

View File

@@ -4,6 +4,8 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { getChats } from '@utils/storage';
import useLocalStorage from '@rehooks/local-storage';
import { useRouter } from 'next/navigation';
import { useEffect, useState } from 'react';
@@ -12,7 +14,7 @@ export default function ChatList() {
const router = useRouter();
const [list, setList] = useState([]);
const [activeAccount]: any = useLocalStorage('activeAccount', {});
const [activeAccount]: any = useLocalStorage('account', {});
const profile = activeAccount.metadata ? JSON.parse(activeAccount.metadata) : null;
const openSelfChat = () => {
@@ -20,12 +22,7 @@ export default function ChatList() {
};
useEffect(() => {
const fetchChats = async () => {
const { getChats } = await import('@utils/bindings');
return await getChats({ account_id: activeAccount.id });
};
fetchChats()
getChats(activeAccount.id)
.then((res) => setList(res))
.catch(console.error);
}, [activeAccount.id]);