Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOTFIX] App crash #2731

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/pages/OldCommon/hooks/useCommonMembers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useCallback, useRef, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { trace } from "firebase/performance";
import { CommonService, Logger, UserService } from "@/services";
import { store } from "@/shared/appConfig";
import { LoadingState } from "@/shared/interfaces";
Expand All @@ -11,7 +10,6 @@ import {
selectUserStates,
} from "@/store/states";
import { useDeepCompareEffect } from "react-use";
import { perf } from "@/shared/utils/firebase";

interface Options {
commonId?: string;
Expand Down Expand Up @@ -113,9 +111,6 @@ export const useCommonMembers = ({ commonId }: Options): Return => {

(async () => {
try {
const useCommonMembersTrace = trace(perf, 'useCommonMembers');
useCommonMembersTrace.start();

const cachedUserStates = selectUserStates()(store.getState());
const hasUsersFromCache = commonMembers.some(
({ userId }) => cachedUserStates[userId]?.data,
Expand Down Expand Up @@ -188,7 +183,6 @@ export const useCommonMembers = ({ commonId }: Options): Return => {
};
});
dispatch(cacheActions.updateUserStates(fetchedUsers));
useCommonMembersTrace.stop();
} catch (err) {
Logger.error(err);
setState((prevState) => ({
Expand Down
13 changes: 2 additions & 11 deletions src/shared/hooks/useCases/useDiscussionMessagesById.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useState, useCallback } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useDeepCompareEffect, useUpdateEffect } from "react-use";
import { trace } from "firebase/performance";
import {
DiscussionMessageService,
MESSAGES_NUMBER_IN_BATCH,
Expand All @@ -21,7 +20,7 @@ import {
User,
} from "@/shared/models";
import { InternalLinkData } from "@/shared/utils";
import firebase, { perf } from "@/shared/utils/firebase";
import firebase from "@/shared/utils/firebase";
import {
cacheActions,
selectDiscussionMessagesStateByDiscussionId,
Expand Down Expand Up @@ -154,10 +153,7 @@ export const useDiscussionMessagesById = ({

const fetchRepliedMessages = useCallback(
async (messageId: string, endDate: Date): Promise<void> => {
const fetchRepliedMessagesTrace = trace(perf, 'fetchRepliedMessagesTrace');
try {
fetchRepliedMessagesTrace.start();

if (state.data?.find((item) => item.id === messageId)) {
return Promise.resolve();
}
Expand Down Expand Up @@ -211,9 +207,8 @@ export const useDiscussionMessagesById = ({
updatedDiscussionMessages: discussionsWithText,
}),
);
fetchRepliedMessagesTrace.stop();
} catch(err) {
fetchRepliedMessagesTrace.stop();
// console.log(err);
}
},
[
Expand Down Expand Up @@ -248,9 +243,6 @@ export const useDiscussionMessagesById = ({
}

try {
const fetchDiscussionMessagesTrace = trace(perf, 'fetchDiscussionMessages');
fetchDiscussionMessagesTrace.start();

DiscussionMessageService.subscribeToDiscussionMessagesByDiscussionId(
discussionId,
lastVisible && lastVisible[discussionId],
Expand Down Expand Up @@ -320,7 +312,6 @@ export const useDiscussionMessagesById = ({
setIsBatchLoading(false);
},
);
fetchDiscussionMessagesTrace.stop();
} catch(err) {
setIsBatchLoading(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const FeedItemBreadcrumbs: FC<FeedItemBreadcrumbsProps> = ({
});

return () => {
unsubscribe();
unsubscribe && unsubscribe();
};
}, [breadcrumbs.activeItem?.id]);

Expand Down
Loading