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

Fix cross platform concern of the improve flagging feature #37754

Merged
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
24 changes: 2 additions & 22 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ import DateUtils from '@libs/DateUtils';
import * as EmojiUtils from '@libs/EmojiUtils';
import * as Environment from '@libs/Environment/Environment';
import * as ErrorUtils from '@libs/ErrorUtils';
import getPlatform from '@libs/getPlatform';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import LocalNotification from '@libs/Notification/LocalNotification';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import * as PhoneNumber from '@libs/PhoneNumber';
import getPolicyMemberAccountIDs from '@libs/PolicyMembersUtils';
import {extractPolicyIDFromPath} from '@libs/PolicyUtils';
import processReportIDDeeplink from '@libs/processReportIDDeeplink';
import * as Pusher from '@libs/Pusher/pusher';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
Expand Down Expand Up @@ -178,27 +178,7 @@ const typingWatchTimers: Record<string, NodeJS.Timeout> = {};

let reportIDDeeplinkedFromOldDot: string | undefined;
Linking.getInitialURL().then((url) => {
const isWeb = ([CONST.PLATFORM.WEB] as unknown as string).includes(getPlatform());
const currentParams = new URLSearchParams(url ?? '');
const currentExitToRoute = currentParams.get('exitTo') ?? '';
const {reportID: currentReportID} = ReportUtils.parseReportRouteParams(currentExitToRoute);

if (!isWeb) {
reportIDDeeplinkedFromOldDot = currentReportID;

return;
}

const prevUrl = sessionStorage.getItem(CONST.SESSION_STORAGE_KEYS.INITIAL_URL);
const prevParams = new URLSearchParams(prevUrl ?? '');
const prevExitToRoute = prevParams.get('exitTo') ?? '';
const {reportID: prevReportID} = ReportUtils.parseReportRouteParams(prevExitToRoute);

reportIDDeeplinkedFromOldDot = currentReportID || prevReportID;

if (currentReportID && url) {
sessionStorage.setItem(CONST.SESSION_STORAGE_KEYS.INITIAL_URL, url);
}
reportIDDeeplinkedFromOldDot = processReportIDDeeplink(url ?? '');
});

let lastVisitedPath: string | undefined;
Expand Down
9 changes: 9 additions & 0 deletions src/libs/processReportIDDeeplink/getReportIDFromUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as ReportUtils from '@libs/ReportUtils';

export default function getReportIDFromUrl(url: string): string {
const currentParams = new URLSearchParams(url);
const currentExitToRoute = currentParams.get('exitTo') ?? '';
const {reportID} = ReportUtils.parseReportRouteParams(currentExitToRoute);

return reportID;
}
5 changes: 5 additions & 0 deletions src/libs/processReportIDDeeplink/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import getReportIDFromUrl from './getReportIDFromUrl';

export default function processReportIDDeeplink(url: string): string {
return getReportIDFromUrl(url);
}
14 changes: 14 additions & 0 deletions src/libs/processReportIDDeeplink/index.website.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import CONST from '@src/CONST';
import getReportIDFromUrl from './getReportIDFromUrl';

export default function processReportIDDeeplink(url: string): string {
const prevUrl = sessionStorage.getItem(CONST.SESSION_STORAGE_KEYS.INITIAL_URL);
const prevReportID = getReportIDFromUrl(prevUrl ?? '');
const currentReportID = getReportIDFromUrl(url);

if (currentReportID && url) {
sessionStorage.setItem(CONST.SESSION_STORAGE_KEYS.INITIAL_URL, url);
}

return currentReportID || prevReportID;
}
Loading