Skip to content

Commit

Permalink
Use getProfileOrNull instead of getProfile in getProfilesFromRawUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
canova committed Jul 19, 2019
1 parent adcdca9 commit 289a64b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/actions/receive-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
initializeHiddenGlobalTracks,
getVisibleThreads,
} from '../profile-logic/tracks';
import { getProfile, getProfileOrNull } from '../selectors/profile';
import { getProfileOrNull } from '../selectors/profile';
import { getView } from '../selectors/app';
import { setDataSource } from './profile-view';

Expand Down Expand Up @@ -997,7 +997,7 @@ export function retrieveProfilesToCompare(
export function getProfilesFromRawUrl(
location: Location
): ThunkAction<
Promise<{| profile: Profile, shouldSetupInitialUrlState: boolean |}>
Promise<{| profile: Profile | null, shouldSetupInitialUrlState: boolean |}>
> {
return async (dispatch, getState) => {
const pathParts = location.pathname.split('/').filter(d => d);
Expand Down Expand Up @@ -1049,7 +1049,7 @@ export function getProfilesFromRawUrl(
}

return {
profile: getProfile(getState()),
profile: getProfileOrNull(getState()),
shouldSetupInitialUrlState,
};
};
Expand Down
6 changes: 3 additions & 3 deletions src/components/app/UrlManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ class UrlManager extends React.PureComponent<Props> {
try {
// Process the raw url and fetch the profile.
const results: {
profile: Profile,
profile: Profile | null,
shouldSetupInitialUrlState: boolean,
} = await getProfilesFromRawUrl(window.location);

// Manually coerce these into the proper type due to the FlowFixMe above.
const profile: Profile = results.profile;
const profile: Profile | null = results.profile;
const shouldSetupInitialUrlState: boolean =
results.shouldSetupInitialUrlState;
if (shouldSetupInitialUrlState) {
if (profile !== null && shouldSetupInitialUrlState) {
setupInitialUrlState(window.location, profile);
} else {
urlSetupDone();
Expand Down

0 comments on commit 289a64b

Please sign in to comment.