From f9f12071fd6790fc5d996f25e7a84a4a656a51fd Mon Sep 17 00:00:00 2001 From: c3024 Date: Mon, 25 Nov 2024 19:58:32 +0530 Subject: [PATCH 1/2] do not make requests to backend for anon users --- .../FloatingActionButtonAndPopover.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index b88b9331c061..715203d83972 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -4,7 +4,7 @@ import type {ForwardedRef} from 'react'; import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react'; import {View} from 'react-native'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; -import {useOnyx} from 'react-native-onyx'; +import Onyx, {useOnyx} from 'react-native-onyx'; import type {SvgProps} from 'react-native-svg'; import ConfirmModal from '@components/ConfirmModal'; import FloatingActionButton from '@components/FloatingActionButton'; @@ -36,6 +36,7 @@ import * as App from '@userActions/App'; import * as IOU from '@userActions/IOU'; import * as Link from '@userActions/Link'; import * as Report from '@userActions/Report'; +import * as Session from '@userActions/Session'; import * as Task from '@userActions/Task'; import * as Welcome from '@userActions/Welcome'; import CONST from '@src/CONST'; @@ -560,9 +561,18 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl text: translate('tour.takeATwoMinuteTour'), description: translate('tour.exploreExpensify'), onSelected: () => { - Welcome.setSelfTourViewed(); Link.openExternalLink(navatticURL); - Task.completeTask(viewTourTaskReport); + // Mark the tour as seen only locally for anonymous users visiting public rooms + if (Session.isAnonymousUser()) { + Onyx.merge(ONYXKEYS.NVP_ONBOARDING, { + selfTourViewed: true, + }); + return; + } + Welcome.setSelfTourViewed(); + if (viewTourTaskReport) { + Task.completeTask(viewTourTaskReport); + } }, }, ] From 727b364beff706c2cbbf97194dc868aab4f85436 Mon Sep 17 00:00:00 2001 From: c3024 Date: Mon, 25 Nov 2024 20:21:13 +0530 Subject: [PATCH 2/2] update Onyx data in the function --- src/libs/actions/Welcome/index.ts | 7 ++++++- .../SidebarScreen/FloatingActionButtonAndPopover.tsx | 11 ++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/libs/actions/Welcome/index.ts b/src/libs/actions/Welcome/index.ts index 230b212292e2..607370ae3b5e 100644 --- a/src/libs/actions/Welcome/index.ts +++ b/src/libs/actions/Welcome/index.ts @@ -185,7 +185,12 @@ function resetAllChecks() { OnboardingFlow.clearInitialPath(); } -function setSelfTourViewed() { +function setSelfTourViewed(shouldUpdateOnyxDataOnlyLocally = false) { + if (shouldUpdateOnyxDataOnlyLocally) { + Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {selfTourViewed: true}); + return; + } + const optimisticData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 715203d83972..f0e8d2ba1781 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -4,7 +4,7 @@ import type {ForwardedRef} from 'react'; import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react'; import {View} from 'react-native'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; -import Onyx, {useOnyx} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import type {SvgProps} from 'react-native-svg'; import ConfirmModal from '@components/ConfirmModal'; import FloatingActionButton from '@components/FloatingActionButton'; @@ -562,14 +562,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl description: translate('tour.exploreExpensify'), onSelected: () => { Link.openExternalLink(navatticURL); - // Mark the tour as seen only locally for anonymous users visiting public rooms - if (Session.isAnonymousUser()) { - Onyx.merge(ONYXKEYS.NVP_ONBOARDING, { - selfTourViewed: true, - }); - return; - } - Welcome.setSelfTourViewed(); + Welcome.setSelfTourViewed(Session.isAnonymousUser()); if (viewTourTaskReport) { Task.completeTask(viewTourTaskReport); }