browser_action/src/actions.js
/**

popupOpened()
------------

This action sends a message to the observer that the popup was opened.
The observer relays this message to the adapter, via adapter.onPopupOpened(), which can respond with an error.
Error cases include detecting automatic captions on YouTube or image captions on Netflix, both of which aren't supported at this time.

**/
popupOpened()
This action sends a message to the observer that the popup was opened.
The observer relays this message to the adapter, via adapter.onPopupOpened(), which can respond with an error.
Error cases include detecting automatic captions on YouTube or image captions on Netflix, both of which aren't supported at this time.
popupOpened () This action sends a message to the observer that the popup was opened . The observer relays this message to the adapter via adapter . onPopupOpened () which can respond with an error . Error cases include detecting automatic captions on YouTube or image captions on Netflix both of which aren ' t supported at this time .
function popupOpened() {
  return function (dispatch) {
    return new Promise((resolve, _) => {
      getActiveTabId()
        .then(tabId => {
          return new Promise(_resolve => {
            window.chrome.tabs.sendMessage(tabId, {
              type: 'popup-opened'
            }, _resolve);
          });
        })
        .then(response => {
          if (!response.ok && response.errorType) {
            dispatch({
              type: 'CHANGE_ERROR',
              payload: {
                hasError: true,
                errorType: response.errorType
              }
            });
          }
          resolve();
        })
        .catch(() => {
          console.log('actions: Can\'t get active tab ID, am I running locally?');
          resolve();
        });
    });
  }
}
function popupOpened ( ) { return function ( dispatch ) { return new Promise ( ( resolve , _ ) => { getActiveTabId ( ) . then ( tabId => { return new Promise ( _resolve => { window . chrome . tabs . sendMessage ( tabId , { type : 'popup-opened' } , _resolve ) ; } ) ; } ) . then ( response => { if ( ! response . ok && response . errorType ) { dispatch ( { type : 'CHANGE_ERROR' , payload : { hasError : true , errorType : response . errorType } } ) ; } resolve ( ) ; } ) . catch ( ( ) => { console . log ( 'actions: Can\'t get active tab ID, am I running locally?' ) ; resolve ( ) ; } ) ; } ) ; } }
popupOpened()
This action sends a message to the observer that the popup was opened.
popupOpened () This action sends a message to the observer that the popup was opened .