Skip to content

Commit

Permalink
fix: epg function to compare channel ids
Browse files Browse the repository at this point in the history
  • Loading branch information
4gray committed Jan 24, 2022
1 parent 98ff7f4 commit c7de39e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions epg-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ const ipcRenderer = electron.ipcRenderer;
const zlib = require('zlib');
const parser = require('epg-parser');
const axios = require('axios');
import { EpgChannel } from './src/app/player/models/epg-channel.model';
import { EpgProgram } from './src/app/player/models/epg-program.model';
import {
EPG_ERROR,
EPG_FETCH,
EPG_FETCH_DONE,
EPG_GET_PROGRAM,
EPG_GET_PROGRAM_DONE,
} from './shared/ipc-commands';
import { EpgChannel } from './src/app/player/models/epg-channel.model';
import { EpgProgram } from './src/app/player/models/epg-program.model';

// EPG data store
let EPG_DATA: { channels: EpgChannel[]; programs: EpgProgram[] };
Expand Down Expand Up @@ -76,13 +76,14 @@ ipcRenderer.on(EPG_GET_PROGRAM, (event, args) => {
const tvgId = args.channel.tvg?.id;
if (!EPG_DATA || !EPG_DATA.channels) return;
const foundChannel = EPG_DATA?.channels?.find((epgChannel) => {
if (tvgId) {
if (tvgId === epgChannel.id) {
return epgChannel;
}
if (tvgId && tvgId === epgChannel.id) {
return epgChannel;
} else if (
epgChannel.name.find((nameObj) => {
if (nameObj.value && nameObj.value.trim() === channelName.trim())
if (
nameObj.value &&
nameObj.value.trim() === channelName.trim()
)
return nameObj;
})
) {
Expand All @@ -98,6 +99,7 @@ ipcRenderer.on(EPG_GET_PROGRAM, (event, args) => {
payload: { channel: foundChannel, items: programs },
});
} else {
console.log('EPG program for the channel was not found...');
ipcRenderer.send(EPG_GET_PROGRAM_DONE, {
payload: { channel: {}, items: [] },
});
Expand Down

1 comment on commit c7de39e

@vercel
Copy link

@vercel vercel bot commented on c7de39e Jan 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.