Skip to content

Commit 560d369

Browse files
committed
A few small fixes
1 parent c369fb6 commit 560d369

File tree

7 files changed

+36
-8
lines changed

7 files changed

+36
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Current version: **0.1.3**
1+
Current version: **0.1.5**
22

33
# About
44
This allows you to fetch EPG data for linear streaming services such as Peacock and ABC, and transforms them so you can use them with [chrome-capture-for-channels](https://github.com/fancybits/chrome-capture-for-channels).

index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ import {Script} from './views/Script';
2929

3030
import {version} from './package.json';
3131

32+
const PROVIDER_MAP = {
33+
ABC: abcHandler,
34+
Peacock: peacockHandler,
35+
} as const;
36+
3237
const notFound = (c: Context<BlankEnv, '', BlankInput>) => c.text('404 not found', 404, {});
3338

3439
const shutDown = () => process.exit(0);
@@ -116,6 +121,10 @@ app.put('/provider/toggle/:provider', async c => {
116121

117122
await miscDbHandler.setCanUseNetwork(provider.toLowerCase(), enabled);
118123

124+
if (enabled) {
125+
await PROVIDER_MAP[provider].getSchedule();
126+
}
127+
119128
const regex = new RegExp(provider, 'i');
120129
const providerChannels = await db.channels.find<IChannel>({from: {$regex: regex}});
121130

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cc-epg",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"description": "",
55
"scripts": {
66
"start": "ts-node index.tsx",

services/misc-db.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { db } from "./database";
2-
import { IMisc } from "./shared-interfaces";
1+
import {db} from './database';
2+
import {IMisc} from './shared-interfaces';
33

44
export const CC_PREFIX = 'http://localhost:5589';
55

@@ -24,9 +24,9 @@ class MiscDB {
2424
const networkObj = await db.misc.findOne<IMisc>({key: network});
2525

2626
if (!networkObj) {
27-
await db.misc.insert({key: network, value: true});
27+
await db.misc.insert({key: network, value: false});
2828

29-
return true;
29+
return false;
3030
}
3131

3232
return networkObj.value as boolean;

views/Provider.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ export const Provider: FC<IProviderProps> = ({name, channels, enabled}) => {
2222
name="provider-enabled"
2323
type="checkbox"
2424
role="switch"
25+
id={`${name}-toggle`}
2526
checked={enabled ? true : false}
2627
data-enabled={enabled ? 'true' : 'false'}
2728
/>
2829
Enabled
2930
</label>
3031
</fieldset>
3132
</div>
33+
<div aria-busy="true" id={`${name}-loading`} class="hide-loading" />
3234
{enabled && (
3335
<table class="striped">
3436
<thead>
@@ -65,6 +67,19 @@ export const Provider: FC<IProviderProps> = ({name, channels, enabled}) => {
6567
</table>
6668
)}
6769
</section>
70+
<script
71+
dangerouslySetInnerHTML={{
72+
__html: `
73+
var toggle = document.getElementById('${name}-toggle');
74+
75+
if (toggle) {
76+
toggle.addEventListener('htmx:beforeRequest', function() {
77+
document.querySelector('#${name}-loading').classList.remove('hide-loading');
78+
});
79+
}
80+
`,
81+
}}
82+
/>
6883
<hr />
6984
</div>
7085
);

views/Style.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ export const Style: FC = () => (
1212
align-items: stretch;
1313
padding-right: 1rem;
1414
}
15+
.hide-loading {
16+
display: none;
17+
height: 0;
18+
}
1519
`}</style>
1620
);

0 commit comments

Comments
 (0)