Files
2026-01-21 12:19:35 +01:00

57 lines
2.1 KiB
JavaScript

/*
This file contains the ipc communication methos between the ui and the gui
*/
const { contextBridge, ipcRenderer, webUtils } = require('electron')
try {
//For file lookup on drop
contextBridge.exposeInMainWorld("explorer", {
onFileDrop: (file) => webUtils.getPathForFile(file)
})
//For sending the specifications to the main
contextBridge.exposeInMainWorld("submit", {
submit: (meeting_specifications) => { ipcRenderer.send("file_submit", meeting_specifications) }
})
//For file lookup on search
contextBridge.exposeInMainWorld("electronAPI", {
getFilePath: (file) => { return webUtils.getPathForFile(file) }
})
//Gets all information from the main process
contextBridge.exposeInMainWorld("onStartup", {
getModuleNames: () => ipcRenderer.invoke('get-module-names')
})
//Calls from the main process regarding the progress
contextBridge.exposeInMainWorld('electron', {
progress: (callback) => ipcRenderer.on('progress', callback)
})
//For getting the speaker audios and names from the main
contextBridge.exposeInMainWorld('audios', {
speakerAudios: (callback) => ipcRenderer.on('speakerAudios', callback)
})
//For sending the new speaker names to the main process
contextBridge.exposeInMainWorld("submitSpeaker", {
speaker_submit: (speaker_names) => { ipcRenderer.send("speaker_submit", speaker_names) }
})
//For downloading the finished document
contextBridge.exposeInMainWorld("download", {
file_download: () => { ipcRenderer.send("file_download") }
})
//documenttypes
contextBridge.exposeInMainWorld('api', {
getTxtFiles: () => ipcRenderer.invoke('get-txt-files'),
saveTxtFile: (name, content) =>
ipcRenderer.invoke('save-txt-file', name, content),
readTxtFile: (fileName) =>
ipcRenderer.invoke('read-txt-file', fileName),
deleteTxtFile: (fileName) =>
ipcRenderer.invoke('delete-txt-file', fileName)
});
ipcRenderer.on("error", (event, err) => { alert(err) })
} catch (error) {
console.log("Error in preload.js");
}