Skip to content

Commit

Permalink
Use new endpoint to get app icon
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed Feb 7, 2020
1 parent 7e4570e commit 982ee13
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
6 changes: 0 additions & 6 deletions app/apps/server/bridges/uiInteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ export class UiInteractionBridge {
throw new Error('Invalid app provided');
}

const { name, iconFileContent } = app.getInfo();

Object.assign(interaction, {
appInfo: { name, base64Icon: iconFileContent },
});

Notifications.notifyUser(user.id, 'uiInteraction', interaction);
}
}
27 changes: 27 additions & 0 deletions app/apps/server/communication/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,33 @@ export class AppsRestApi {
},
});

this.api.addRoute('icon/:id', { authRequired: false }, {
get() {
const prl = manager.getOneById(this.urlParams.id);
if (!prl) {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}

const info = prl.getInfo();
if (!info || !info.iconFileContent) {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}

const imageData = info.iconFileContent.split(';base64,');

const buf = Buffer.from(imageData[1], 'base64');

return {
statusCode: 200,
headers: {
'Content-Length': buf.length,
'Content-Type': imageData[0].replace('data:', ''),
},
body: buf,
};
},
});

this.api.addRoute(':id/languages', { authRequired: false }, {
get() {
const prl = manager.getOneById(this.urlParams.id);
Expand Down
3 changes: 1 addition & 2 deletions app/ui-message/client/blocks/MessageBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const textParser = uiKitText(new class {
return text;
}
}());
const thumb = 'data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==';

// https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/dialog.html

Expand Down Expand Up @@ -134,7 +133,7 @@ export const modalBlockWithContext = ({
<Modal open id={id} ref={ref}>
<Modal.Header>
{/* <Modal.Thumb url={`api/apps/${ context.appId }/icon`} /> */}
<Modal.Thumb url={thumb} />
<Modal.Thumb url={`/api/apps/icon/${ data.appId }`} />
<Modal.Title>{textParser([title])}</Modal.Title>
<Modal.Close tabIndex={-1} onClick={onClose} />
</Modal.Header>
Expand Down

0 comments on commit 982ee13

Please sign in to comment.