Skip to content

Commit 22db2af

Browse files
authored
Redirect unpublished url loads to the homepage similar to from-file (#5712)
Initially `unpublished` was an alias of `from-addon` and then it was made a separate data source. But reloading the url or loading from scratch was hanging in the profile loading animation indefinitely and it wasn't trying to load any profile either. It makes sense to make it behave more like `from-file` in that sense and just redirect to the home page. Issue #5709 has an STR for this bug.
1 parent 5dd4c64 commit 22db2af

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/actions/app.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,12 @@ export function setupInitialUrlState(
150150
return;
151151
}
152152

153-
// Validate the initial URL state. We can't refresh on a from-file URL.
154-
if (urlState.dataSource === 'from-file') {
153+
// Validate the initial URL state. We can't refresh on from-file or
154+
// unpublished URLs.
155+
if (
156+
urlState.dataSource === 'from-file' ||
157+
urlState.dataSource === 'unpublished'
158+
) {
155159
urlState = null;
156160
}
157161

src/actions/receive-profile.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,9 +1400,10 @@ export function retrieveProfileForRawUrl(
14001400
}
14011401

14021402
let dataSource = ensureIsValidDataSource(possibleDataSource);
1403-
if (dataSource === 'from-file') {
1404-
// Redirect to 'none' if `dataSource` is 'from-file' since initial urls can't
1405-
// be 'from-file' and needs to be redirected to home page.
1403+
// Redirect to 'none' for from-file and unpublished data sources since initial
1404+
// urls can't be 'from-file' or 'unpublished' and need to be redirected to
1405+
// home page. 'unpublished' is a transient state after profile deletion.
1406+
if (dataSource === 'from-file' || dataSource === 'unpublished') {
14061407
dataSource = 'none';
14071408
}
14081409
dispatch(setDataSource(dataSource));
@@ -1475,7 +1476,6 @@ export function retrieveProfileForRawUrl(
14751476
case 'uploaded-recordings':
14761477
case 'none':
14771478
case 'local':
1478-
case 'unpublished':
14791479
// There is no profile to download for these datasources.
14801480
break;
14811481
default:

src/test/store/receive-profile.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,6 +2190,20 @@ describe('actions/receive-profile', function () {
21902190
});
21912191
}
21922192
);
2193+
2194+
it('redirects unpublished initial URLs to home page', async function () {
2195+
const { getState } = await setup({
2196+
pathname: '/unpublished/',
2197+
search: '',
2198+
hash: '',
2199+
});
2200+
2201+
// The data source should be redirected from 'unpublished' to 'none'.
2202+
expect(UrlStateSelectors.getDataSource(getState())).toEqual('none');
2203+
2204+
// No profile should be loaded.
2205+
expect(ProfileViewSelectors.getProfileOrNull(getState())).toEqual(null);
2206+
});
21932207
});
21942208
});
21952209

0 commit comments

Comments
 (0)