add button to compose a message to an arbitrary lxmf address

This commit is contained in:
liamcottle
2024-05-28 21:14:41 +12:00
parent 856f2bdadf
commit fd89b50da5
5 changed files with 95 additions and 10 deletions

View File

@@ -1,5 +1,7 @@
const { app, BrowserWindow } = require('electron');
const { app, BrowserWindow, ipcMain } = require('electron');
const electronPrompt = require('electron-prompt');
const { spawn } = require('child_process');
const fs = require('fs');
const path = require('node:path');
// remember main window
@@ -8,6 +10,19 @@ var mainWindow = null;
// remember child process for exe so we can kill it when app exits
var exeChildProcess = null;
// add support for showing a prompt window via ipc
ipcMain.handle('prompt', async(event, message) => {
return await electronPrompt({
title: message,
label: '',
value: '',
type: 'input',
inputAttrs: {
type: 'text',
},
});
});
function log(message) {
// make sure main window exists
@@ -44,7 +59,12 @@ app.whenReady().then(async () => {
await mainWindow.loadFile(path.join(__dirname, 'loading.html'));
// find path to python/cxfreeze reticulum webchat executable
const exe = path.join(__dirname, 'build/exe/ReticulumWebChat');
var exe = path.join(__dirname, 'build/exe/ReticulumWebChat');
// if dist exe doesn't exist, check local build
if(!fs.existsSync(exe)){
exe = path.join(__dirname, '..', 'build/exe/ReticulumWebChat');
}
try {

View File

@@ -1,4 +1,11 @@
const { ipcRenderer } = require('electron');
const { ipcRenderer, contextBridge } = require('electron');
// forward logs received from exe to web console
ipcRenderer.on('log', (event, message) => console.log(message));
// add support for using "prompt" in electron browser window
contextBridge.exposeInMainWorld('electron', {
prompt: async function(message) {
return await ipcRenderer.invoke('prompt', message);
},
});