mirror of
https://github.com/HeyPuter/puter.git
synced 2026-09-25 22:55:58 +00:00
Merge launch & installed apps, tweak app tile CSS
Fetch both the installedApps and get-launch-apps endpoints in parallel, normalize recommended + recent launch items, and merge them with installed apps while deduplicating by name (launch items are prioritized). Update this._apps and render the combined list. Also simplify the app tile icon styling by removing border-radius and box-shadow for a flatter icon appearance. Error handling for failed loads is preserved.
This commit is contained in:
@@ -79,18 +79,56 @@ const TabApps = {
|
||||
const $container = $el_window.find('.myapps-container');
|
||||
|
||||
try {
|
||||
const res = await fetch(
|
||||
`${window.api_origin}/installedApps?orderBy=name&limit=100`,
|
||||
{
|
||||
headers: {
|
||||
'Authorization': `Bearer ${puter.authToken}`,
|
||||
// Fetch both APIs in parallel
|
||||
const [installedRes, launchRes] = await Promise.all([
|
||||
fetch(
|
||||
`${window.api_origin}/installedApps?orderBy=name&limit=100`,
|
||||
{
|
||||
headers: { 'Authorization': `Bearer ${puter.authToken}` },
|
||||
method: 'GET',
|
||||
},
|
||||
method: 'GET',
|
||||
},
|
||||
);
|
||||
const apps = await res.json();
|
||||
this._apps = apps;
|
||||
$container.html(buildAppsGrid(apps));
|
||||
),
|
||||
fetch(
|
||||
`${window.api_origin}/get-launch-apps?icon_size=64`,
|
||||
{
|
||||
headers: { 'Authorization': `Bearer ${window.auth_token}` },
|
||||
method: 'GET',
|
||||
},
|
||||
),
|
||||
]);
|
||||
|
||||
const installedApps = await installedRes.json();
|
||||
const launchData = await launchRes.json();
|
||||
|
||||
// Normalize launch apps (recommended + recent) to same shape
|
||||
const launchApps = [
|
||||
...(launchData.recommended || []),
|
||||
...(launchData.recent || []),
|
||||
].map(app => ({
|
||||
name: app.name,
|
||||
title: app.title,
|
||||
iconUrl: app.icon || null,
|
||||
}));
|
||||
|
||||
// Build seen set from launch apps
|
||||
const seen = new Set();
|
||||
const merged = [];
|
||||
|
||||
for ( const app of launchApps ) {
|
||||
if ( seen.has(app.name) ) continue;
|
||||
seen.add(app.name);
|
||||
merged.push(app);
|
||||
}
|
||||
|
||||
// Append installed apps that aren't already in the list
|
||||
for ( const app of installedApps ) {
|
||||
if ( seen.has(app.name) ) continue;
|
||||
seen.add(app.name);
|
||||
merged.push(app);
|
||||
}
|
||||
|
||||
this._apps = merged;
|
||||
$container.html(buildAppsGrid(merged));
|
||||
} catch (e) {
|
||||
console.error('Failed to load installed apps:', e);
|
||||
$container.html('<div class="myapps-empty"><p>Failed to load apps</p></div>');
|
||||
|
||||
@@ -499,10 +499,8 @@ body {
|
||||
.myapps-tile-icon {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 14px;
|
||||
overflow: hidden;
|
||||
background: var(--dashboard-card-background);
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
|
||||
transition: transform 0.15s ease, box-shadow 0.15s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -517,7 +515,6 @@ body {
|
||||
|
||||
.myapps-tile:hover .myapps-tile-icon {
|
||||
transform: scale(1.08);
|
||||
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.myapps-tile:active .myapps-tile-icon {
|
||||
|
||||
Reference in New Issue
Block a user