Skip to content

Commit

Permalink
Use destructuring to make some code more succinct
Browse files Browse the repository at this point in the history
  • Loading branch information
robertknight committed Oct 7, 2021
1 parent 1494380 commit e6af3ec
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/annotator/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ export default class Sidebar {
*/
this.ready = new Promise(resolve => {
this._listeners.add(window, 'message', event => {
const messageEvent = /** @type {MessageEvent} */ (event);
if (messageEvent.data?.type === 'hypothesisSidebarReady') {
this._sidebarRPC.createChannel(messageEvent.ports[0]);
const { data, ports } = /** @type {MessageEvent} */ (event);
if (data?.type === 'hypothesisSidebarReady') {
this._sidebarRPC.createChannel(ports[0]);
resolve();
}
});
Expand All @@ -215,9 +215,9 @@ export default class Sidebar {
// directly to the sidebar during a window's 'unload' event.
// See https://bugs.webkit.org/show_bug.cgi?id=231167.
this._listeners.add(window, 'message', event => {
const messageData = /** @type {MessageEvent} */ (event).data;
if (messageData?.type === 'hypothesisGuestUnloaded') {
this._sidebarRPC.call('destroyFrame', messageData.frameIdentifier);
const { data } = /** @type {MessageEvent} */ (event);
if (data?.type === 'hypothesisGuestUnloaded') {
this._sidebarRPC.call('destroyFrame', data.frameIdentifier);
}
});
}
Expand Down

0 comments on commit e6af3ec

Please sign in to comment.