diff --git a/index.html b/index.html index 1b5c26a2..743d01dc 100644 --- a/index.html +++ b/index.html @@ -51,8 +51,6 @@ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - - ga('create', 'UA-60614729-2', 'auto'); diff --git a/js/actions/coa_actions.js b/js/actions/coa_actions.js index 9af2841c..7c6f5118 100644 --- a/js/actions/coa_actions.js +++ b/js/actions/coa_actions.js @@ -7,7 +7,8 @@ import CoaFetcher from '../fetchers/coa_fetcher'; class CoaActions { constructor() { this.generateActions( - 'updateCoa' + 'updateCoa', + 'flushCoa' ); } @@ -26,9 +27,7 @@ class CoaActions { this.actions.updateCoa(res.coa); }) .catch((err) => { - console.log(err) console.logGlobal(err); - this.actions.updateCoa('Something went wrong, please try again later.'); }); } } diff --git a/js/actions/event_actions.js b/js/actions/event_actions.js new file mode 100644 index 00000000..8f1def9f --- /dev/null +++ b/js/actions/event_actions.js @@ -0,0 +1,19 @@ +'use strict'; + +import alt from '../alt'; + + +class EventActions { + constructor() { + this.generateActions( + 'applicationWillBoot', + 'applicationDidBoot', + 'profileDidLoad', + //'userDidLogin', + //'userDidLogout', + 'routeDidChange' + ); + } +} + +export default alt.createActions(EventActions); diff --git a/js/app.js b/js/app.js index 13aa38a5..81a8fb82 100644 --- a/js/app.js +++ b/js/app.js @@ -5,7 +5,9 @@ require('babel/polyfill'); import React from 'react'; import Router from 'react-router'; +/* eslint-disable */ import fetch from 'isomorphic-fetch'; +/* eslint-enable */ import ApiUrls from './constants/api_urls'; import { updateApiUrls } from './constants/api_urls'; @@ -16,6 +18,16 @@ import requests from './utils/requests'; import { getSubdomainSettings } from './utils/constants_utils'; import { initLogging } from './utils/error_utils'; +import EventActions from './actions/event_actions'; + +/* eslint-disable */ +// You can comment out the modules you don't need +// import DebugHandler from './third_party/debug'; +import GoogleAnalyticsHandler from './third_party/ga'; +import RavenHandler from './third_party/raven'; +import IntercomHandler from './third_party/intercom'; +/* eslint-enable */ + initLogging(); let headers = { @@ -43,25 +55,30 @@ class AppGateway { settings = getSubdomainSettings(subdomain); appConstants.whitelabel = settings; updateApiUrls(settings.type, subdomain); - this.load(settings.type); + this.load(settings); } catch(err) { // if there are no matching subdomains, we're routing // to the default frontend console.logGlobal(err); - this.load('default'); + this.load(); } } - load(type) { + load(settings) { + let type = 'default'; + if (settings) { + type = settings.type; + } + + EventActions.applicationWillBoot(settings); Router.run(getRoutes(type), Router.HistoryLocation, (App) => { - if (window.ga) { - window.ga('send', 'pageview'); - } React.render( , document.getElementById('main') ); + EventActions.routeDidChange(); }); + EventActions.applicationDidBoot(settings); } } diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index 409f94b9..acb76875 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -68,6 +68,15 @@ let Edition = React.createClass({ }, componentWillUnmount() { + // Flushing the coa state is essential to not displaying the same + // data to the user while he's on another edition + // + // BUGFIX: Previously we had this line in the componentWillUnmount of + // CoaDetails, but since we're reloading the edition after performing an ACL action + // on it, this resulted in multiple events occupying the dispatcher, which eventually + // resulted in crashing the app. + CoaActions.flushCoa(); + UserStore.unlisten(this.onChange); PieceListStore.unlisten(this.onChange); }, @@ -391,7 +400,7 @@ let CoaDetails = React.createClass({ componentDidMount() { CoaStore.listen(this.onChange); - if (this.props.edition.coa) { + if(this.props.edition.coa) { CoaActions.fetchOne(this.props.edition.coa); } else { @@ -408,7 +417,7 @@ let CoaDetails = React.createClass({ }, render() { - if (this.state.coa && this.state.coa.url_safe) { + if(this.state.coa && this.state.coa.url_safe) { return (

@@ -426,8 +435,7 @@ let CoaDetails = React.createClass({

); - } - else if (typeof this.state.coa === 'string'){ + } else if(typeof this.state.coa === 'string'){ return (
{this.state.coa} diff --git a/js/components/ascribe_detail/media_container.js b/js/components/ascribe_detail/media_container.js index 6bf58a9c..2ff5a55d 100644 --- a/js/components/ascribe_detail/media_container.js +++ b/js/components/ascribe_detail/media_container.js @@ -12,6 +12,11 @@ import CollapsibleButton from './../ascribe_collapsible/collapsible_button'; import AclProxy from '../acl_proxy'; +const EMBED_IFRAME_HEIGHT = { + video: 315, + audio: 62 +}; + let MediaContainer = React.createClass({ propTypes: { content: React.PropTypes.object @@ -29,7 +34,9 @@ let MediaContainer = React.createClass({ extraData = this.props.content.digital_work.encoding_urls.map(e => { return { url: e.url, type: e.label }; }); } - if (['video', 'audio'].indexOf(mimetype) > -1){ + if (['video', 'audio'].indexOf(mimetype) > -1) { + let height = EMBED_IFRAME_HEIGHT[mimetype]; + embed = ( - {''} }/> @@ -55,6 +62,7 @@ let MediaContainer = React.createClass({ encodingStatus={this.props.content.digital_work.isEncoding} />