Explorar o código

change how initial rendering and resetting work

Adam Shaw %!s(int64=8) %!d(string=hai) anos
pai
achega
721ba38afc
Modificáronse 1 ficheiros con 7 adicións e 23 borrados
  1. 7 23
      src/common/View.js

+ 7 - 23
src/common/View.js

@@ -380,37 +380,21 @@ var View = FC.View = Model.extend({
 
 	setEvents: function(events) {
 		this.set('currentEvents', events);
-
-		if (this.has('displayingEvents')) {
-			this.requestEventsRender(events);
-		}
+		this.set('hasEvents', true);
 	},
 
 
 	unsetEvents: function() {
 		this.unset('currentEvents');
-
-		if (this.has('displayingEvents')) {
-			this.requestEventsUnrender();
-		}
+		this.unset('hasEvents');
 	},
 
 
 	resetEvents: function(events) {
-		var _this = this;
-
-		this.set('currentEvents', events);
-
-		if (this.has('displayingEvents')) {
-
-			// queue 2 render actions, guarantees serial execution.
-			// TODO: move this into rendering section?
-			this.renderQueue.queue(function() {
-				_this.executeEventsUnrender();
-			}, function() {
-				_this.executeEventsRender(events);
-			});
-		}
+		this.startBatchRender();
+		this.unsetEvents();
+		this.setEvents(events);
+		this.stopBatchRender();
 	},
 
 
@@ -1291,7 +1275,7 @@ View.watch('bindingEvents', [ 'initialEvents' ], function(deps) {
 });
 
 
-View.watch('displayingEvents', [ 'displayingDates', 'bindingEvents' ], function() {
+View.watch('displayingEvents', [ 'displayingDates', 'hasEvents' ], function() {
 	this.requestEventsRender(this.get('currentEvents')); // if there were event mutations after initialEvents
 }, function() {
 	this.requestEventsUnrender();