aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-22 17:13:58 +0200
committerChocobozzz <me@florianbigard.com>2019-08-22 17:14:44 +0200
commit60c2bc80b82c71bd63bdb1fcf64d4d49491ce5c8 (patch)
treef9479065dc5d28bca46120ab0a29ed7074ab5fff /client
parent4334445d043252661e62cf97f76b67a2c43e3750 (diff)
downloadPeerTube-60c2bc80b82c71bd63bdb1fcf64d4d49491ce5c8.tar.gz
PeerTube-60c2bc80b82c71bd63bdb1fcf64d4d49491ce5c8.tar.zst
PeerTube-60c2bc80b82c71bd63bdb1fcf64d4d49491ce5c8.zip
Go back when cancel NSFW modal
Instead of redirecting on the homepage
Diffstat (limited to 'client')
-rw-r--r--client/src/app/app.component.ts6
-rw-r--r--client/src/app/core/confirm/confirm.service.ts8
-rw-r--r--client/src/app/shared/confirm/confirm.component.ts8
-rw-r--r--client/src/app/shared/misc/constants.ts1
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts6
5 files changed, 22 insertions, 7 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index 065bdcaa4..64bfb9671 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -12,6 +12,7 @@ import { PlatformLocation, ViewportScroller } from '@angular/common'
12import { PluginService } from '@app/core/plugins/plugin.service' 12import { PluginService } from '@app/core/plugins/plugin.service'
13import { HooksService } from '@app/core/plugins/hooks.service' 13import { HooksService } from '@app/core/plugins/hooks.service'
14import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 14import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
15import { POP_STATE_MODAL_DISMISS } from '@app/shared/misc/constants'
15 16
16@Component({ 17@Component({
17 selector: 'my-app', 18 selector: 'my-app',
@@ -94,7 +95,7 @@ export class AppComponent implements OnInit {
94 .pipe(debounceTime(200)) 95 .pipe(debounceTime(200))
95 .subscribe(() => this.onResize()) 96 .subscribe(() => this.onResize())
96 97
97 this.location.onPopState(() => this.modalService.dismissAll()) 98 this.location.onPopState(() => this.modalService.dismissAll(POP_STATE_MODAL_DISMISS))
98 } 99 }
99 100
100 isUserLoggedIn () { 101 isUserLoggedIn () {
@@ -115,7 +116,6 @@ export class AppComponent implements OnInit {
115 const eventsObs = this.router.events 116 const eventsObs = this.router.events
116 117
117 const scrollEvent = eventsObs.pipe(filter((e: Event): e is Scroll => e instanceof Scroll)) 118 const scrollEvent = eventsObs.pipe(filter((e: Event): e is Scroll => e instanceof Scroll))
118 const navigationEndEvent = eventsObs.pipe(filter((e: Event): e is NavigationEnd => e instanceof NavigationEnd))
119 119
120 scrollEvent.subscribe(e => { 120 scrollEvent.subscribe(e => {
121 if (e.position) { 121 if (e.position) {
@@ -131,6 +131,8 @@ export class AppComponent implements OnInit {
131 } 131 }
132 }) 132 })
133 133
134 const navigationEndEvent = eventsObs.pipe(filter((e: Event): e is NavigationEnd => e instanceof NavigationEnd))
135
134 // When we add the a-state parameter, we don't want to alter the scroll 136 // When we add the a-state parameter, we don't want to alter the scroll
135 navigationEndEvent.pipe(pairwise()) 137 navigationEndEvent.pipe(pairwise())
136 .subscribe(([ e1, e2 ]) => { 138 .subscribe(([ e1, e2 ]) => {
diff --git a/client/src/app/core/confirm/confirm.service.ts b/client/src/app/core/confirm/confirm.service.ts
index 8419f622b..6e042c16b 100644
--- a/client/src/app/core/confirm/confirm.service.ts
+++ b/client/src/app/core/confirm/confirm.service.ts
@@ -18,12 +18,16 @@ export class ConfirmService {
18 confirm (message: string, title = '', confirmButtonText?: string) { 18 confirm (message: string, title = '', confirmButtonText?: string) {
19 this.showConfirm.next({ title, message, confirmButtonText }) 19 this.showConfirm.next({ title, message, confirmButtonText })
20 20
21 return this.confirmResponse.asObservable().pipe(first()).toPromise() 21 return this.confirmResponse.asObservable()
22 .pipe(first())
23 .toPromise()
22 } 24 }
23 25
24 confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) { 26 confirmWithInput (message: string, inputLabel: string, expectedInputValue: string, title = '', confirmButtonText?: string) {
25 this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText }) 27 this.showConfirm.next({ title, message, inputLabel, expectedInputValue, confirmButtonText })
26 28
27 return this.confirmResponse.asObservable().pipe(first()).toPromise() 29 return this.confirmResponse.asObservable()
30 .pipe(first())
31 .toPromise()
28 } 32 }
29} 33}
diff --git a/client/src/app/shared/confirm/confirm.component.ts b/client/src/app/shared/confirm/confirm.component.ts
index 53aed14d7..763454c4f 100644
--- a/client/src/app/shared/confirm/confirm.component.ts
+++ b/client/src/app/shared/confirm/confirm.component.ts
@@ -3,6 +3,7 @@ import { ConfirmService } from '@app/core/confirm/confirm.service'
3import { I18n } from '@ngx-translate/i18n-polyfill' 3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 4import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
5import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 5import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
6import { POP_STATE_MODAL_DISMISS } from '@app/shared/misc/constants'
6 7
7@Component({ 8@Component({
8 selector: 'my-confirm', 9 selector: 'my-confirm',
@@ -63,6 +64,11 @@ export class ConfirmComponent implements OnInit {
63 64
64 this.openedModal.result 65 this.openedModal.result
65 .then(() => this.confirmService.confirmResponse.next(true)) 66 .then(() => this.confirmService.confirmResponse.next(true))
66 .catch(() => this.confirmService.confirmResponse.next(false)) 67 .catch((reason: string) => {
68 // If the reason was that the user used the back button, we don't care about the confirm dialog result
69 if (!reason || reason !== POP_STATE_MODAL_DISMISS) {
70 this.confirmService.confirmResponse.next(false)
71 }
72 })
67 } 73 }
68} 74}
diff --git a/client/src/app/shared/misc/constants.ts b/client/src/app/shared/misc/constants.ts
new file mode 100644
index 000000000..bb4a0884e
--- /dev/null
+++ b/client/src/app/shared/misc/constants.ts
@@ -0,0 +1 @@
export const POP_STATE_MODAL_DISMISS = 'pop state dismiss'
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts
index d7c7b7497..21a24113f 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -34,6 +34,7 @@ import { VideoWatchPlaylistComponent } from '@app/videos/+video-watch/video-watc
34import { getStoredTheater } from '../../../assets/player/peertube-player-local-storage' 34import { getStoredTheater } from '../../../assets/player/peertube-player-local-storage'
35import { PluginService } from '@app/core/plugins/plugin.service' 35import { PluginService } from '@app/core/plugins/plugin.service'
36import { HooksService } from '@app/core/plugins/hooks.service' 36import { HooksService } from '@app/core/plugins/hooks.service'
37import { PlatformLocation } from '@angular/common'
37 38
38@Component({ 39@Component({
39 selector: 'my-video-watch', 40 selector: 'my-video-watch',
@@ -95,6 +96,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
95 private i18n: I18n, 96 private i18n: I18n,
96 private hotkeysService: HotkeysService, 97 private hotkeysService: HotkeysService,
97 private hooks: HooksService, 98 private hooks: HooksService,
99 private location: PlatformLocation,
98 @Inject(LOCALE_ID) private localeId: string 100 @Inject(LOCALE_ID) private localeId: string
99 ) {} 101 ) {}
100 102
@@ -374,13 +376,13 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
374 this.i18n('This video contains mature or explicit content. Are you sure you want to watch it?'), 376 this.i18n('This video contains mature or explicit content. Are you sure you want to watch it?'),
375 this.i18n('Mature or explicit content') 377 this.i18n('Mature or explicit content')
376 ) 378 )
377 if (res === false) return this.redirectService.redirectToHomepage() 379 if (res === false) return this.location.back()
378 } 380 }
379 381
380 // Flush old player if needed 382 // Flush old player if needed
381 this.flushPlayer() 383 this.flushPlayer()
382 384
383 // Build video element, because videojs remove it on dispose 385 // Build video element, because videojs removes it on dispose
384 const playerElementWrapper = this.elementRef.nativeElement.querySelector('#videojs-wrapper') 386 const playerElementWrapper = this.elementRef.nativeElement.querySelector('#videojs-wrapper')
385 this.playerElement = document.createElement('video') 387 this.playerElement = document.createElement('video')
386 this.playerElement.className = 'video-js vjs-peertube-skin' 388 this.playerElement.className = 'video-js vjs-peertube-skin'