Skip to content

Commit

Permalink
fix: empty data cache invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
aseerkt committed Jun 25, 2024
1 parent 4a82416 commit b1be052
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pnpm --filter server seed
- [x] redis implementation (typing users, online users)
- [x] online status
- [x] realtime member list update
- [ ] infinite scroll pagination (messages/rooms/members)
- [x] infinite scroll pagination (messages/rooms/members)
- [ ] delete room
- [ ] e2e encryption
- [ ] read receipts
Expand Down
4 changes: 3 additions & 1 deletion client/src/features/members/components/MemberItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export const MemberItem = ({ member }: MemberItemProps) => {
<div
className={cn(
'h-3 w-3 rounded-full',
member.online ? 'bg-green-600' : 'bg-gray-400',
member.online
? 'bg-green-600'
: 'border-2 border-gray-400 bg-gray-200',
)}
></div>
<b>{member.user.username}</b>
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/useInfiniteQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const useInfiniteQuery = <TData extends { _id: string }, TError = Error>(
}, [path])

useEffect(() => {
if (!isCached && data?.length) {
if (!isCached && Array.isArray(data)) {
fetchInitialData()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
7 changes: 2 additions & 5 deletions client/src/utils/headers.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { getToken } from './token'

export const getAuthHeaders = () => {
const headers: Record<string, string> = {}
const token = getToken()
if (token) {
headers.Authorization = `Bearer ${token}`
return {
Authorization: token ? `Bearer ${token}` : '',
}

return headers
}

0 comments on commit b1be052

Please sign in to comment.