Created
May 23, 2017 19:35
-
-
Save thomsbg/fb462eda1a9ae57851eb754bc9e1dd4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/client/app.js b/client/app.js | |
index 5086ac0d3..758272d2b 100644 | |
--- a/client/app.js | |
+++ b/client/app.js | |
@@ -1,4 +1,5 @@ | |
var Emitter = require('eventemitter2').EventEmitter2; | |
+var sentryActions = require('./actions/sentry'); | |
var App = window.App = function(opts) { | |
Emitter.call(this); | |
@@ -31,13 +32,18 @@ App.prototype.start = function() { | |
App.prototype.render = function(Component, data) { | |
var self = this; | |
var previous = this.ractive; | |
+ if (previous instanceof Component) { | |
+ // Set new data instead of building a whole new component | |
+ return previous.set(data); | |
+ } | |
+ | |
var ractive = this.ractive = new Component({ data: data }); | |
var render = function() { | |
window.scrollTo(0, 0); | |
return ractive.render(document.body).then(() => { | |
self.emit('render'); | |
return ractive; | |
- }); | |
+ }).catch(sentryActions.reportError); | |
}; | |
if (previous) { | |
return previous.teardown().then(render); | |
diff --git a/client/middleware/render_editor.js b/client/middleware/render_editor.js | |
index a4424503c..fffa3ddf5 100644 | |
--- a/client/middleware/render_editor.js | |
+++ b/client/middleware/render_editor.js | |
@@ -2,12 +2,5 @@ var sentryActions = require('../actions/sentry'); | |
var Editor = require('../components/editor.html'); | |
module.exports = function(ctx, next) { | |
- if (app.ractive instanceof Editor) { | |
- // We only need to load the doc actions once, until we switch contexts. | |
- next(); | |
- } else { | |
- app.render(Editor).then(function() { | |
- next(); | |
- }).catch(sentryActions.reportError); | |
- } | |
+ app.render(Editor).then(() => next()); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment