Skip to content

Commit

Permalink
Merge pull request #90 from skiff-org/fix-network-error
Browse files Browse the repository at this point in the history
Fix network error on inbox page from drafts request
  • Loading branch information
amilich authored Jul 31, 2023
2 parents 4e1e2bc + 71b5083 commit 1c8d57a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 2 additions & 5 deletions skiff-mail-web/__mocks__/mockApiResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,9 @@ export const MOCK_MAILBOX_REQUEST = {

export const MOCK_NUM_UNREAD = 0;

export const MOCK_DRAFTS = [];

export const getMockedThread = (threadID: string | null) => {
console.log({
threadID,
thread1ID: MOCK_THREAD_1.data.userThread.threadID,
thread2ID: MOCK_THREAD_2.data.userThread.threadID
});
if (threadID === MOCK_THREAD_1.data.userThread.threadID) {
return MOCK_THREAD_1;
}
Expand Down
5 changes: 3 additions & 2 deletions skiff-mail-web/hooks/useFetchCurrentUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { getUserDrafts } from '../utils/draftUtils';
import { useNavigate } from '../utils/navigation';

import { tryCachedLogin } from './useCachedLogin';
import { MOCK_DRAFTS } from '__mocks__/mockApiResponse';

const useFetchCurrentUser = () => {
const { data, loading: queryLoading, error } = useCurrentUserQuery();
Expand Down Expand Up @@ -72,8 +73,8 @@ const useFetchCurrentUser = () => {
useEffect(() => {
const getDrafts = async () => {
if (user) {
// Fetch drafts from IDB
const drafts = await getUserDrafts(user);
// Fetch mock drafts from IDB
const drafts = MOCK_DRAFTS;
dispatch(skemailDraftsReducer.actions.setDrafts({ drafts }));
}
};
Expand Down

0 comments on commit 1c8d57a

Please sign in to comment.