Skip to content

Commit

Permalink
frontend working
Browse files Browse the repository at this point in the history
  • Loading branch information
micahg committed Mar 2, 2023
1 parent c3e6ea1 commit 22d6569
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ function App() {
let view = query.get('view');
return (
<div className="App">
<ContentEditor/>
{/* {view !== 'edit' && <RemoteDisplayComponent/>}
{view === 'edit' && <ContentEditor/>} */}
{/* <ContentEditor/> */}
{view !== 'edit' && <RemoteDisplayComponent/>}
{view === 'edit' && <ContentEditor/>}
</div>
);
}
Expand Down
13 changes: 11 additions & 2 deletions src/components/RemoteDisplayComponent/RemoteDisplayComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,17 @@ const RemoteDisplayComponent = () => {
return;
}

// ignore null state -- happens when server has no useful state loaded yet
if (js.state === null) return;

// if we don't have an API URL we'll never get WS messages... seems impossible
if (apiUrl === null) {
console.error('THE IMPOSSIBLE HAS HAPPENED -- WS MESSAGE WITH NO API SERVER WHAT');
return;
}

let ts: number = new Date().getTime();
if ('overlay' in js.state && apiUrl) {
if ('overlay' in js.state && js.state.overlay) {
let asset: string = js.state.overlay;
loadImage(`${apiUrl}/${asset}?${ts}`).then((img: HTMLImageElement) => {
renderImage(img, overlayCnvs, overlayCtx);
Expand All @@ -65,7 +74,7 @@ const RemoteDisplayComponent = () => {
});
}

if ('background' in js.state && apiUrl) {
if ('background' in js.state && js.state.background) {
let asset: string = js.state.background;
loadImage(`${apiUrl}/${asset}?${ts}`).then((img: HTMLImageElement) => {
renderImage(img, contentCnvs, contentCtx);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/drawing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function loadImage(uri: string): Promise<HTMLImageElement> {
// originates from the fact that our frontend in dev is on localhost:4200 and
// I don't think cross-origin is setup properly for static data on the nose
// server
img.crossOrigin = 'Anonymous';
// img.crossOrigin = 'Anonymous';
});
}
/*export function loadImage(data: Blob): Promise<HTMLImageElement>;
Expand Down

0 comments on commit 22d6569

Please sign in to comment.