- ์์กด ํจํค์ง๋ฅผ ์ค์นํฉ๋๋ค.
npm install
- ํ์ด์ด ๋ฒ ์ด์ค ์ฌ์ฉ์ ์ํด์ renderer ํด๋ ํ์์ .env ํ์ผ์ ์์ฑํ๊ณ ๋ค์๊ณผ ๊ฐ์ ๋ด์ฉ์ ์ถ๊ฐํฉ๋๋ค.
NEXT_PUBLIC_API=
NEXT_PUBLIC_FIRE_DOMAIN=
NEXT_PUBLIC_FIRE_DATABASE=
NEXT_PUBLIC_FIRE_PROJECT_ID=
- ์๋ฒ๋ฅผ ์คํํฉ๋๋ค.
npm run dev
etc. chatty APP์์ ์ด์ฉํ ์ ์๋ ํ ์คํธ ๊ณ์ ์ ๋ณด์ ๋๋ค.
[email protected] / password=1234567
[email protected] / password=1234567
[email protected] / password=1234567
React, TypeScript, Next.js, Electron, firebase, react-query, ant-design
- ํ์๊ฐ์
- ๋ก๊ทธ์ธ
- ์ ์ ๋ชฉ๋ก
- 1:1 ์ฑํ
- ๊ทธ๋ฃน์ฑํ
nextron-chatty/renderer/src/apis/firebase.tsx
Lines 24 to 52 in 9e0d467
- ํ์ ๊ฐ์
์,
updateProfile
ํจ์๋ฅผ ์ฒด์ด๋ ํด firebase user ์ ๋ณด์ ๋ด๊ฐ ๊ธฐ์ ํ ๋ณ๋ช ์displayName
์ผ๋ก ์ ์ฅ - ์๋ฌ ๋ฐ์ ์,
throw new Error
๋ก ์๋ฌ๋ฅผ ๋๊ฒจ ๋ก๊ทธ์ธ ํ์ด์ง์์ ์ฒ๋ฆฌ
nextron-chatty/renderer/src/apis/firebase.tsx
Lines 59 to 70 in 9e0d467
nextron-chatty/renderer/src/context/AuthContext.tsx
Lines 11 to 32 in 9e0d467
- ๋ก๊ทธ์ธ ์ firebase์
onAuthStateChanged
ํจ์๋ฅผ ์ด์ฉํด current user ์ ๋ณด๋ฅผ ๋ฐ์์ค๋๋ก ๊ตฌํ - ์๋ฌ๋ฅผ ๋๋นํ์ฌ ์ ์ ์ ๋ณด๋ฅผ localStorage์ ์ด์ค์ผ๋ก ์ ์ฅ
- context api๋ฅผ ์ด์ฉํด ์ ์ ์ ๋ณด๋ฅผ ์ ์ญ์ผ๋ก ๊ด๋ฆฌ
nextron-chatty/renderer/pages/chat/[roomId].tsx
Lines 17 to 20 in 9e0d467
nextron-chatty/renderer/src/hooks/useChat.tsx
Lines 11 to 32 in 9e0d467
- react query์
refetchInterval์ 1000
์ผ๋ก ์ค์ ํ์ฌ ์๋ฒpolling
์ ๊ตฌํ - ๊ฐ์ query key๋ฅผ ์ฐ๋ ํจ์๋ผ๋ฆฌ custom hook์ผ๋ก ๋ฌถ์ด ๊ด๋ฆฌ ์ฉ์ด์ฑ ์ฆ๋
- ๋ฉ์ธ์ง๋ฅผ ๋ณด๋ผ ์์๋ useMutation์ ์ด์ฉํด
์ฑํ ๋ฐฉ ๋ฐ์ดํฐ ๋๊ธฐํ
๋ฅผ ๊ตฌํ
nextron-chatty/renderer/src/hooks/useMsg.tsx
Lines 3 to 20 in 9e0d467
nextron-chatty/renderer/src/hooks/useScroll.tsx
Lines 3 to 11 in 9e0d467
- 1:1 ์ฑํ ๋ฐฉ๊ณผ ๊ทธ๋ฃน ์ฑํ ๋ฐฉ์์ ๋์ผํ๊ฒ ์ฐ์ด๋ input event์ scroll ์ด๋ฒคํธ๋ฅผ custom hook์ผ๋ก ๊ด๋ฆฌ
nextron-chatty/renderer/pages/chat/[roomId].tsx
Lines 22 to 27 in 9e0d467
nextron-chatty/renderer/pages/group/[idx].tsx
Lines 22 to 27 in fd23871
- useMutation ํจ์๋ฅผ callback์ผ๋ก ๋๊ธฐ๊ณ obj๋ฅผ Value ๊ฐ์ผ๋ก ๋๊ฒจ ์ด์ฉ