Update channel.ts

This commit is contained in:
freearhey 2023-10-12 09:06:46 +03:00
parent 454ed7f5e8
commit 7ab66d6c7f

View file

@ -75,11 +75,18 @@ export class Channel {
this.logo = logo
}
update(data: { [key: string]: string }) {
for (const key in data) {
if (this[key] && data[key]) {
this[key] = data[key]
}
data() {
const { ...object } = this
return object
}
merge(channel: Channel) {
const data: { [key: string]: string | string[] | boolean } = channel.data()
for (const prop in data) {
if (data[prop] === undefined) continue
if (Array.isArray(data[prop]) && !data[prop].length) continue
this[prop] = data[prop]
}
}
}