From 8dfceec44a5eec8b0190d1d5076aab0f03a0cb52 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 Apr 2019 14:16:48 +0200 Subject: [PATCH] video add to playlist component -> onpush strategy --- .../forms/peertube-checkbox.component.scss | 2 +- .../forms/peertube-checkbox.component.ts | 11 +++++++++- client/src/app/shared/misc/screen.service.ts | 4 ++++ .../video-add-to-playlist.component.html | 4 ++-- .../video-add-to-playlist.component.scss | 1 + .../video-add-to-playlist.component.ts | 22 ++++++++++++++----- .../modals/video-download.component.html | 2 +- .../video/modals/video-download.component.ts | 2 +- .../video/video-actions-dropdown.component.ts | 2 +- .../video/video-miniature.component.scss | 6 +++++ .../shared/video/video-miniature.component.ts | 3 ++- 11 files changed, 46 insertions(+), 13 deletions(-) diff --git a/client/src/app/shared/forms/peertube-checkbox.component.scss b/client/src/app/shared/forms/peertube-checkbox.component.scss index 6e4e20775..ea321ee65 100644 --- a/client/src/app/shared/forms/peertube-checkbox.component.scss +++ b/client/src/app/shared/forms/peertube-checkbox.component.scss @@ -28,4 +28,4 @@ position: relative; top: -2px; } -} \ No newline at end of file +} diff --git a/client/src/app/shared/forms/peertube-checkbox.component.ts b/client/src/app/shared/forms/peertube-checkbox.component.ts index c1a6915e8..9578f5618 100644 --- a/client/src/app/shared/forms/peertube-checkbox.component.ts +++ b/client/src/app/shared/forms/peertube-checkbox.component.ts @@ -1,4 +1,4 @@ -import { Component, forwardRef, Input } from '@angular/core' +import { ChangeDetectorRef, Component, forwardRef, Input, OnChanges, SimpleChanges } from '@angular/core' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' @Component({ @@ -21,10 +21,19 @@ export class PeertubeCheckboxComponent implements ControlValueAccessor { @Input() helpHtml: string @Input() disabled = false + // FIXME: https://github.com/angular/angular/issues/10816#issuecomment-307567836 + @Input() onPushWorkaround = false + + constructor (private cdr: ChangeDetectorRef) { } + propagateChange = (_: any) => { /* empty */ } writeValue (checked: boolean) { this.checked = checked + + if (this.onPushWorkaround) { + this.cdr.markForCheck() + } } registerOnChange (fn: (_: any) => void) { diff --git a/client/src/app/shared/misc/screen.service.ts b/client/src/app/shared/misc/screen.service.ts index db481204e..af75569d9 100644 --- a/client/src/app/shared/misc/screen.service.ts +++ b/client/src/app/shared/misc/screen.service.ts @@ -18,6 +18,10 @@ export class ScreenService { return this.getWindowInnerWidth() < 500 } + isInTouchScreen () { + return 'ontouchstart' in window || navigator.msMaxTouchPoints + } + // Cache window inner width, because it's an expensive call private getWindowInnerWidth () { if (this.cacheWindowInnerWidthExpired()) this.refreshWindowInnerWidth() diff --git a/client/src/app/shared/video-playlist/video-add-to-playlist.component.html b/client/src/app/shared/video-playlist/video-add-to-playlist.component.html index 6029b3648..648d580fa 100644 --- a/client/src/app/shared/video-playlist/video-add-to-playlist.component.html +++ b/client/src/app/shared/video-playlist/video-add-to-playlist.component.html @@ -42,7 +42,7 @@