mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-29 12:50:59 +00:00
Detect fullpage apps early and skip desktop load
This commit is contained in:
+13
-18
@@ -646,10 +646,10 @@ async function UIDesktop (options) {
|
||||
// Desktop
|
||||
// If desktop is not in fullpage/embedded mode, we hide it until files and directories are loaded and then fade in the UI
|
||||
// This gives a calm and smooth experience for the user
|
||||
h += `<div class="desktop item-container disable-user-select"
|
||||
data-uid="${options.desktop_fsentry.uid}"
|
||||
data-sort_by="${!options.desktop_fsentry.sort_by ? 'name' : options.desktop_fsentry.sort_by}"
|
||||
data-sort_order="${!options.desktop_fsentry.sort_order ? 'asc' : options.desktop_fsentry.sort_order}"
|
||||
h += `<div class="desktop item-container disable-user-select"
|
||||
data-uid="${options.desktop_fsentry?.uid ?? ''}"
|
||||
data-sort_by="${!options.desktop_fsentry?.sort_by ? 'name' : options.desktop_fsentry.sort_by}"
|
||||
data-sort_order="${!options.desktop_fsentry?.sort_order ? 'asc' : options.desktop_fsentry.sort_order}"
|
||||
data-path="${html_encode(window.desktop_path)}"
|
||||
>`;
|
||||
|
||||
@@ -1261,18 +1261,16 @@ async function UIDesktop (options) {
|
||||
// i.e. https://puter.com/app/<app_name>
|
||||
//--------------------------------------------------------------------------------------
|
||||
if ( window.url_paths[0]?.toLocaleLowerCase() === 'app' && window.url_paths[1] ) {
|
||||
window.app_launched_from_url = window.url_paths[1];
|
||||
// get app metadata
|
||||
try {
|
||||
window.app_launched_from_url = await puter.apps.get(window.url_paths[1], { icon_size: 64 });
|
||||
window.is_fullpage_mode = window.app_launched_from_url.metadata?.fullpage_on_landing ?? window.is_fullpage_mode ?? false;
|
||||
|
||||
// show 'Show Desktop' button
|
||||
if ( window.is_fullpage_mode ) {
|
||||
$('.show-desktop-btn').removeClass('hidden');
|
||||
// If app metadata was already fetched early (for fullpage detection), reuse it
|
||||
if ( !window.app_launched_from_url?.name ) {
|
||||
window.app_launched_from_url = window.url_paths[1];
|
||||
// get app metadata
|
||||
try {
|
||||
window.app_launched_from_url = await puter.apps.get(window.url_paths[1], { icon_size: 64 });
|
||||
window.is_fullpage_mode = window.app_launched_from_url.metadata?.fullpage_on_landing ?? window.is_fullpage_mode ?? false;
|
||||
} catch (e) {
|
||||
console.error('UIDesktop app path launch error', e);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('UIDesktop app path launch error', e);
|
||||
}
|
||||
|
||||
// get query params, any param that doesn't start with 'puter.' will be passed to the app
|
||||
@@ -2472,9 +2470,6 @@ window.exit_fullpage_mode = (el_window) => {
|
||||
// reset dektop height to take into account the taskbar height
|
||||
$('.desktop').css('height', `calc(100vh - ${window.taskbar_height + window.toolbar_height}px)`);
|
||||
|
||||
// hide the 'Show Desktop' button in toolbar
|
||||
$('.show-desktop-btn').hide();
|
||||
|
||||
// refresh desktop background
|
||||
window.refresh_desktop_background();
|
||||
};
|
||||
|
||||
@@ -1972,20 +1972,6 @@ label {
|
||||
box-shadow: rgb(255 255 255 / 44%) 0px 0px 0px 0.5px inset, rgba(0, 0, 0, 0.2) 0px 0px 0px 0.5px, rgba(0, 0, 0, 0.2) 0px 2px 14px;
|
||||
}
|
||||
|
||||
.show-desktop-btn {
|
||||
color: white;
|
||||
font-size: 11px !important;
|
||||
padding: 2px 5px 2px !important;
|
||||
border: 1px solid;
|
||||
border-radius: 4px;
|
||||
height: 18px !important;
|
||||
width: 110px !important;
|
||||
margin-top: 2px;
|
||||
text-decoration: none;
|
||||
margin-left: 10px !important;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.device-phone .toolbar {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
+52
-8
@@ -521,6 +521,24 @@ window.initgui = async function (options) {
|
||||
window.history.replaceState(null, document.title, cleanUrl);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Early check for fullpage mode from app metadata
|
||||
// If the user navigated to /app/<app_name> and the app has fullpage_on_landing,
|
||||
// set fullpage mode now so we can skip loading the desktop background and items.
|
||||
//--------------------------------------------------------------------------------------
|
||||
if ( !window.is_fullpage_mode && window.url_paths[0]?.toLocaleLowerCase() === 'app' && window.url_paths[1] ) {
|
||||
try {
|
||||
const app_info = await puter.apps.get(window.url_paths[1], { icon_size: 64 });
|
||||
if ( app_info?.metadata?.fullpage_on_landing ) {
|
||||
window.is_fullpage_mode = true;
|
||||
window.taskbar_height = 0;
|
||||
window.app_launched_from_url = app_info;
|
||||
}
|
||||
} catch (e) {
|
||||
// App metadata fetch failed; will retry later in UIDesktop
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Desktop background (early)
|
||||
// Set before action=login/signup so OIDC error redirects show the background behind the form.
|
||||
@@ -860,10 +878,15 @@ window.initgui = async function (options) {
|
||||
// Load desktop, only if we're not embedded in a popup and not on the dashboard page
|
||||
// -------------------------------------------------------------------------------------
|
||||
if ( !window.embedded_in_popup && !window.is_dashboard_mode ) {
|
||||
await window.get_auto_arrange_data();
|
||||
puter.fs.stat({ path: window.desktop_path, consistency: 'eventual' }).then(desktop_fsentry => {
|
||||
UIDesktop({ desktop_fsentry: desktop_fsentry });
|
||||
});
|
||||
if ( window.is_fullpage_mode ) {
|
||||
// In fullpage mode, skip loading desktop items and background
|
||||
UIDesktop({});
|
||||
} else {
|
||||
await window.get_auto_arrange_data();
|
||||
puter.fs.stat({ path: window.desktop_path, consistency: 'eventual' }).then(desktop_fsentry => {
|
||||
UIDesktop({ desktop_fsentry: desktop_fsentry });
|
||||
});
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Dashboard mode
|
||||
@@ -1408,14 +1431,35 @@ window.initgui = async function (options) {
|
||||
await UIWindowCopyToken({ show_header: true });
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Early check for fullpage mode from app metadata (after login)
|
||||
// -------------------------------------------------------------------------------------
|
||||
if ( !window.is_fullpage_mode && window.url_paths[0]?.toLocaleLowerCase() === 'app' && window.url_paths[1] ) {
|
||||
try {
|
||||
const app_info = await puter.apps.get(window.url_paths[1], { icon_size: 64 });
|
||||
if ( app_info?.metadata?.fullpage_on_landing ) {
|
||||
window.is_fullpage_mode = true;
|
||||
window.taskbar_height = 0;
|
||||
window.app_launched_from_url = app_info;
|
||||
}
|
||||
} catch (e) {
|
||||
// App metadata fetch failed; will retry later in UIDesktop
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Load desktop, if not embedded in a popup and not on the dashboard page
|
||||
// -------------------------------------------------------------------------------------
|
||||
if ( !window.embedded_in_popup && !window.is_dashboard_mode ) {
|
||||
await window.get_auto_arrange_data();
|
||||
puter.fs.stat({ path: window.desktop_path, consistency: 'eventual' }).then(desktop_fsentry => {
|
||||
UIDesktop({ desktop_fsentry: desktop_fsentry });
|
||||
});
|
||||
if ( window.is_fullpage_mode ) {
|
||||
// In fullpage mode, skip loading desktop items and background
|
||||
UIDesktop({});
|
||||
} else {
|
||||
await window.get_auto_arrange_data();
|
||||
puter.fs.stat({ path: window.desktop_path, consistency: 'eventual' }).then(desktop_fsentry => {
|
||||
UIDesktop({ desktop_fsentry: desktop_fsentry });
|
||||
});
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------------------
|
||||
// Dashboard mode: open explorer pointing to home directory
|
||||
|
||||
Reference in New Issue
Block a user