<commit_before>import { Location } from '@angular/common';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { RouterState } from '@ngxs/router-plugin';
import { Store } from '@ngxs/store';
import { map } from 'rxjs/operators';
import { DnbhubLoginDialogComponent } from 'src/app/components/login-dialog/login-dialog.component';
import {
  ISupportedLanguage,
  SUPPORTED_LANGUAGE_KEY,
  supportedLanguages,
} from 'src/app/modules/translate/index';
import { firebaseActions } from 'src/app/state/firebase/firebase.actions';
import { DnbhubUiService } from 'src/app/state/ui/ui.service';
import { INxgsRouterState } from 'src/app/utils/ngxs.util';

import { DnbhubFirebaseState } from '../../state/firebase/firebase.store';

@Component({
  selector: 'dnbhub-nav',
  templateUrl: './navbar.component.html',
  styleUrls: ['./navbar.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DnbhubNavbarComponent {
  public readonly userInfo$ = this.store
    .select(DnbhubFirebaseState.getState)
    .pipe(map(state => state.userInfo));

  public readonly language$ = this.ui.language$;

  public readonly showBackButton$ = this.store.select<INxgsRouterState>(RouterState).pipe(
    map(state => {
      return state.navigationId > 1 && !state.state?.url?.includes('index');
    }),
  );

  public readonly privilegedAccess$ = this.store.select(DnbhubFirebaseState.privilegedAccess);

  constructor(
    private readonly store: Store,
    private readonly dialog: MatDialog,
    private readonly ui: DnbhubUiService,
    private readonly location: Location,
  ) {}

  public supportedLanguages: ISupportedLanguage[] = [...supportedLanguages];

  public goBack(): void {
    this.location.back();
  }

  public selectLanguage(key: SUPPORTED_LANGUAGE_KEY = SUPPORTED_LANGUAGE_KEY.ENGLISH): void {
    void this.ui.selectLanguage(key).subscribe();
  }

  public showAuthDialog(): void {
    this.dialog.open(DnbhubLoginDialogComponent);
  }

  public logout(): void {
    void this.store.dispatch(new firebaseActions.signOut()).subscribe();
  }
}<commit_msg>fix(navbar): fix navbar component - go back<commit_after>import { Location } from '@angular/common';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { RouterState } from '@ngxs/router-plugin';
import { Store } from '@ngxs/store';
import { first, map, tap } from 'rxjs/operators';
import { DnbhubLoginDialogComponent } from 'src/app/components/login-dialog/login-dialog.component';
import {
  ISupportedLanguage,
  SUPPORTED_LANGUAGE_KEY,
  supportedLanguages,
} from 'src/app/modules/translate/index';
import { firebaseActions } from 'src/app/state/firebase/firebase.actions';
import { DnbhubUiService } from 'src/app/state/ui/ui.service';
import { INxgsRouterState } from 'src/app/utils/ngxs.util';

import { DnbhubFirebaseState } from '../../state/firebase/firebase.store';

@Component({
  selector: 'dnbhub-nav',
  templateUrl: './navbar.component.html',
  styleUrls: ['./navbar.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DnbhubNavbarComponent {
  public readonly userInfo$ = this.store
    .select(DnbhubFirebaseState.getState)
    .pipe(map(state => state.userInfo));

  public readonly language$ = this.ui.language$;

  public readonly showBackButton$ = this.store.select<INxgsRouterState>(RouterState).pipe(
    map(state => {
      return state.navigationId > 1 && !state.state?.url?.includes('index');
    }),
  );

  public readonly privilegedAccess$ = this.store.select(DnbhubFirebaseState.privilegedAccess);

  constructor(
    private readonly store: Store,
    private readonly dialog: MatDialog,
    private readonly ui: DnbhubUiService,
    private readonly location: Location,
  ) {}

  public supportedLanguages: ISupportedLanguage[] = [...supportedLanguages];

  public goBack(): void {
    void this.store
      .select(RouterState.state)
      .pipe(
        first(),
        tap(state => {
          const hasQueryParams = state?.url?.match(/.*[?].*/);
          if (
            typeof hasQueryParams !== 'undefined' &&
            hasQueryParams !== null &&
            hasQueryParams.length > 0
          ) {
            this.location.back();
            this.location.back();
          } else {
            this.location.back();
          }
        }),
      )
      .subscribe();
  }

  public selectLanguage(key: SUPPORTED_LANGUAGE_KEY = SUPPORTED_LANGUAGE_KEY.ENGLISH): void {
    void this.ui.selectLanguage(key).subscribe();
  }

  public showAuthDialog(): void {
    this.dialog.open(DnbhubLoginDialogComponent);
  }

  public logout(): void {
    void this.store.dispatch(new firebaseActions.signOut()).subscribe();
  }
}
{'fraction_non_alphanumeric': 0.13334711598097995, 'fraction_numerical': 0.0006202191440975812, 'mean_word_length': 3.9417773237997955, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '665992', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1439, 'n_words': 286}