in src/actions/app-actions.ts [566:630]
export function completeInitialization(
issueId?: string,
articleId?: string,
navigateToActivity?: string,
searchQuery?: string,
isRedirected: boolean = false,
helpdeskFormId?: string,
): ReduxAction {
return async (dispatch: ReduxThunkDispatch) => {
await dispatch(applyGlobalSettings());
dispatch({
type: types.SET_HELPDESK_MENU_HIDDEN,
hidden: storage.getStorageState().helpdeskMenuHidden,
});
log.info('App Actions: Completing initialization');
const cachedCurrentUser: User | undefined = storage.getStorageState()?.currentUser?.ytCurrentUser;
const cachedLocale: UserGeneralProfileLocale | undefined = cachedCurrentUser?.profiles?.general?.locale;
const currentUser: User = await dispatch(loadYTCurrentUser());
const userProfileLocale: UserGeneralProfileLocale | undefined = currentUser?.profiles?.general?.locale;
const isLanguageChanged: boolean = !cachedLocale?.language || (
!!cachedLocale?.language &&
!!userProfileLocale?.language &&
cachedLocale?.language !== userProfileLocale?.language
);
if (isLanguageChanged && userProfileLocale?.language) {
loadTranslation(userProfileLocale?.locale, userProfileLocale?.language);
if (!issueId && !articleId) {
redirectToHome(storage.getStorageState()?.config?.backendUrl);
}
}
await dispatch(loadUserPermissions());
await dispatch(cacheProjects());
log.info('App Actions: Initialization completed');
const isStackNotEmpty = Router.getRoutes().length <= 1;
log.info(`App Actions(completeInitialization): stack: ${JSON.stringify(Router.getRoutes())}`);
if (isStackNotEmpty && !isRedirected) {
if (currentUser.profiles?.helpdesk?.isReporter) {
Router.Tickets();
} else {
Router.navigateToDefaultRoute(
issueId || articleId || searchQuery || helpdeskFormId
? {
issueId,
articleId,
navigateToActivity,
searchQuery,
helpdeskFormId,
}
: undefined
);
}
}
dispatch(loadWorkTimeSettings());
dispatch(subscribeToPushNotifications());
if (checkVersion(FEATURE_VERSION.inboxThreads)) {
dispatch(inboxCheckUpdateStatus());
}
log.info('App Actions(completeInitialization): Initialization completed');
};
}