-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathpreload.js
20 lines (19 loc) · 871 Bytes
/
preload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld('api', {
findCity: () => ipcRenderer.invoke('find-city'),
send: (channel, data) => {
const validChannels = ['settings', 'getNewTimingsTable', 'setPrayerTray', 'notification', 'apply-settings', 'close-app', 'invalidWarning']
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, data)
}
},
receive: (channel, func) => {
const validChannels = ['init-data', 'setNewTimingsTable', 'update-data']
if (validChannels.includes(channel)) {
ipcRenderer.on(channel, (event, ...args) => func(...args))
}
},
toggleTheme: (theme) => ipcRenderer.invoke('theme:toggle', theme),
toggleLanguage: (...args) => ipcRenderer.invoke('language:toggle', ...args),
loadTranslations: (keys) => ipcRenderer.invoke('load-translations', keys)
})