rebase some more

This commit is contained in:
Tobias Merkle 2024-06-03 13:46:58 -04:00
parent 6c750e504f
commit bd52f8e4f9
6 changed files with 139 additions and 21 deletions

File diff suppressed because one or more lines are too long

View File

@ -14,8 +14,8 @@
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover" />
<script type="module" crossorigin src="/main:app_store:sys/assets/index-aozprPas.js"></script>
<link rel="stylesheet" crossorigin href="/main:app_store:sys/assets/index-fGthT1qI.css">
<script type="module" crossorigin src="/main:app_store:sys/assets/index-t-SU3ZQb.js"></script>
<link rel="stylesheet" crossorigin href="/main:app_store:sys/assets/index-INOvE5GS.css">
</head>
<body>

View File

@ -11,9 +11,10 @@ interface ActionButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
app: AppInfo;
isIcon?: boolean;
permitMultiButton?: boolean;
launchPath?: string
}
export default function ActionButton({ app, isIcon = false, permitMultiButton = false, ...props }: ActionButtonProps) {
export default function ActionButton({ app, launchPath = '', isIcon = false, permitMultiButton = false, ...props }: ActionButtonProps) {
const { installed, downloaded, updatable } = useMemo(() => {
const versions = Object.entries(app?.metadata?.properties?.code_hashes || {});
const latestHash = (versions.find(([v]) => v === app.metadata?.properties?.current_version) || [])[1];
@ -32,21 +33,6 @@ export default function ActionButton({ app, isIcon = false, permitMultiButton =
};
}, [app]);
const [launchPath, setLaunchPath] = useState('');
useEffect(() => {
fetch('/apps').then(data => data.json())
.then((data: Array<{ package_name: string, path: string }>) => {
if (Array.isArray(data)) {
const homepageAppData = data.find(otherApp => app.package === otherApp.package_name)
if (homepageAppData) {
setLaunchPath(homepageAppData.path)
}
}
})
}, [app])
return (
<>
{/* if it's got a UI and it's updatable, show both buttons if we have space (launch will otherwise push out update) */}

View File

@ -15,9 +15,10 @@ interface AppEntryProps extends React.HTMLAttributes<HTMLDivElement> {
size?: "small" | "medium" | "large";
overrideImageSize?: "small" | "medium" | "large";
showMoreActions?: boolean;
launchPath?: string;
}
export default function AppEntry({ app, size = "medium", overrideImageSize, showMoreActions, ...props }: AppEntryProps) {
export default function AppEntry({ app, size = "medium", overrideImageSize, showMoreActions, launchPath, ...props }: AppEntryProps) {
const isMobile = isMobileCheck()
const navigate = useNavigate()
@ -45,6 +46,7 @@ export default function AppEntry({ app, size = "medium", overrideImageSize, show
})}>
<ActionButton
app={app}
launchPath={launchPath}
isIcon={!showMoreActions && size !== 'large'}
className={classNames({
'bg-orange text-lg': size === 'large',

View File

@ -22,6 +22,7 @@ export default function AppPage() {
const navigate = useNavigate();
const params = useParams();
const [app, setApp] = useState<AppInfo | undefined>(undefined);
const [launchPath, setLaunchPath] = useState('');
useEffect(() => {
const myApp = myApps.local.find((a) => appId(a) === params.id);
@ -91,6 +92,18 @@ export default function AppPage() {
}
]
useEffect(() => {
fetch('/apps').then(data => data.json())
.then((data: Array<{ package_name: string, path: string }>) => {
if (Array.isArray(data)) {
const homepageAppData = data.find(otherApp => app?.package === otherApp.package_name)
if (homepageAppData) {
setLaunchPath(homepageAppData.path)
}
}
})
}, [app])
return (
<div className={classNames("flex flex-col w-full p-2",
{
@ -143,7 +156,12 @@ export default function AppPage() {
<div className={classNames("flex-center gap-2", {
'flex-col': isMobile,
})}>
<ActionButton app={app} className={classNames("self-center bg-orange text-lg px-12")} permitMultiButton />
<ActionButton
app={app}
launchPath={launchPath}
className={classNames("self-center bg-orange text-lg px-12")}
permitMultiButton
/>
</div>
{app.installed && app.state?.mirroring && (
<button type="button" onClick={goToPublish}>

View File

@ -19,11 +19,11 @@ export default function StorePage() {
const { listedApps, getListedApps, rebuildIndex } = useAppsStore();
const [resultsSort, setResultsSort] = useState<string>("Recently published");
const [searchQuery, setSearchQuery] = useState<string>("");
const [displayedApps, setDisplayedApps] = useState<AppInfo[]>(listedApps);
const [page, setPage] = useState(1);
const [tags, setTags] = useState<string[]>([])
const [launchPaths, setLaunchPaths] = useState<{ [package_name: string]: string }>({})
const pages = useMemo(
() =>
@ -108,6 +108,23 @@ export default function StorePage() {
const isMobile = isMobileCheck()
useEffect(() => {
fetch('/apps').then(data => data.json())
.then((data: Array<{ package_name: string, path: string }>) => {
if (Array.isArray(data)) {
listedApps.forEach(app => {
const homepageAppData = data.find(otherApp => app.package === otherApp.package_name)
if (homepageAppData) {
setLaunchPaths({
...launchPaths,
[app.package]: homepageAppData.path
})
}
})
}
})
}, [listedApps])
return (
<div className={classNames("flex flex-col w-full max-h-screen p-2", {
'gap-4 max-w-screen': isMobile,
@ -170,6 +187,7 @@ export default function StorePage() {
key={appId(app) + (app.state?.our_version || "")}
size={'medium'}
app={app}
launchPath={launchPaths[app.package]}
className={classNames("grow", {
'w-1/4': !isMobile,
'w-full': isMobile