1
0
Fork 0

Fix video support field update

This commit is contained in:
Chocobozzz 2019-12-27 14:41:41 +01:00
parent e4a686b4a2
commit 6f79be110d
No known key found for this signature in database
GPG key ID: 583A612D890159BE

View file

@ -248,28 +248,32 @@ export class VideoEditComponent implements OnInit, OnDestroy {
.subscribe( .subscribe(
newChannelId => { newChannelId => {
const oldChannelId = parseInt(this.form.value[ 'channelId' ], 10) const oldChannelId = parseInt(this.form.value[ 'channelId' ], 10)
const currentSupport = this.form.value[ 'support' ]
// Not initialized yet // Not initialized yet
if (isNaN(newChannelId)) return if (isNaN(newChannelId)) return
const newChannel = this.userVideoChannels.find(c => c.id === newChannelId) const newChannel = this.userVideoChannels.find(c => c.id === newChannelId)
if (!newChannel) return if (!newChannel) return
// First time we set the channel? // Wait support field update
if (isNaN(oldChannelId)) return this.updateSupportField(newChannel.support) setTimeout(() => {
const oldChannel = this.userVideoChannels.find(c => c.id === oldChannelId) const currentSupport = this.form.value[ 'support' ]
if (!newChannel || !oldChannel) { // First time we set the channel?
console.error('Cannot find new or old channel.') if (isNaN(oldChannelId) && !currentSupport) return this.updateSupportField(newChannel.support)
return
}
// If the current support text is not the same than the old channel, the user updated it. const oldChannel = this.userVideoChannels.find(c => c.id === oldChannelId)
// We don't want the user to lose his text, so stop here if (!newChannel || !oldChannel) {
if (currentSupport && currentSupport !== oldChannel.support) return console.error('Cannot find new or old channel.')
return
}
// Update the support text with our new channel // If the current support text is not the same than the old channel, the user updated it.
this.updateSupportField(newChannel.support) // We don't want the user to lose his text, so stop here
if (currentSupport && currentSupport !== oldChannel.support) return
// Update the support text with our new channel
this.updateSupportField(newChannel.support)
})
} }
) )
} }