File tree 3 files changed +9
-12
lines changed
3 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,8 @@ async function oneTimeFetch(url) {
8
8
if ( url . length == 0 ) return false
9
9
10
10
let res = await fetch ( url )
11
- if ( res ) {
12
- return res . json ( )
13
- }
14
- else {
15
- return null
16
- }
11
+ let txt = await res . text ( )
12
+ return txt ?? null
17
13
}
18
14
19
15
function setupOneTimeFetchEvent ( ) {
Original file line number Diff line number Diff line change 1
1
import { ipcRenderer } from 'electron'
2
2
import * as events from 'shared/main-renderer-events'
3
3
4
- // get JSON data from an arbitrary endpoint
4
+ // get data from an arbitrary endpoint using main process fetch
5
5
export function oneTimeFetch ( url ) {
6
- return new Promise < JSON > ( ( resolve , reject ) => {
7
- ipcRenderer . send ( events . IPC_EVENT_oneTimeFetch , url )
8
- ipcRenderer . once ( events . IPC_EVENT_oneTimeFetch , ( event , res : JSON ) => {
6
+ return new Promise < string > ( ( resolve , reject ) => {
7
+ ipcRenderer . once ( events . IPC_EVENT_oneTimeFetch , ( event , res ) => {
9
8
resolve ( res )
10
9
} )
10
+ ipcRenderer . send ( events . IPC_EVENT_oneTimeFetch , url )
11
11
} )
12
12
}
Original file line number Diff line number Diff line change @@ -12,10 +12,11 @@ let defaultSponsorshipMessage = {
12
12
async function updateSponsorshipMessage ( ) {
13
13
// fetch the latest sponsorship message
14
14
try {
15
- let sponsorshipData = await App . oneTimeFetch (
15
+ let data = await App . oneTimeFetch (
16
16
'https://dl.daisy.org/tools/sponsorship.json'
17
17
)
18
- if ( sponsorshipData ) {
18
+ if ( data ) {
19
+ let sponsorshipData = JSON . parse ( data )
19
20
return sponsorshipData [ 'PipelineApp' ] [ 'en' ]
20
21
} else {
21
22
return defaultSponsorshipMessage
You can’t perform that action at this time.
0 commit comments