Replace current state when changing page

pull/525/head
Chocobozzz 2018-04-20 14:27:30 +02:00
parent 6d492e562c
commit 2a2c19dfef
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import { Component, OnInit, OnDestroy } from '@angular/core' import { Component, OnInit, OnDestroy } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { Location } from '@angular/common'
import { immutableAssign } from '@app/shared/misc/utils' import { immutableAssign } from '@app/shared/misc/utils'
import { ComponentPagination } from '@app/shared/rest/component-pagination.model' import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
import { NotificationsService } from 'angular2-notifications' import { NotificationsService } from 'angular2-notifications'
@ -35,6 +36,7 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit,
protected authService: AuthService, protected authService: AuthService,
protected notificationsService: NotificationsService, protected notificationsService: NotificationsService,
protected confirmService: ConfirmService, protected confirmService: ConfirmService,
protected location: Location,
private videoService: VideoService) { private videoService: VideoService) {
super() super()
} }

View File

@ -1,5 +1,6 @@
import { ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core' import { ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { Location } from '@angular/common'
import { isInMobileView } from '@app/shared/misc/utils' import { isInMobileView } from '@app/shared/misc/utils'
import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive' import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive'
import { NotificationsService } from 'angular2-notifications' import { NotificationsService } from 'angular2-notifications'
@ -40,6 +41,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {
protected abstract authService: AuthService protected abstract authService: AuthService
protected abstract router: Router protected abstract router: Router
protected abstract route: ActivatedRoute protected abstract route: ActivatedRoute
protected abstract location: Location
protected abstract currentRoute: string protected abstract currentRoute: string
abstract titlePage: string abstract titlePage: string
@ -164,8 +166,10 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {
} }
protected setNewRouteParams () { protected setNewRouteParams () {
const routeParams = this.buildRouteParams() const paramsObject = this.buildRouteParams()
this.router.navigate([ this.currentRoute ], { queryParams: routeParams })
const queryParams = Object.keys(paramsObject).map(p => p + '=' + paramsObject[p]).join('&')
this.location.replaceState(this.currentRoute, queryParams)
} }
protected buildVideoPages () { protected buildVideoPages () {

View File

@ -1,6 +1,7 @@
import { Component, OnDestroy, OnInit } from '@angular/core' import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { immutableAssign } from '@app/shared/misc/utils' import { immutableAssign } from '@app/shared/misc/utils'
import { Location } from '@angular/common'
import { NotificationsService } from 'angular2-notifications' import { NotificationsService } from 'angular2-notifications'
import { AuthService } from '../../core/auth' import { AuthService } from '../../core/auth'
import { AbstractVideoList } from '../../shared/video/abstract-video-list' import { AbstractVideoList } from '../../shared/video/abstract-video-list'
@ -23,6 +24,7 @@ export class VideoLocalComponent extends AbstractVideoList implements OnInit, On
protected route: ActivatedRoute, protected route: ActivatedRoute,
protected notificationsService: NotificationsService, protected notificationsService: NotificationsService,
protected authService: AuthService, protected authService: AuthService,
protected location: Location,
private videoService: VideoService) { private videoService: VideoService) {
super() super()
} }

View File

@ -1,5 +1,6 @@
import { Component, OnDestroy, OnInit } from '@angular/core' import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { Location } from '@angular/common'
import { immutableAssign } from '@app/shared/misc/utils' import { immutableAssign } from '@app/shared/misc/utils'
import { NotificationsService } from 'angular2-notifications' import { NotificationsService } from 'angular2-notifications'
import { AuthService } from '../../core/auth' import { AuthService } from '../../core/auth'
@ -19,6 +20,7 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On
constructor (protected router: Router, constructor (protected router: Router,
protected route: ActivatedRoute, protected route: ActivatedRoute,
protected location: Location,
protected notificationsService: NotificationsService, protected notificationsService: NotificationsService,
protected authService: AuthService, protected authService: AuthService,
private videoService: VideoService) { private videoService: VideoService) {

View File

@ -1,5 +1,6 @@
import { Component, OnDestroy, OnInit } from '@angular/core' import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { Location } from '@angular/common'
import { RedirectService } from '@app/core' import { RedirectService } from '@app/core'
import { immutableAssign } from '@app/shared/misc/utils' import { immutableAssign } from '@app/shared/misc/utils'
import { NotificationsService } from 'angular2-notifications' import { NotificationsService } from 'angular2-notifications'
@ -27,6 +28,7 @@ export class VideoSearchComponent extends AbstractVideoList implements OnInit, O
protected route: ActivatedRoute, protected route: ActivatedRoute,
protected notificationsService: NotificationsService, protected notificationsService: NotificationsService,
protected authService: AuthService, protected authService: AuthService,
protected location: Location,
private videoService: VideoService, private videoService: VideoService,
private redirectService: RedirectService private redirectService: RedirectService
) { ) {

View File

@ -1,5 +1,6 @@
import { Component, OnDestroy, OnInit } from '@angular/core' import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
import { Location } from '@angular/common'
import { immutableAssign } from '@app/shared/misc/utils' import { immutableAssign } from '@app/shared/misc/utils'
import { NotificationsService } from 'angular2-notifications' import { NotificationsService } from 'angular2-notifications'
import { AuthService } from '../../core/auth' import { AuthService } from '../../core/auth'
@ -21,6 +22,7 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
protected route: ActivatedRoute, protected route: ActivatedRoute,
protected notificationsService: NotificationsService, protected notificationsService: NotificationsService,
protected authService: AuthService, protected authService: AuthService,
protected location: Location,
private videoService: VideoService) { private videoService: VideoService) {
super() super()
} }