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 mark message from notification #41484

Merged
Merged
Show file tree
Hide file tree
Changes from 11 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: 5 additions & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ const ROUTES = {
REPORT: 'r',
REPORT_WITH_ID: {
route: 'r/:reportID?/:reportActionID?',
getRoute: (reportID: string, reportActionID?: string) => (reportActionID ? (`r/${reportID}/${reportActionID}` as const) : (`r/${reportID}` as const)),
getRoute: (reportID: string, reportActionID?: string, referrer?: string) => {
const baseRoute = reportActionID ? (`r/${reportID}/${reportActionID}` as const) : (`r/${reportID}` as const);
const referrerParam = referrer ? `?referrer=${encodeURIComponent(referrer)}` : '';
return `${baseRoute}${referrerParam}` as const;
},
},
REPORT_AVATAR: {
route: 'r/:reportID/avatar',
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ import type {EmptyObject} from '@src/types/utils/EmptyObject';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import * as CachedPDFPaths from './CachedPDFPaths';
import * as Modal from './Modal';
import navigateFromNotification from './navigateFromNotification';
import * as Session from './Session';
import * as Welcome from './Welcome';

Expand Down Expand Up @@ -2242,7 +2243,7 @@ function showReportActionNotification(reportID: string, reportAction: ReportActi
if (!reportBelongsToWorkspace) {
Navigation.navigateWithSwitchPolicyID({route: ROUTES.HOME});
}
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID));
navigateFromNotification(reportID);
});

if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE) {
Expand Down
8 changes: 8 additions & 0 deletions src/libs/actions/navigateFromNotification/index.desktop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Navigation from '@libs/Navigation/Navigation';
import ROUTES from '@src/ROUTES';

const navigateFromNotification = (reportID: string) => {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID, undefined, 'notification'));
};

export default navigateFromNotification;
8 changes: 8 additions & 0 deletions src/libs/actions/navigateFromNotification/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Navigation from '@libs/Navigation/Navigation';
import ROUTES from '@src/ROUTES';

const navigateFromNotification = (reportID: string) => {
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(reportID));
};

export default navigateFromNotification;
8 changes: 6 additions & 2 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,14 @@ function ReportActionsList({
if (!userActiveSince.current || report.reportID !== prevReportID) {
return;
}

if (ReportUtils.isUnread(report)) {
if (Visibility.isVisible() && scrollingVerticalOffset.current < MSG_VISIBLE_THRESHOLD) {
// On desktop, when the notification center is displayed, Visibility.isVisible() will return false.
// Currently, there's no programmatic way to dismiss the notification center panel.
// To handle this, we use the 'referrer' parameter to check if the current navigation is triggered from a notification. const isFromNotification = (route?.params as {referrer?: string})?.referrer === 'notification';
wildan-m marked this conversation as resolved.
Show resolved Hide resolved
const isFromNotification = (route?.params as {referrer?: string})?.referrer === 'notification';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add referrer in route param type here

[SCREENS.REPORT]: {
reportActionID: string;
reportID: string;
openOnAdminRoom?: boolean;
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont need type assertion anymore can you please remove it

Suggested change
const isFromNotification = (route?.params as {referrer?: string})?.referrer === 'notification';
const isFromNotification = route?.params?.referrer === 'notification';

Also can you please use constant for 'notification'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done.

if ((Visibility.isVisible() || isFromNotification) && scrollingVerticalOffset.current < MSG_VISIBLE_THRESHOLD) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from this issue
In most cases, Visibility.isVisible() returns the value that the app is not visible (inactive). It happens because of the leverage of outdated value.
As result chat is not marked as read (chat is bold) on LHN when opening a new message via notification and navigating to another chat.

So the more preferable value is to use isVisible in this screen

Report.readNewestAction(report.reportID);
Navigation.setParams({referrer: undefined});
Comment on lines +257 to +259
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from #45093 we should only set navigation param referrer to undefined when user is linked through notification

} else {
readActionSkipped.current = true;
}
Expand Down
Loading