Skip to content

Commit

Permalink
fix: desktop app name (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
stoffeastrom committed May 20, 2020
1 parent e0d135c commit 4457433
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions commands/serve/web/components/Hub.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,21 @@ function SelectEngine({ info, children }) {
);
}

function AppList({ info, glob }) {
function AppList({ info, glob, treatAsDesktop }) {
const [items, setItems] = useState();
const [waiting, setWaiting] = useState(false);

useEffect(() => {
const t = setTimeout(() => {
setWaiting(true);
}, 750);

glob.getDocList().then((its) => {
clearTimeout(t);
setWaiting(false);
setItems(its);
});

return () => {
clearTimeout(t);
};
Expand All @@ -219,7 +221,7 @@ function AppList({ info, glob }) {
component="a"
href={`/dev/${window.location.search.replace(
info.engineUrl,
`${info.engineUrl}/app/${encodeURIComponent(li.qDocId)}`
`${info.engineUrl}/app/${encodeURIComponent(treatAsDesktop ? li.qDocName : li.qDocId)}`
)}`}
>
<ListItemText primary={li.qTitle} secondary={li.qDocId} />
Expand Down Expand Up @@ -254,6 +256,7 @@ const Err = ({ e: { message, hints } }) => {
export default function Hub() {
const [info, setInfo] = useState();
const [glob, setGlobal] = useState();
const [treatAsDesktop, setTreatAsDesktop] = useState(false);
const [err, setError] = useState();
const steps = ['Connect to an engine', 'Select an app', 'Develop'];
const [activeStep, setActiveStep] = useState(0);
Expand Down Expand Up @@ -286,6 +289,7 @@ export default function Hub() {
connect()
.then((g) => {
setGlobal(g);

setActiveStep(1);
const conns = storage.get('connections') || [];
const url = `${info.engineUrl}${
Expand All @@ -295,6 +299,11 @@ export default function Hub() {
conns.push(url);
storage.save('connections', conns);
}
g.getConfiguration().then((c) => {
if (c.qFeatures && c.qFeatures.qIsDesktop) {
setTreatAsDesktop(true);
}
});
})
.catch((e) => {
const oops = {
Expand Down Expand Up @@ -348,7 +357,7 @@ export default function Hub() {
</ThemeProvider>
<Box p={[2, 2]} m={2} bgcolor="background.paper" boxShadow={24} borderRadius="borderRadius">
{glob ? (
<AppList info={info} glob={glob} />
<AppList info={info} glob={glob} treatAsDesktop={treatAsDesktop} />
) : (
<SelectEngine info={info}>{err && <Err e={err} />}</SelectEngine>
)}
Expand Down

0 comments on commit 4457433

Please sign in to comment.