import { AuthService } from '../../core/auth'
import { ConfirmService } from '../../core/confirm'
import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
-import { Subscription } from 'rxjs'
+import { Subject, Subscription } from 'rxjs'
import { ActivatedRoute } from '@angular/router'
import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service'
import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model'
import { I18n } from '@ngx-translate/i18n-polyfill'
+import { ScreenService } from '@app/shared/misc/screen.service'
import { CdkDragDrop } from '@angular/cdk/drag-drop'
import { VideoPlaylistElement } from '@app/shared/video-playlist/video-playlist-element.model'
pagination: ComponentPagination = {
currentPage: 1,
- itemsPerPage: 30,
+ itemsPerPage: 10,
totalItems: null
}
+ onDataSubject = new Subject<any[]>()
+
private videoPlaylistId: string | number
private paramsSub: Subscription
private confirmService: ConfirmService,
private route: ActivatedRoute,
private i18n: I18n,
+ private screenService: ScreenService,
private videoPlaylistService: VideoPlaylistService
) {}
return elem.id
}
+ /**
+ * Returns null to not have drag and drop delay.
+ * In small views, where elements are about 100% wide,
+ * we add a delay to prevent unwanted drag&drop.
+ *
+ * @see {@link https://github.com/Chocobozzz/PeerTube/issues/2078}
+ *
+ * @returns {null|number} Null for no delay, or a number in milliseconds.
+ */
+ getDragStartDelay (): null | number {
+ if (this.screenService.isInTouchScreen()) {
+ return 500
+ }
+
+ return null
+ }
+
private loadElements () {
this.videoPlaylistService.getPlaylistVideos(this.videoPlaylistId, this.pagination)
.subscribe(({ total, data }) => {
this.playlistElements = this.playlistElements.concat(data)
this.pagination.totalItems = total
+
+ this.onDataSubject.next(data)
})
}