Skip to content

Commit

Permalink
Add option for fully synchronize a chnanel (Chocobozzz#754)
Browse files Browse the repository at this point in the history
  • Loading branch information
fflorent committed Aug 8, 2022
1 parent 9dc5088 commit c8ab2bc
Showing 1 changed file with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core'
import { AuthService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'
import { DropdownAction, VideoChannelSyncService } from '@app/shared/shared-main'
import { DropdownAction, VideoChannelService, VideoChannelSyncService } from '@app/shared/shared-main'
import { HTMLServerConfig } from '@shared/models/server'
import { VideoChannelSync, VideoChannelSyncState } from '@shared/models/videos'
import { SortMeta } from 'primeng/api'
Expand Down Expand Up @@ -32,7 +32,8 @@ export class MyVideoChannelSyncsComponent extends RestTable implements OnInit {
private videoChannelsSyncService: VideoChannelSyncService,
private serverService: ServerService,
private notifier: Notifier,
private authService: AuthService
private authService: AuthService,
private videoChannelService: VideoChannelService
) {
super()
}
Expand All @@ -46,6 +47,12 @@ export class MyVideoChannelSyncsComponent extends RestTable implements OnInit {
label: $localize`Delete`,
iconName: 'delete',
handler: videoChannelSync => this.deleteSync(videoChannelSync)
},
{
label: $localize`Fully synchronize the channel`,
description: $localize`This fetches any missing videos on the local channel`,
iconName: 'refresh',
handler: videoChannelSync => this.fullySynchronize(videoChannelSync)
}
]
]
Expand Down Expand Up @@ -76,11 +83,11 @@ export class MyVideoChannelSyncsComponent extends RestTable implements OnInit {
return this.serverConfig.import.synchronization.enabled
}

deleteSync (videoChannelsSync: VideoChannelSync) {
this.videoChannelsSyncService.deleteSync(videoChannelsSync.id)
deleteSync (videoChannelSync: VideoChannelSync) {
this.videoChannelsSyncService.deleteSync(videoChannelSync.id)
.subscribe({
next: () => {
this.notifier.success($localize`Synchronization removed successfully for ${videoChannelsSync.channel.displayName}.`)
this.notifier.success($localize`Synchronization removed successfully for ${videoChannelSync.channel.displayName}.`)
this.reloadData()
},
error: (err) => {
Expand All @@ -89,6 +96,18 @@ export class MyVideoChannelSyncsComponent extends RestTable implements OnInit {
})
}

fullySynchronize (videoChannelSync: VideoChannelSync) {
this.videoChannelService.importVideos(videoChannelSync.channel.name, videoChannelSync.externalChannelUrl)
.subscribe({
next: () => {
this.notifier.success($localize`Full synchronization requested successfully for ${videoChannelSync.channel.displayName}.`)
},
error: (err) => {
this.error = err.message
}
})
}

getVideoChannelCreateLink () {
return '/my-library/video-channel-syncs/create'
}
Expand Down

0 comments on commit c8ab2bc

Please sign in to comment.