Skip to content

Commit

Permalink
Merge pull request #59 from software-mansion-labs/w8/ideal-nav-fixes-v6
Browse files Browse the repository at this point in the history
Refactor comments
  • Loading branch information
filip-solecki authored Feb 1, 2024
2 parents 7860696 + 1fe4cd6 commit d30ff8c
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 12 deletions.
6 changes: 6 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,10 @@ const CONST = {
OTHER_INVISIBLE_CHARACTERS: /[\u3164]/g,

REPORT_FIELD_TITLE: /{report:([a-zA-Z]+)}/g,

PATH_WITHOUT_POLICY_ID: /\/w\/[a-zA-Z0-9]+(\/|$)/,

POLICY_ID_FROM_PATH: /\/w\/([a-zA-Z0-9]+)(\/|$)/,
},

PRONOUNS: {
Expand Down Expand Up @@ -3104,6 +3108,7 @@ const CONST = {
DEFAULT: 5,
CAROUSEL: 3,
},

BRICK_ROAD: {
GBR: 'info',
RBR: 'error',
Expand Down Expand Up @@ -3172,6 +3177,7 @@ const CONST = {
SUBSCRIPT_ICON_SIZE: 8,
MINIMUM_WORKSPACES_TO_SHOW_SEARCH: 8,
},

REPORT_FIELD_TITLE_FIELD_ID: 'text_title',
} as const;

Expand Down
1 change: 1 addition & 0 deletions src/components/AvatarWithImagePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const propTypes = {

/** Indicates if picker feature should be disabled */
disabled: PropTypes.bool,

/** Executed once click on view photo option */
onViewPhotoPress: PropTypes.func,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type CustomNavigatorProps = DefaultNavigatorOptions<ParamListBase, StackNavigati

function getStateToRender(state: StackNavigationState<ParamListBase>): StackNavigationState<ParamListBase> {
const routesToRender = [state.routes.at(-1)] as NavigationStateRoute[];

// We need to render at least one HOME screen to make sure everything load properly.
if (routesToRender[0].name !== SCREENS.HOME) {
const routeToRender = state.routes.find((route) => route.name === SCREENS.HOME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function compareAndAdaptState(state: StackNavigationState<RootStackParamList>) {
const topmostBottomTabRoute = getTopmostBottomTabRoute(state);
const isSmallScreenWidth = getIsSmallScreenWidth();

// This solutions is heurestis and will work for our cases. We may need to improve it in the future if we will have more cases to handle.
// This solutions is heuristics and will work for our cases. We may need to improve it in the future if we will have more cases to handle.
if (topmostBottomTabRoute && !isSmallScreenWidth) {
const fullScreenRoute = state.routes.find((route) => route.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR);

Expand Down Expand Up @@ -84,7 +84,7 @@ function compareAndAdaptState(state: StackNavigationState<RootStackParamList>) {
// If there is central pane route in state and template state has one, we need to check if they are the same.
if (topmostCentralPaneRouteExtracted && templateCentralPaneRouteExtracted && topmostCentralPaneRouteExtracted.name !== templateCentralPaneRouteExtracted.name) {
// Not every RHP screen has matching central pane defined. In that case we use the REPORT screen as default for initial screen.
// But we don't want to ovverride the central pane for those screens as they may be opened with different central panes under the overlay.
// But we don't want to override the central pane for those screens as they may be opened with different central panes under the overlay.
// e.g. i-know-a-teacher may be opened with different central panes under the overlay
if (templateCentralPaneRouteExtracted.name === SCREENS.REPORT) {
return;
Expand Down
10 changes: 5 additions & 5 deletions src/libs/Navigation/AppNavigator/getPartialStateDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ type GetPartialStateDiffReturnType = {
};

/**
* This function returns partial additive diff beteween the two states.
* The partial diff have information which bottom tab, central pane and full screen screens we need to push to go from state to templateState
* This function returns partial additive diff between the two states.
* The partial diff has information which bottom tab, central pane and full screen screens we need to push to go from state to templateState.
* @param state - Current state.
* @param templateState - Desired state generated with getAdaptedStateFromPath.
* @param metainfo - Additional info from getAdaptedStateFromPath funciton.
* @param metainfo - Additional info from getAdaptedStateFromPath function.
* @returns The screen options object
*/
function getPartialStateDiff(state: State<RootStackParamList>, templateState: State<RootStackParamList>, metainfo: Metainfo): GetPartialStateDiffReturnType {
Expand Down Expand Up @@ -60,8 +60,8 @@ function getPartialStateDiff(state: State<RootStackParamList>, templateState: St
}
}

// This one is heurestic and may need to improved if we will be able to navigate from modal screen with full screen in background to another modal screen with full screen in background.
// For now this simple check is enought.
// This one is heuristic and may need to be improved if we will be able to navigate from modal screen with full screen in background to another modal screen with full screen in background.
// For now this simple check is enough.
if (metainfo.isFullScreenNavigatorMandatory) {
const stateTopmostFullScreen = state.routes.filter((route) => route.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR).at(-1);
const templateStateTopmostFullScreen = templateState.routes.filter((route) => route.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR).at(-1) as NavigationPartialRoute;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/linkTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default function linkTo(navigation: NavigationContainerRef<RootStackParam
},
});
} else {
// // If the layout is small we need to pop everything from the central pane so the bottom tab navigator is visible.
// If the layout is small we need to pop everything from the central pane so the bottom tab navigator is visible.
root.dispatch({
type: 'POP_TO_TOP',
target: rootState.key,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ function isPaidGroupPolicy(policy: OnyxEntry<Policy>): boolean {
}

function extractPolicyIDFromPath(path: string) {
return path.match(/\/w\/([a-zA-Z0-9]+)(\/|$)/)?.[1];
return path.match(CONST.REGEX.POLICY_ID_FROM_PATH)?.[1];
}

function getPathWithoutPolicyID(path: string) {
return path.replace(/\/w\/[a-zA-Z0-9]+(\/|$)/, '/');
return path.replace(CONST.REGEX.PATH_WITHOUT_POLICY_ID, '/');
}

function getPolicyMembersByIdWithoutCurrentUser(policyMembers: OnyxCollection<PolicyMembers>, currentPolicyID?: string, currentUserAccountID?: number) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,7 @@ function showReportActionNotification(reportID: string, reportAction: ReportActi
Modal.close(() => {
const policyID = lastVisitedPath && extractPolicyIDFromPath(lastVisitedPath);
const policyMembersAccountIDs = policyID ? getPolicyMemberAccountIDs(policyID) : [];
const reportBelongsToWorkspace = policyID ? doesReportBelongToWorkspace(report, policyMembersAccountIDs, policyID) : true;
const reportBelongsToWorkspace = policyID ? doesReportBelongToWorkspace(report, policyMembersAccountIDs, policyID) : false;
if (!reportBelongsToWorkspace) {
Navigation.navigateWithSwitchPolicyID({policyID: undefined, route: ROUTES.HOME});
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/sidebar/AllSettingsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function AllSettingsScreen({policies, policyMembers}: AllSettingsScreenProps) {
const {isSmallScreenWidth} = useWindowDimensions();

/**
* Retuns a list of menu items data for "everything" settings
* Retuns a list of menu items data for All workspaces settings
* @returns {Object} object with translationKey, style and items
*/
const menuItems = useMemo(() => {
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/WorkspacePageWithSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type WorkspacePageWithSectionsProps = WithPolicyAndFullscreenLoadingProps &
/** Should show the back button. It is used when in RHP. */
shouldShowBackButton?: boolean;

/** Whether the offline indicator should be shown in wide screen devices */
shouldShowOfflineIndicatorInWideScreen?: boolean;

/** Whether to show this page to non admin policy members */
Expand Down
1 change: 1 addition & 0 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ type Policy = {
/** When tax tracking is enabled */
isTaxTrackingEnabled?: boolean;

/** ReportID of the admins room for this workspace */
chatReportIDAdmins?: number;

chatReportIDAnnounce?: number;
Expand Down

0 comments on commit d30ff8c

Please sign in to comment.