mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-12-05 06:10:01 -05:00
Compare commits
31 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6c56ae39c | ||
|
|
993786673b | ||
|
|
a9f925975e | ||
|
|
3190f3e5a6 | ||
|
|
df5aea94ea | ||
|
|
7e88277abd | ||
|
|
45f89a8fca | ||
|
|
ecb1efc5a4 | ||
|
|
f9d930ed87 | ||
|
|
db26474273 | ||
|
|
b36dcddfcd | ||
|
|
3baa5cd19a | ||
|
|
6b45c3239d | ||
|
|
e49df24360 | ||
|
|
97be61e36c | ||
|
|
946d113e69 | ||
|
|
42db0fdb23 | ||
|
|
2c6d316801 | ||
|
|
4ef57593e9 | ||
|
|
011876bec5 | ||
|
|
e3dae8aea9 | ||
|
|
c2ee9be39a | ||
|
|
002360399c | ||
|
|
c9f4ef64c1 | ||
|
|
ffe2cb884d | ||
|
|
d6847d262a | ||
|
|
65df111b87 | ||
|
|
747236ae8b | ||
|
|
4e55006084 | ||
|
|
dcaffe2594 | ||
|
|
094f6cb5ec |
17 changed files with 139 additions and 57 deletions
7
.github/workflows/build.yml
vendored
7
.github/workflows/build.yml
vendored
|
|
@ -45,7 +45,10 @@ jobs:
|
||||||
artifacts: "dist/*-win-installer.exe,dist/*-win-portable.exe"
|
artifacts: "dist/*-win-installer.exe,dist/*-win-portable.exe"
|
||||||
|
|
||||||
build_mac:
|
build_mac:
|
||||||
runs-on: macos-13
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ macos-15, macos-15-intel ]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -80,7 +83,7 @@ jobs:
|
||||||
replacesArtifacts: true
|
replacesArtifacts: true
|
||||||
omitDraftDuringUpdate: true
|
omitDraftDuringUpdate: true
|
||||||
omitNameDuringUpdate: true
|
omitNameDuringUpdate: true
|
||||||
artifacts: "dist/*-mac.dmg"
|
artifacts: "dist/*-mac-*.dmg"
|
||||||
|
|
||||||
build_linux:
|
build_linux:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,27 @@ ipcMain.handle('alert', async(event, message) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// add support for showing a confirm window via ipc
|
||||||
|
ipcMain.handle('confirm', async(event, message) => {
|
||||||
|
|
||||||
|
// show confirm dialog
|
||||||
|
const result = await dialog.showMessageBox(mainWindow, {
|
||||||
|
type: "question",
|
||||||
|
title: "Confirm",
|
||||||
|
message: message,
|
||||||
|
cancelId: 0, // esc key should press cancel button
|
||||||
|
defaultId: 1, // enter key should press ok button
|
||||||
|
buttons: [
|
||||||
|
"Cancel", // 0
|
||||||
|
"OK", // 1
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// check if user clicked OK
|
||||||
|
return result.response === 1;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// add support for showing a prompt window via ipc
|
// add support for showing a prompt window via ipc
|
||||||
ipcMain.handle('prompt', async(event, message) => {
|
ipcMain.handle('prompt', async(event, message) => {
|
||||||
return await electronPrompt({
|
return await electronPrompt({
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,11 @@ contextBridge.exposeInMainWorld('electron', {
|
||||||
return await ipcRenderer.invoke('alert', message);
|
return await ipcRenderer.invoke('alert', message);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// show a confirm dialog in electron browser window, this fixes a bug where confirm breaks input fields on windows
|
||||||
|
confirm: async function(message) {
|
||||||
|
return await ipcRenderer.invoke('confirm', message);
|
||||||
|
},
|
||||||
|
|
||||||
// add support for using "prompt" in electron browser window
|
// add support for using "prompt" in electron browser window
|
||||||
prompt: async function(message) {
|
prompt: async function(message) {
|
||||||
return await ipcRenderer.invoke('prompt', message);
|
return await ipcRenderer.invoke('prompt', message);
|
||||||
|
|
|
||||||
41
meshchat.py
41
meshchat.py
|
|
@ -4,6 +4,7 @@ import argparse
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
@ -944,6 +945,7 @@ class ReticulumMeshChat:
|
||||||
"version": self.get_app_version(),
|
"version": self.get_app_version(),
|
||||||
"lxmf_version": LXMF.__version__,
|
"lxmf_version": LXMF.__version__,
|
||||||
"rns_version": RNS.__version__,
|
"rns_version": RNS.__version__,
|
||||||
|
"python_version": platform.python_version(),
|
||||||
"storage_path": self.storage_path,
|
"storage_path": self.storage_path,
|
||||||
"database_path": self.database_path,
|
"database_path": self.database_path,
|
||||||
"database_file_size": os.path.getsize(self.database_path),
|
"database_file_size": os.path.getsize(self.database_path),
|
||||||
|
|
@ -978,6 +980,10 @@ class ReticulumMeshChat:
|
||||||
@routes.post("/api/v1/reticulum/enable-transport")
|
@routes.post("/api/v1/reticulum/enable-transport")
|
||||||
async def index(request):
|
async def index(request):
|
||||||
|
|
||||||
|
# ensure reticulum section exists
|
||||||
|
if "reticulum" not in self.reticulum.config:
|
||||||
|
self.reticulum.config["reticulum"] = {}
|
||||||
|
|
||||||
# enable transport mode
|
# enable transport mode
|
||||||
self.reticulum.config["reticulum"]["enable_transport"] = True
|
self.reticulum.config["reticulum"]["enable_transport"] = True
|
||||||
self.reticulum.config.write()
|
self.reticulum.config.write()
|
||||||
|
|
@ -990,6 +996,10 @@ class ReticulumMeshChat:
|
||||||
@routes.post("/api/v1/reticulum/disable-transport")
|
@routes.post("/api/v1/reticulum/disable-transport")
|
||||||
async def index(request):
|
async def index(request):
|
||||||
|
|
||||||
|
# ensure reticulum section exists
|
||||||
|
if "reticulum" not in self.reticulum.config:
|
||||||
|
self.reticulum.config["reticulum"] = {}
|
||||||
|
|
||||||
# disable transport mode
|
# disable transport mode
|
||||||
self.reticulum.config["reticulum"]["enable_transport"] = False
|
self.reticulum.config["reticulum"]["enable_transport"] = False
|
||||||
self.reticulum.config.write()
|
self.reticulum.config.write()
|
||||||
|
|
@ -1723,6 +1733,10 @@ class ReticulumMeshChat:
|
||||||
if "transport_id" in interface_stats:
|
if "transport_id" in interface_stats:
|
||||||
interface_stats["transport_id"] = interface_stats["transport_id"].hex()
|
interface_stats["transport_id"] = interface_stats["transport_id"].hex()
|
||||||
|
|
||||||
|
# ensure network_id is hex as json_response can't serialize bytes
|
||||||
|
if "network_id" in interface_stats and interface_stats["network_id"] is not None:
|
||||||
|
interface_stats["network_id"] = interface_stats["network_id"].hex()
|
||||||
|
|
||||||
# ensure probe_responder is hex as json_response can't serialize bytes
|
# ensure probe_responder is hex as json_response can't serialize bytes
|
||||||
if "probe_responder" in interface_stats and interface_stats["probe_responder"] is not None:
|
if "probe_responder" in interface_stats and interface_stats["probe_responder"] is not None:
|
||||||
interface_stats["probe_responder"] = interface_stats["probe_responder"].hex()
|
interface_stats["probe_responder"] = interface_stats["probe_responder"].hex()
|
||||||
|
|
@ -2038,6 +2052,9 @@ class ReticulumMeshChat:
|
||||||
# called when web app has started
|
# called when web app has started
|
||||||
async def on_startup(app):
|
async def on_startup(app):
|
||||||
|
|
||||||
|
# remember main event loop
|
||||||
|
AsyncUtils.set_main_loop(asyncio.get_event_loop())
|
||||||
|
|
||||||
# auto launch web browser
|
# auto launch web browser
|
||||||
if launch_browser:
|
if launch_browser:
|
||||||
try:
|
try:
|
||||||
|
|
@ -3022,10 +3039,11 @@ class ReticulumMeshChat:
|
||||||
has_delivered = lxmf_message.state == LXMF.LXMessage.DELIVERED
|
has_delivered = lxmf_message.state == LXMF.LXMessage.DELIVERED
|
||||||
has_propagated = lxmf_message.state == LXMF.LXMessage.SENT and lxmf_message.method == LXMF.LXMessage.PROPAGATED
|
has_propagated = lxmf_message.state == LXMF.LXMessage.SENT and lxmf_message.method == LXMF.LXMessage.PROPAGATED
|
||||||
has_failed = lxmf_message.state == LXMF.LXMessage.FAILED
|
has_failed = lxmf_message.state == LXMF.LXMessage.FAILED
|
||||||
|
has_rejected = lxmf_message.state == LXMF.LXMessage.REJECTED
|
||||||
is_cancelled = lxmf_message.state == LXMF.LXMessage.CANCELLED
|
is_cancelled = lxmf_message.state == LXMF.LXMessage.CANCELLED
|
||||||
|
|
||||||
# check if we should stop updating
|
# check if we should stop updating
|
||||||
if has_delivered or has_propagated or has_failed or is_cancelled:
|
if has_delivered or has_propagated or has_failed or has_rejected or is_cancelled:
|
||||||
should_update_message = False
|
should_update_message = False
|
||||||
|
|
||||||
# handle an announce received from reticulum, for an audio call address
|
# handle an announce received from reticulum, for an audio call address
|
||||||
|
|
@ -3552,12 +3570,31 @@ class NomadnetFileDownloader(NomadnetDownloader):
|
||||||
self.on_file_download_success(file_name, file_data)
|
self.on_file_download_success(file_name, file_data)
|
||||||
return
|
return
|
||||||
|
|
||||||
# original response format
|
# check for list response with bytes in position 0, and metadata dict in position 1
|
||||||
|
# e.g: [file_bytes, {name: "filename.ext"}]
|
||||||
|
if isinstance(response, list) and isinstance(response[1], dict):
|
||||||
|
|
||||||
|
file_data: bytes = response[0]
|
||||||
|
metadata: dict = response[1]
|
||||||
|
|
||||||
|
# get file name from metadata
|
||||||
|
file_name = "downloaded_file"
|
||||||
|
if metadata is not None and "name" in metadata:
|
||||||
|
file_path = metadata["name"].decode("utf-8")
|
||||||
|
file_name = os.path.basename(file_path)
|
||||||
|
|
||||||
|
self.on_file_download_success(file_name, file_data)
|
||||||
|
return
|
||||||
|
|
||||||
|
# try using original response format
|
||||||
# unsure if this is actually used anymore now that a buffered reader is provided
|
# unsure if this is actually used anymore now that a buffered reader is provided
|
||||||
# have left here just in case...
|
# have left here just in case...
|
||||||
|
try:
|
||||||
file_name: str = response[0]
|
file_name: str = response[0]
|
||||||
file_data: bytes = response[1]
|
file_data: bytes = response[1]
|
||||||
self.on_file_download_success(file_name, file_data)
|
self.on_file_download_success(file_name, file_data)
|
||||||
|
except:
|
||||||
|
self.on_download_failure("unsupported_response")
|
||||||
|
|
||||||
# page download failed, send error to provided callback
|
# page download failed, send error to provided callback
|
||||||
def on_download_failure(self, failure_reason):
|
def on_download_failure(self, failure_reason):
|
||||||
|
|
|
||||||
13
package-lock.json
generated
13
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "reticulum-meshchat",
|
"name": "reticulum-meshchat",
|
||||||
"version": "2.2.0",
|
"version": "2.4.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "reticulum-meshchat",
|
"name": "reticulum-meshchat",
|
||||||
"version": "2.2.0",
|
"version": "2.4.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mdi/js": "^7.4.47",
|
"@mdi/js": "^7.4.47",
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
"click-outside-vue3": "^4.0.1",
|
"click-outside-vue3": "^4.0.1",
|
||||||
"compressorjs": "^1.2.1",
|
"compressorjs": "^1.2.1",
|
||||||
"electron-prompt": "^1.7.0",
|
"electron-prompt": "^1.7.0",
|
||||||
"micron-parser": "^1.0.2",
|
"micron-parser": "^1.1.0",
|
||||||
"mitt": "^3.0.1",
|
"mitt": "^3.0.1",
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
"postcss": "^8.4.49",
|
"postcss": "^8.4.49",
|
||||||
|
|
@ -4184,9 +4184,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/micron-parser": {
|
"node_modules/micron-parser": {
|
||||||
"version": "1.0.2",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/micron-parser/-/micron-parser-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/micron-parser/-/micron-parser-1.1.0.tgz",
|
||||||
"integrity": "sha512-lYrEolylOUXeSISYrPRW/ZZAH1dpZRyTJ0VzQIA4cWJy0yNCXUUs+ujuAwV2OYlAPH8tCE1Z22+zg04Ilp/JWg==",
|
"integrity": "sha512-v1CXQkmuxRDz6N0EWcUhPq+FzZ4RBXPO7zEuhrRIBsnOZBjXSZosSRYQyU53DNAPL5SR+xRRFDCGhvR0cexf8A==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dompurify": "*"
|
"dompurify": "*"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "reticulum-meshchat",
|
"name": "reticulum-meshchat",
|
||||||
"version": "2.2.0",
|
"version": "2.4.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "electron/main.js",
|
"main": "electron/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
"mac": {
|
"mac": {
|
||||||
"target": "dmg",
|
"target": "dmg",
|
||||||
"identity": null,
|
"identity": null,
|
||||||
"artifactName": "ReticulumMeshChat-v${version}-${os}.${ext}",
|
"artifactName": "ReticulumMeshChat-v${version}-${os}-${arch}.${ext}",
|
||||||
"extendInfo": {
|
"extendInfo": {
|
||||||
"NSMicrophoneUsageDescription": "Microphone access is only needed for Audio Calls",
|
"NSMicrophoneUsageDescription": "Microphone access is only needed for Audio Calls",
|
||||||
"com.apple.security.device.audio-input": true
|
"com.apple.security.device.audio-input": true
|
||||||
|
|
@ -102,7 +102,7 @@
|
||||||
"click-outside-vue3": "^4.0.1",
|
"click-outside-vue3": "^4.0.1",
|
||||||
"compressorjs": "^1.2.1",
|
"compressorjs": "^1.2.1",
|
||||||
"electron-prompt": "^1.7.0",
|
"electron-prompt": "^1.7.0",
|
||||||
"micron-parser": "^1.0.2",
|
"micron-parser": "^1.1.0",
|
||||||
"mitt": "^3.0.1",
|
"mitt": "^3.0.1",
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
"postcss": "^8.4.49",
|
"postcss": "^8.4.49",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
aiohttp>=3.9.5
|
aiohttp>=3.13.3
|
||||||
cx_freeze>=7.0.0
|
cx_freeze>=7.0.0
|
||||||
lxmf>=0.8.0
|
lxmf>=1.0.1
|
||||||
peewee>=3.17.3
|
peewee>=3.18.1,<4.0.0
|
||||||
rns>=1.0.0
|
rns>=1.3.7
|
||||||
websockets>=14.2
|
websockets>=16.0
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from typing import Coroutine
|
||||||
|
|
||||||
|
|
||||||
class AsyncUtils:
|
class AsyncUtils:
|
||||||
|
|
||||||
# this method allows running the provided async coroutine from within a sync function
|
# remember main loop
|
||||||
# it will run the async function on the existing event loop if available, otherwise it will start a new event loop
|
main_loop: asyncio.AbstractEventLoop | None = None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run_async(coroutine):
|
def set_main_loop(loop: asyncio.AbstractEventLoop):
|
||||||
|
AsyncUtils.main_loop = loop
|
||||||
|
|
||||||
# attempt to get existing event loop
|
# this method allows running the provided async coroutine from within a sync function
|
||||||
existing_event_loop = None
|
# it will run the async function on the main event loop if possible, otherwise it logs a warning
|
||||||
try:
|
@staticmethod
|
||||||
existing_event_loop = asyncio.get_running_loop()
|
def run_async(coroutine: Coroutine):
|
||||||
except RuntimeError:
|
|
||||||
# 'RuntimeError: no running event loop'
|
|
||||||
pass
|
|
||||||
|
|
||||||
# if there is an existing event loop running, submit the coroutine to that loop
|
# run provided coroutine on main event loop, ensuring thread safety
|
||||||
if existing_event_loop and existing_event_loop.is_running():
|
if AsyncUtils.main_loop and AsyncUtils.main_loop.is_running():
|
||||||
existing_event_loop.create_task(coroutine)
|
asyncio.run_coroutine_threadsafe(coroutine, AsyncUtils.main_loop)
|
||||||
return
|
return
|
||||||
|
|
||||||
# otherwise start a new event loop to run the coroutine
|
# main event loop not running...
|
||||||
asyncio.run(coroutine)
|
print("WARNING: Main event loop not available. Could not schedule task.")
|
||||||
|
|
|
||||||
|
|
@ -448,7 +448,7 @@ export default {
|
||||||
|
|
||||||
// ask to stop syncing if already syncing
|
// ask to stop syncing if already syncing
|
||||||
if(this.isSyncingPropagationNode){
|
if(this.isSyncingPropagationNode){
|
||||||
if(confirm("Are you sure you want to stop syncing?")){
|
if(await DialogUtils.confirm("Are you sure you want to stop syncing?")){
|
||||||
await this.stopSyncingPropagationNode();
|
await this.stopSyncingPropagationNode();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -529,7 +529,7 @@ export default {
|
||||||
async hangupAllCalls() {
|
async hangupAllCalls() {
|
||||||
|
|
||||||
// confirm user wants to hang up calls
|
// confirm user wants to hang up calls
|
||||||
if(!confirm("Are you sure you want to hang up all incoming and outgoing calls?")){
|
if(!await DialogUtils.confirm("Are you sure you want to hang up all incoming and outgoing calls?")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
<div class="mr-auto">
|
<div class="mr-auto">
|
||||||
<div>Versions</div>
|
<div>Versions</div>
|
||||||
<div class="text-sm text-gray-700 dark:text-zinc-400">
|
<div class="text-sm text-gray-700 dark:text-zinc-400">
|
||||||
MeshChat v{{ appInfo.version }} • RNS v{{ appInfo.rns_version }} • LXMF v{{ appInfo.lxmf_version }}
|
MeshChat v{{ appInfo.version }} • RNS v{{ appInfo.rns_version }} • LXMF v{{ appInfo.lxmf_version }} • Python v{{ appInfo.python_version }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden sm:block mx-2 my-auto">
|
<div class="hidden sm:block mx-2 my-auto">
|
||||||
|
|
|
||||||
|
|
@ -259,6 +259,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import protobuf from "protobufjs";
|
import protobuf from "protobufjs";
|
||||||
|
import DialogUtils from "../../js/DialogUtils";
|
||||||
export default {
|
export default {
|
||||||
name: 'CallPage',
|
name: 'CallPage',
|
||||||
data() {
|
data() {
|
||||||
|
|
@ -488,7 +489,7 @@ export default {
|
||||||
async hangupCall(callHash) {
|
async hangupCall(callHash) {
|
||||||
|
|
||||||
// confirm user wants to hang up call
|
// confirm user wants to hang up call
|
||||||
if(!confirm("Are you sure you want to hang up this call?")){
|
if(!await DialogUtils.confirm("Are you sure you want to hang up this call?")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -681,7 +682,7 @@ export default {
|
||||||
async deleteCall(callHash) {
|
async deleteCall(callHash) {
|
||||||
|
|
||||||
// confirm user wants to delete call
|
// confirm user wants to delete call
|
||||||
if(!confirm("Are you sure you want to delete this call?")){
|
if(!await DialogUtils.confirm("Are you sure you want to delete this call?")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -701,7 +702,7 @@ export default {
|
||||||
async clearCallHistory() {
|
async clearCallHistory() {
|
||||||
|
|
||||||
// confirm user wants to clear call history
|
// confirm user wants to clear call history
|
||||||
if(!confirm("Are you sure you want to clear your call history?")){
|
if(!await DialogUtils.confirm("Are you sure you want to clear your call history?")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ export default {
|
||||||
async deleteInterface(interfaceName) {
|
async deleteInterface(interfaceName) {
|
||||||
|
|
||||||
// ask user to confirm deleting conversation history
|
// ask user to confirm deleting conversation history
|
||||||
if(!confirm("Are you sure you want to delete this interface? This can not be undone!")){
|
if(!await DialogUtils.confirm("Are you sure you want to delete this interface? This can not be undone!")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ export default {
|
||||||
async onDeleteMessageHistory() {
|
async onDeleteMessageHistory() {
|
||||||
|
|
||||||
// ask user to confirm deleting conversation history
|
// ask user to confirm deleting conversation history
|
||||||
if(!confirm("Are you sure you want to delete all messages in this conversation? This can not be undone!")){
|
if(!await DialogUtils.confirm("Are you sure you want to delete all messages in this conversation? This can not be undone!")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -997,7 +997,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// ask user to confirm deleting message
|
// ask user to confirm deleting message
|
||||||
if(shouldConfirm && !confirm("Are you sure you want to delete this message? This can not be undone!")){
|
if(shouldConfirm && !await DialogUtils.confirm("Are you sure you want to delete this message? This can not be undone!")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1056,7 +1056,11 @@ export default {
|
||||||
if(this.newMessageImage){
|
if(this.newMessageImage){
|
||||||
imageTotalSize = this.newMessageImage.size;
|
imageTotalSize = this.newMessageImage.size;
|
||||||
fields["image"] = {
|
fields["image"] = {
|
||||||
// Reticulum sends image type as "jpg" or "png" and not "image/jpg" or "image/png"
|
// Reticulum sends image type as "jpg", "png", "webp" etc and not "image/jpg" or "image/png"
|
||||||
|
// From memory, Sideband would not display images if the image type has the "image/" prefix
|
||||||
|
// https://github.com/markqvist/Sideband/blob/354fb08297835eab04ac69d15081a18baf0583ac/docs/example_plugins/view.py#L78
|
||||||
|
// https://github.com/markqvist/Sideband/blob/354fb08297835eab04ac69d15081a18baf0583ac/sbapp/main.py#L1900
|
||||||
|
// https://github.com/markqvist/Sideband/blob/354fb08297835eab04ac69d15081a18baf0583ac/sbapp/ui/messages.py#L783
|
||||||
"image_type": this.newMessageImage.type.replace("image/", ""),
|
"image_type": this.newMessageImage.type.replace("image/", ""),
|
||||||
"image_bytes": Utils.arrayBufferToBase64(await this.newMessageImage.arrayBuffer()),
|
"image_bytes": Utils.arrayBufferToBase64(await this.newMessageImage.arrayBuffer()),
|
||||||
};
|
};
|
||||||
|
|
@ -1078,7 +1082,7 @@ export default {
|
||||||
|
|
||||||
// ask user if they still want to send message if it may be rejected by sender
|
// ask user if they still want to send message if it may be rejected by sender
|
||||||
if(totalMessageSize > 1000 * 900){ // actual limit in LXMF Router is 1mb
|
if(totalMessageSize > 1000 * 900){ // actual limit in LXMF Router is 1mb
|
||||||
if(!confirm(`Your message exceeds 900KB (It's ${this.formatBytes(totalMessageSize)}). It may be rejected by the recipient unless they have increased their delivery limit. Do you want to try sending anyway?`)){
|
if(!await DialogUtils.confirm(`Your message exceeds 900KB (It's ${this.formatBytes(totalMessageSize)}). It may be rejected by the recipient unless they have increased their delivery limit. Do you want to try sending anyway?`)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1209,10 +1213,10 @@ export default {
|
||||||
clearFileInput: function() {
|
clearFileInput: function() {
|
||||||
this.$refs["file-input"].value = null;
|
this.$refs["file-input"].value = null;
|
||||||
},
|
},
|
||||||
removeImageAttachment: function() {
|
async removeImageAttachment() {
|
||||||
|
|
||||||
// ask user to confirm removing image attachment
|
// ask user to confirm removing image attachment
|
||||||
if(!confirm("Are you sure you want to remove this image attachment?")){
|
if(!await DialogUtils.confirm("Are you sure you want to remove this image attachment?")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1244,7 +1248,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ask user to confirm recording new audio attachment, if an existing audio attachment exists
|
// ask user to confirm recording new audio attachment, if an existing audio attachment exists
|
||||||
if(this.newMessageAudio && !confirm("An audio recording is already attached. A new recording will replace it. Do you want to continue?")){
|
if(this.newMessageAudio && !await DialogUtils.confirm("An audio recording is already attached. A new recording will replace it. Do you want to continue?")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1386,10 +1390,10 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
removeAudioAttachment: function() {
|
async removeAudioAttachment() {
|
||||||
|
|
||||||
// ask user to confirm removing audio attachment
|
// ask user to confirm removing audio attachment
|
||||||
if(!confirm("Are you sure you want to remove this audio attachment?")){
|
if(!await DialogUtils.confirm("Are you sure you want to remove this audio attachment?")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -862,10 +862,10 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
onRemoveFavourite: function(favourite) {
|
async onRemoveFavourite(favourite) {
|
||||||
|
|
||||||
// ask user to confirm
|
// ask user to confirm
|
||||||
if(!confirm("Are you sure you want to remove this favourite?")){
|
if(!await DialogUtils.confirm("Are you sure you want to remove this favourite?")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -911,7 +911,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// ask user to confirm
|
// ask user to confirm
|
||||||
if(!confirm("Are you sure you want to identify yourself to this NomadNetwork Node? The page will reload after your identity has been sent.")){
|
if(!await DialogUtils.confirm("Are you sure you want to identify yourself to this NomadNetwork Node? The page will reload after your identity has been sent.")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// confirm user wants to update their icon
|
// confirm user wants to update their icon
|
||||||
if(!confirm("Are you sure you want to set this as your profile icon?")){
|
if(!await DialogUtils.confirm("Are you sure you want to set this as your profile icon?")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,7 +160,7 @@ export default {
|
||||||
async removeProfileIcon() {
|
async removeProfileIcon() {
|
||||||
|
|
||||||
// confirm user wants to remove their icon
|
// confirm user wants to remove their icon
|
||||||
if(!confirm("Are you sure you want to remove your profile icon? Anyone that has already received it will continue to see it until you send them a new icon.")){
|
if(!await DialogUtils.confirm("Are you sure you want to remove your profile icon? Anyone that has already received it will continue to see it until you send them a new icon.")){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,16 @@ class DialogUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static confirm(message) {
|
||||||
|
if(window.electron){
|
||||||
|
// running inside electron, use ipc confirm
|
||||||
|
return window.electron.confirm(message);
|
||||||
|
} else {
|
||||||
|
// running inside normal browser, use browser alert
|
||||||
|
return window.confirm(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static async prompt(message) {
|
static async prompt(message) {
|
||||||
if(window.electron){
|
if(window.electron){
|
||||||
// running inside electron, use ipc prompt
|
// running inside electron, use ipc prompt
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue