Fix mobile assistant image downloads
Some checks failed
Forgejo Android APK / Build signed APK (push) Has been cancelled

This commit is contained in:
Daniel 2026-05-13 16:04:06 +02:00
parent 629dea808e
commit 2cef65fb1f
6 changed files with 35 additions and 15 deletions

View file

@ -9,8 +9,8 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
// Version values below are overwritten by scripts/release.sh from
// the root package.json. versionCode auto-increments per release.
versionCode 714003
versionName "7.14.3"
versionCode 714007
versionName "7.14.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.

View file

@ -1,12 +1,12 @@
{
"name": "pedscribe-mobile",
"version": "7.14.3",
"version": "7.14.7",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "pedscribe-mobile",
"version": "7.14.3",
"version": "7.14.7",
"dependencies": {
"@aparajita/capacitor-biometric-auth": "^8.0.0",
"@capacitor/android": "^6.0.0",

View file

@ -1,6 +1,6 @@
{
"name": "pedscribe-mobile",
"version": "7.14.3",
"version": "7.14.7",
"description": "PedScribe native mobile app — Capacitor wrapper for Pediatric AI Scribe",
"private": true,
"scripts": {

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "pediatric-ai-scribe",
"version": "7.14.6",
"version": "7.14.7",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "pediatric-ai-scribe",
"version": "7.14.6",
"version": "7.14.7",
"dependencies": {
"@marp-team/marp-cli": "^4.3.1",
"@marp-team/marp-core": "^4.3.0",

View file

@ -1,6 +1,6 @@
{
"name": "pediatric-ai-scribe",
"version": "7.14.6",
"version": "7.14.7",
"description": "AI-powered pediatric clinical documentation platform",
"main": "server.js",
"scripts": {

View file

@ -49,13 +49,7 @@ export function createAssistantImageStore() {
if (typeof window.showToast === 'function') window.showToast('Image saving is not available in this app build yet. Update the app and try again.', 'error');
return;
}
var a = document.createElement('a');
a.href = src;
a.download = 'clinical-visual.png';
a.rel = 'noopener';
document.body.appendChild(a);
a.click();
a.remove();
await downloadWithBrowser(src);
} catch (e) {
if (typeof window.showToast === 'function') window.showToast(e.message || 'Image download failed', 'error');
}
@ -145,6 +139,32 @@ async function shareWithWebFile(src) {
} catch (e) { return isShareCancel(e) ? 'cancelled' : 'unavailable'; }
}
async function downloadWithBrowser(src) {
var blob = await imageSourceToBlob(src);
var objectUrl = URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = objectUrl;
a.download = 'clinical-visual.png';
a.rel = 'noopener';
document.body.appendChild(a);
a.click();
a.remove();
setTimeout(function() { URL.revokeObjectURL(objectUrl); }, 60000);
if (isMobileBrowser()) {
setTimeout(function() {
var opened = window.open(objectUrl, '_blank', 'noopener');
if (opened && typeof window.showToast === 'function') {
window.showToast('If the download did not start, long-press the opened image and save it.', 'success');
}
}, 300);
}
}
function isMobileBrowser() {
return !isNativeApp() && /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent || '');
}
function isNativeApp() {
return !!(window.Capacitor && (!window.Capacitor.isNativePlatform || window.Capacitor.isNativePlatform()));
}