* Remove Connect
* Remove more Connect specs
* Remove a lot more Connect code
* 🚮
* It all has to go
* Explicitly add httpclient
* Update application layout
* Remove messages association from User
* Start fixing specs
* reintroduce util function and refactor references
* Remove Connect Cypress test
* Fix more specs
* Remove Connect from listings
* Ignore contact_via_connect column on listings
* Remove contact_via_connect usages
* Ignore mod_chat_channel_id on tags
* Drop Connect tables
* Remove email_connect_messages from user notification settings
* Re-add httpclient 2.8.3
This was mistakenly removed as a merge conflict
* Don't need to exclude removed chat channel file
* Remove unneeded style for chat channels
* Remove unneeded channel list prop type
* Remove chat channels index/connect-link from getPageEntries
* Re-add comment from httpclient in Gemfile
* Remove connect references from mailers
Tag Moderators no longer have a chat channel
No longer will users be notified about new messages (there won't be
any)
No longer will users be notified about channel invites (you can't
invite anyone anymore)
* Don't configure Pusher and remove PUSHER_* from .env_sample
since it's removed from gemfile, the Pusher constant will not resolve, if this is
configured in the environment variables we'll fail to boot.
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Dan Uber <dan@forem.com>
76 lines
2.5 KiB
JavaScript
76 lines
2.5 KiB
JavaScript
import { getUserDataAndCsrfToken } from '@utilities/getUserDataAndCsrfToken';
|
|
|
|
HTMLDocument.prototype.ready = new Promise((resolve) => {
|
|
if (document.readyState !== 'loading') {
|
|
return resolve();
|
|
}
|
|
document.addEventListener('DOMContentLoaded', () => resolve());
|
|
return null;
|
|
});
|
|
|
|
// If localStorage.getItem('shouldRedirectToOnboarding') is not set, i.e. null, that means we should redirect.
|
|
function redirectableLocation() {
|
|
return (
|
|
window.location.pathname !== '/onboarding' &&
|
|
window.location.pathname !== '/signout_confirm' &&
|
|
window.location.pathname !== '/privacy' &&
|
|
window.location.pathname !== '/admin/creator_settings/new'
|
|
);
|
|
}
|
|
|
|
function onboardingSkippable(currentUser) {
|
|
return (
|
|
currentUser.saw_onboarding &&
|
|
currentUser.checked_code_of_conduct &&
|
|
currentUser.checked_terms_and_conditions
|
|
);
|
|
}
|
|
|
|
function onboardCreator(currentUser) {
|
|
return (
|
|
document.body.dataset.creator === 'true' &&
|
|
document.body.dataset.creatorOnboarding === 'true' &&
|
|
!currentUser.saw_onboarding
|
|
);
|
|
}
|
|
|
|
document.ready.then(
|
|
getUserDataAndCsrfToken()
|
|
.then(({ currentUser, csrfToken }) => {
|
|
window.currentUser = currentUser;
|
|
window.csrfToken = csrfToken;
|
|
|
|
if (redirectableLocation() && onboardCreator(currentUser)) {
|
|
window.location = `${window.location.origin}/admin/creator_settings/new?referrer=${window.location}`;
|
|
} else if (redirectableLocation() && !onboardingSkippable(currentUser)) {
|
|
window.location = `${window.location.origin}/onboarding?referrer=${window.location}`;
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
// eslint-disable-next-line no-console
|
|
console.error('Error getting user and CSRF Token', error);
|
|
}),
|
|
);
|
|
|
|
window.InstantClick.on('change', () => {
|
|
getUserDataAndCsrfToken()
|
|
.then(({ currentUser }) => {
|
|
if (
|
|
redirectableLocation() &&
|
|
localStorage.getItem('shouldRedirectToOnboarding') === null &&
|
|
onboardCreator(currentUser)
|
|
) {
|
|
window.location = `${window.location.origin}/admin/creator_settings/new?referrer=${window.location}`;
|
|
} else if (
|
|
redirectableLocation() &&
|
|
localStorage.getItem('shouldRedirectToOnboarding') === null &&
|
|
!onboardingSkippable(currentUser)
|
|
) {
|
|
window.location = `${window.location.origin}/onboarding?referrer=${window.location}`;
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
// eslint-disable-next-line no-console
|
|
console.error('Error getting user and CSRF Token', error);
|
|
});
|
|
});
|