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

[CP Staging] Revert "Handle API errors to trigger force upgrades of the app " #35046

Merged
merged 1 commit into from
Jan 24, 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
Binary file removed assets/animations/Update.lottie
Binary file not shown.
4 changes: 0 additions & 4 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,6 @@ const CONST = {
EXP_ERROR: 666,
MANY_WRITES_ERROR: 665,
UNABLE_TO_RETRY: 'unableToRetry',
UPDATE_REQUIRED: 426,
},
HTTP_STATUS: {
// When Cloudflare throttles
Expand Down Expand Up @@ -819,9 +818,6 @@ const CONST = {
GATEWAY_TIMEOUT: 'Gateway Timeout',
EXPENSIFY_SERVICE_INTERRUPTED: 'Expensify service interrupted',
DUPLICATE_RECORD: 'A record already exists with this ID',

// The "Upgrade" is intentional as the 426 HTTP code means "Upgrade Required" and sent by the API. We use the "Update" language everywhere else in the front end when this gets returned.
UPDATE_REQUIRED: 'Upgrade Required',
},
ERROR_TYPE: {
SOCKET: 'Expensify\\Auth\\Error\\Socket',
Expand Down
16 changes: 1 addition & 15 deletions src/Expensify.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import AppleAuthWrapper from './components/SignInButtons/AppleAuthWrapper';
import SplashScreenHider from './components/SplashScreenHider';
import UpdateAppModal from './components/UpdateAppModal';
import withLocalize, {withLocalizePropTypes} from './components/withLocalize';
import CONST from './CONST';
import * as EmojiPickerAction from './libs/actions/EmojiPickerAction';
import * as Report from './libs/actions/Report';
import * as User from './libs/actions/User';
Expand Down Expand Up @@ -77,9 +76,6 @@ const propTypes = {
/** Whether the app is waiting for the server's response to determine if a room is public */
isCheckingPublicRoom: PropTypes.bool,

/** True when the user must update to the latest minimum version of the app */
updateRequired: PropTypes.bool,

/** Whether we should display the notification alerting the user that focus mode has been auto-enabled */
focusModeNotification: PropTypes.bool,

Expand All @@ -95,7 +91,6 @@ const defaultProps = {
isSidebarLoaded: false,
screenShareRequest: null,
isCheckingPublicRoom: true,
updateRequired: false,
focusModeNotification: false,
};

Expand Down Expand Up @@ -209,10 +204,6 @@ function Expensify(props) {
return null;
}

if (props.updateRequired) {
throw new Error(CONST.ERROR.UPDATE_REQUIRED);
}

return (
<DeeplinkWrapper
isAuthenticated={isAuthenticated}
Expand All @@ -224,8 +215,7 @@ function Expensify(props) {
<PopoverReportActionContextMenu ref={ReportActionContextMenu.contextMenuRef} />
<EmojiPicker ref={EmojiPickerAction.emojiPickerRef} />
{/* We include the modal for showing a new update at the top level so the option is always present. */}
{/* If the update is required we won't show this option since a full screen update view will be displayed instead. */}
{props.updateAvailable && !props.updateRequired ? <UpdateAppModal /> : null}
{props.updateAvailable ? <UpdateAppModal /> : null}
{props.screenShareRequest ? (
<ConfirmModal
title={props.translate('guides.screenShare')}
Expand Down Expand Up @@ -278,10 +268,6 @@ export default compose(
screenShareRequest: {
key: ONYXKEYS.SCREEN_SHARE_REQUEST,
},
updateRequired: {
key: ONYXKEYS.UPDATE_REQUIRED,
initWithStoredValues: false,
},
focusModeNotification: {
key: ONYXKEYS.FOCUS_MODE_NOTIFICATION,
initWithStoredValues: false,
Expand Down
4 changes: 0 additions & 4 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,6 @@ const ONYXKEYS = {
// Max width supported for HTML <canvas> element
MAX_CANVAS_WIDTH: 'maxCanvasWidth',

/** Indicates whether an forced upgrade is required */
UPDATE_REQUIRED: 'updateRequired',

/** Collection Keys */
COLLECTION: {
DOWNLOAD: 'download_',
Expand Down Expand Up @@ -445,7 +442,6 @@ type OnyxValues = {
[ONYXKEYS.MAX_CANVAS_AREA]: number;
[ONYXKEYS.MAX_CANVAS_HEIGHT]: number;
[ONYXKEYS.MAX_CANVAS_WIDTH]: number;
[ONYXKEYS.UPDATE_REQUIRED]: boolean;

// Collections
[ONYXKEYS.COLLECTION.DOWNLOAD]: OnyxTypes.Download;
Expand Down
14 changes: 4 additions & 10 deletions src/components/ErrorBoundary/BaseErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React, {useState} from 'react';
import React from 'react';
import {ErrorBoundary} from 'react-error-boundary';
import BootSplash from '@libs/BootSplash';
import GenericErrorPage from '@pages/ErrorPage/GenericErrorPage';
import UpdateRequiredView from '@pages/ErrorPage/UpdateRequiredView';
import CONST from '@src/CONST';
import type {BaseErrorBoundaryProps, LogError} from './types';

/**
Expand All @@ -13,19 +11,15 @@ import type {BaseErrorBoundaryProps, LogError} from './types';
*/

function BaseErrorBoundary({logError = () => {}, errorMessage, children}: BaseErrorBoundaryProps) {
const [errorContent, setErrorContent] = useState('');
const catchError = (errorObject: Error, errorInfo: React.ErrorInfo) => {
logError(errorMessage, errorObject, JSON.stringify(errorInfo));
const catchError = (error: Error, errorInfo: React.ErrorInfo) => {
logError(errorMessage, error, JSON.stringify(errorInfo));
// We hide the splash screen since the error might happened during app init
BootSplash.hide();
setErrorContent(errorObject.message);
};

const updateRequired = errorContent === CONST.ERROR.UPDATE_REQUIRED;

return (
<ErrorBoundary
fallback={updateRequired ? <UpdateRequiredView /> : <GenericErrorPage />}
fallback={<GenericErrorPage />}
onError={catchError}
>
{children}
Expand Down
6 changes: 0 additions & 6 deletions src/components/LottieAnimations/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import variables from '@styles/variables';
import type DotLottieAnimation from './types';

const DotLottieAnimations: Record<string, DotLottieAnimation> = {
Expand Down Expand Up @@ -52,11 +51,6 @@ const DotLottieAnimations: Record<string, DotLottieAnimation> = {
w: 853,
h: 480,
},
Update: {
file: require('@assets/animations/Update.lottie'),
w: variables.updateAnimationW,
h: variables.updateAnimationH,
},
Coin: {
file: require('@assets/animations/Coin.lottie'),
w: 375,
Expand Down
6 changes: 0 additions & 6 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ export default {
showing: 'Showing',
of: 'of',
default: 'Default',
update: 'Update',
},
location: {
useCurrent: 'Use current location',
Expand Down Expand Up @@ -773,11 +772,6 @@ export default {
isShownOnProfile: 'Your timezone is shown on your profile.',
getLocationAutomatically: 'Automatically determine your location.',
},
updateRequiredView: {
updateRequired: 'Update required',
pleaseInstall: 'Please update to the latest version of New Expensify',
toGetLatestChanges: 'For mobile or desktop, download and install the latest version. For web, refresh your browser.',
},
initialSettingsPage: {
about: 'About',
aboutPage: {
Expand Down
6 changes: 0 additions & 6 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ export default {
showing: 'Mostrando',
of: 'de',
default: 'Predeterminado',
update: 'Actualizar',
},
location: {
useCurrent: 'Usar ubicación actual',
Expand Down Expand Up @@ -767,11 +766,6 @@ export default {
isShownOnProfile: 'Tu zona horaria se muestra en tu perfil.',
getLocationAutomatically: 'Detecta tu ubicación automáticamente.',
},
updateRequiredView: {
updateRequired: 'Actualización requerida',
pleaseInstall: 'Por favor, actualice la última versión de Nuevo Expensify',
toGetLatestChanges: 'Para móvil o escritorio, descarga e instala la última versión. Para la web, actualiza tu navegador.',
},
initialSettingsPage: {
about: 'Acerca de',
aboutPage: {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Environment/betaChecker/index.android.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Onyx from 'react-native-onyx';
import semver from 'semver';
import * as AppUpdate from '@libs/actions/AppUpdate';
import * as AppUpdate from '@userActions/AppUpdate';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import pkg from '../../../../package.json';
Expand Down
5 changes: 0 additions & 5 deletions src/libs/HttpUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import ONYXKEYS from '@src/ONYXKEYS';
import type {RequestType} from '@src/types/onyx/Request';
import type Response from '@src/types/onyx/Response';
import * as NetworkActions from './actions/Network';
import * as UpdateRequired from './actions/UpdateRequired';
import * as ApiUtils from './ApiUtils';
import HttpsError from './Errors/HttpsError';

Expand Down Expand Up @@ -129,10 +128,6 @@ function processHTTPRequest(url: string, method: RequestType = 'get', body: Form
alert('Too many auth writes', message);
}
}
if (response.jsonCode === CONST.JSON_CODE.UPDATE_REQUIRED) {
// Trigger a modal and disable the app as the user needs to upgrade to the latest minimum version to continue
UpdateRequired.alertUser();
}
return response as Promise<Response>;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import Str from 'expensify-common/lib/str';
import type {ImageSourcePropType} from 'react-native';
import EXPENSIFY_ICON_URL from '@assets/images/expensify-logo-round-clearspace.png';
import * as AppUpdate from '@libs/actions/AppUpdate';
import ModifiedExpenseMessage from '@libs/ModifiedExpenseMessage';
import * as ReportUtils from '@libs/ReportUtils';
import * as AppUpdate from '@userActions/AppUpdate';
import type {Report, ReportAction} from '@src/types/onyx';
import focusApp from './focusApp';
import type {LocalNotificationClickHandler, LocalNotificationData} from './types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Onyx from 'react-native-onyx';
import ONYXKEYS from '@src/ONYXKEYS';
import updateApp from './updateApp';

function triggerUpdateAvailable() {
Onyx.set(ONYXKEYS.UPDATE_AVAILABLE, true);
Expand All @@ -10,4 +9,4 @@ function setIsAppInBeta(isBeta: boolean) {
Onyx.set(ONYXKEYS.IS_BETA, isBeta);
}

export {triggerUpdateAvailable, setIsAppInBeta, updateApp};
export {triggerUpdateAvailable, setIsAppInBeta};
6 changes: 0 additions & 6 deletions src/libs/actions/AppUpdate/updateApp/index.android.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/libs/actions/AppUpdate/updateApp/index.desktop.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/libs/actions/AppUpdate/updateApp/index.ios.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/libs/actions/AppUpdate/updateApp/index.ts

This file was deleted.

22 changes: 0 additions & 22 deletions src/libs/actions/UpdateRequired.ts

This file was deleted.

6 changes: 6 additions & 0 deletions src/libs/migrations/PersonalDetailsByAccountID.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ export default function () {
delete newReport.lastActorEmail;
}

if (lodashHas(newReport, ['participants'])) {
reportWasModified = true;
Log.info(`[Migrate Onyx] PersonalDetailsByAccountID migration: removing participants from report ${newReport.reportID}`);
delete newReport.participants;
}

if (lodashHas(newReport, ['ownerEmail'])) {
reportWasModified = true;
Log.info(`[Migrate Onyx] PersonalDetailsByAccountID migration: removing ownerEmail from report ${newReport.reportID}`);
Expand Down
60 changes: 0 additions & 60 deletions src/pages/ErrorPage/UpdateRequiredView.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4169,19 +4169,6 @@ const styles = (theme: ThemeColors) =>
},

colorSchemeStyle: (colorScheme: ColorScheme) => ({colorScheme}),

updateAnimation: {
width: variables.updateAnimationW,
height: variables.updateAnimationH,
},

updateRequiredViewHeader: {
height: variables.updateViewHeaderHeight,
},

updateRequiredViewTextContainer: {
width: variables.updateTextViewContainerWidth,
},
} satisfies Styles);

type ThemeStyles = ReturnType<typeof styles>;
Expand Down
8 changes: 0 additions & 8 deletions src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1431,14 +1431,6 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({
return containerStyles;
},

getUpdateRequiredViewStyles: (isSmallScreenWidth: boolean): ViewStyle[] => [
{
alignItems: 'center',
justifyContent: 'center',
...(isSmallScreenWidth ? {} : styles.pb40),
},
],

getFullscreenCenteredContentStyles: () => [StyleSheet.absoluteFill, styles.justifyContentCenter, styles.alignItemsCenter],
});

Expand Down
Loading
Loading