ngiactcp commited on
Commit
9896f8a
·
1 Parent(s): a2ea3f7

Make installed apps appear instantly on the home screen

Browse files

Update app installation to trigger instant home screen updates via postMessage and ensure apps open correctly within the Nexa browser frame.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 9d4157c5-3aaa-42eb-948c-782340830561
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: 35cb3148-74a7-4124-809e-803461c46b67
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3b12fe82-08c9-4f4d-bbd8-39c248923097/9d4157c5-3aaa-42eb-948c-782340830561/6fNReKI
Replit-Helium-Checkpoint-Created: true

Files changed (2) hide show
  1. appstore.html +5 -2
  2. index.html +5 -5
appstore.html CHANGED
@@ -661,13 +661,16 @@
661
  name: app.name,
662
  icon: app.icon,
663
  color: app.color,
664
- url: app.url // Ensure URL is saved for the Home Screen to use
665
  });
666
  localStorage.setItem('homeScreenApps', JSON.stringify(homeApps));
667
  }
668
 
 
 
 
 
669
  showToast('Installed!');
670
- setTimeout(() => location.reload(), 500);
671
  }
672
 
673
  async function updateApp(appId) {
 
661
  name: app.name,
662
  icon: app.icon,
663
  color: app.color,
664
+ url: app.url
665
  });
666
  localStorage.setItem('homeScreenApps', JSON.stringify(homeApps));
667
  }
668
 
669
+ if (window.parent !== window) {
670
+ window.parent.postMessage({ type: 'install_app_instant', appId: appId }, '*');
671
+ }
672
+
673
  showToast('Installed!');
 
674
  }
675
 
676
  async function updateApp(appId) {
index.html CHANGED
@@ -15135,7 +15135,7 @@
15135
  // Check for installed .lunpkg apps first
15136
  const installedApps = JSON.parse(localStorage.getItem("installed_lunpkg_apps") || "{}");
15137
  if (installedApps[appId]) {
15138
- const pkg = installedApps[appId];
15139
  const content = pkg["entry/main.html"];
15140
  const blob = new Blob([content], {type: "text/html"});
15141
  const url = URL.createObjectURL(blob);
@@ -15143,7 +15143,7 @@
15143
  const nexaFrame = document.getElementById("nexaFrame");
15144
  if (nexaFrame) {
15145
  nexaFrame.src = url;
15146
- openAppDirect("nexaApp");
15147
  return;
15148
  }
15149
  }
@@ -15153,8 +15153,8 @@
15153
  const browserFrame = document.getElementById("browserFrame");
15154
  const nexaApp = document.getElementById("nexaApp");
15155
  if (nexaApp) {
15156
- const nexaFrame = document.getElementById("nexaFrame"); if (nexaFrame) nexaFrame.src = customApp.url;
15157
- openAppDirect("nexaApp");
15158
  return;
15159
  }
15160
  }
@@ -22316,7 +22316,7 @@
22316
 
22317
 
22318
  window.addEventListener('message', (e) => {
22319
- if (e.data.type === 'install_app') {
22320
  const { appId, packageData } = e.data;
22321
  const installedPackages = JSON.parse(localStorage.getItem('installed_lunpkg_apps') || '{}');
22322
  installedPackages[appId] = packageData;
 
15135
  // Check for installed .lunpkg apps first
15136
  const installedApps = JSON.parse(localStorage.getItem("installed_lunpkg_apps") || "{}");
15137
  if (installedApps[appId]) {
15138
+ if (installedApps[appId]) { const pkg = installedApps[appId];
15139
  const content = pkg["entry/main.html"];
15140
  const blob = new Blob([content], {type: "text/html"});
15141
  const url = URL.createObjectURL(blob);
 
15143
  const nexaFrame = document.getElementById("nexaFrame");
15144
  if (nexaFrame) {
15145
  nexaFrame.src = url;
15146
+ openAppDirect(appId);
15147
  return;
15148
  }
15149
  }
 
15153
  const browserFrame = document.getElementById("browserFrame");
15154
  const nexaApp = document.getElementById("nexaApp");
15155
  if (nexaApp) {
15156
+ const nexaFrame = document.getElementById("nexaFrame"); if (nexaFrame) const targetApp = document.getElementById(appId); if (targetApp) { const iframe = targetApp.querySelector("iframe"); if (iframe) iframe.src = customApp.url; }
15157
+ openAppDirect(appId);
15158
  return;
15159
  }
15160
  }
 
22316
 
22317
 
22318
  window.addEventListener('message', (e) => {
22319
+ if (e.data.type === 'install_app' || e.data.type === 'install_app_instant') {
22320
  const { appId, packageData } = e.data;
22321
  const installedPackages = JSON.parse(localStorage.getItem('installed_lunpkg_apps') || '{}');
22322
  installedPackages[appId] = packageData;