<commit_before>import { NgModule, Injectable } from '@angular/core';
import { RouterModule, Routes, Resolve, ActivatedRouteSnapshot, CanDeactivate } from '@angular/router';

import { RpComponent } from './rp/rp.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { TitleComponent } from './title/title.component';
import { ArchiveComponent } from './rp/archive/archive.component';
import { ChatComponent } from './rp/chat/chat.component';
import { RpService } from './rp.service';

@Injectable()
export class RpResolverService implements Resolve<any> {
  constructor(private service: RpService) { }

  resolve(route: ActivatedRouteSnapshot) {
    let rpCode = route.paramMap.get('rpCode');
    return this.service.join(rpCode);
  }
}

@Injectable()
export class RpDeactivate implements CanDeactivate<RpComponent> {
  canDeactivate(component: RpComponent){
    component.onRouteDeactivate();
    return true;
  }
}

const appRoutes: Routes = [
  {
    path: 'rp/:rpCode',
    component: RpComponent,
    canDeactivate: [RpDeactivate],<commit_msg>temp solution for 404 RP; we need to make sure that rp-not-found doesn't persist if the rpCode does exist later.<commit_after>import { NgModule, Injectable } from '@angular/core';
import { RouterModule, Router, Routes, Resolve, ActivatedRouteSnapshot, CanDeactivate } from '@angular/router';

import { RpComponent } from './rp/rp.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { TitleComponent } from './title/title.component';
import { ArchiveComponent } from './rp/archive/archive.component';
import { ChatComponent } from './rp/chat/chat.component';
import { RpService } from './rp.service';

@Injectable()
export class RpResolverService implements Resolve<any> {
  constructor(private service: RpService, private router: Router) { }

  resolve(route: ActivatedRouteSnapshot) {
    let rpCode = route.paramMap.get('rpCode');
    return this.service.join(rpCode).catch(err => {
      if (err.code === 'RP_NOT_FOUND') {
        this.router.navigate(['/rp-not-found', rpCode])
        return err;
      }

      throw err;
    });
  }
}

@Injectable()
export class RpDeactivate implements CanDeactivate<RpComponent> {
  canDeactivate(component: RpComponent){
    component.onRouteDeactivate();
    return true;
  }
}

const appRoutes: Routes = [
  {
    path: 'rp/:rpCode',
    component: RpComponent,
    canDeactivate: [RpDeactivate],
{'fraction_non_alphanumeric': 0.13140764849471115, 'fraction_numerical': 0.0012205044751830757, 'mean_word_length': 4.464444444444444, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, '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': '750898', 'n_tokens_mistral': 751, 'n_tokens_neox': 745, 'n_words': 177}