async function navigateToScreen()

in src/actions/app-actions.ts [791:832]


async function navigateToScreen(
  backendUrl: string,
  dispatch: ReduxThunkDispatch,
  url: string,
  forceReset: boolean,
  issueId?: string,
  articleId?: string,
  searchQuery?: string,
  helpdeskFormId?: string,
) {
  if (url.indexOf(backendUrl) === -1) {
    const targetServerURL = UrlParse(url).origin;
    const account = await targetAccountToSwitchTo(targetServerURL, backendUrl);
    if (account) {
      await dispatch(changeAccount(account, false, issueId, articleId, undefined, searchQuery, helpdeskFormId));
    } else {
      notify(i18n('You are trying to open a link from another server. Please add this server to the app first.'));
    }
  } else {
    const navigateToActivity: string | undefined = url.split('#focus=Comments-')?.[1];
    if (helpdeskFormId) {
      Router.HelpDeskFeedback({uuid: helpdeskFormId});
    } else {
      const splitView = isSplitView();
      if (issueId) {
            if (splitView) {
              Router.Issues({issueId, issuePlaceholder: {id: issueId}, navigateToActivity});
            } else {
              Router.Issue({issueId, issuePlaceholder: {id: issueId}, navigateToActivity}, {forceReset});
            }
          } else if (articleId) {
            if (splitView) {
              Router.KnowledgeBase({lastVisitedArticle: {id: articleId}, navigateToActivity, preventReload: true}, {forceReset});
            } else {
              Router.Article({articlePlaceholder: {id: articleId}, navigateToActivity}, {forceReset});
            }
          } else {
            Router.navigateToDefaultRoute({searchQuery});
          }
    }
  }
}