From 5c9c865f123ff2df3eac768594a1f348865e9b0d Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 17 May 2013 16:51:01 -0700 Subject: [PATCH] Move flush to context --- js/id/id.js | 7 +++++++ js/id/renderer/map.js | 6 ------ js/id/ui/save.js | 3 +-- js/id/ui/source_switch.js | 3 +-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/js/id/id.js b/js/id/id.js index c71d2820a..319452da0 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -79,6 +79,13 @@ window.iD = function () { context.changes = history.changes; context.intersects = history.intersects; + context.flush = function() { + history.reset(); + connection.flush(); + map.redraw(); + return context; + }; + /* Graph */ context.hasEntity = function(id) { return history.graph().hasEntity(id); diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index abf763e6c..f29e5a8c7 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -404,12 +404,6 @@ iD.Map = function(context) { return newZoom; }; - map.flush = function() { - context.connection().flush(); - context.history().reset(); - return map; - }; - map.editable = function() { return map.zoom() >= 16; }; diff --git a/js/id/ui/save.js b/js/id/ui/save.js index ddcb6a9e6..3e4e917a4 100644 --- a/js/id/ui/save.js +++ b/js/id/ui/save.js @@ -54,8 +54,7 @@ iD.ui.Save = function(context) { .append('p') .text(err.responseText); } else { - history.reset(); - map.flush().redraw(); + context.flush(); success(e, changeset_id); } }); diff --git a/js/id/ui/source_switch.js b/js/id/ui/source_switch.js index 88ae4d009..b1b2cb4d0 100644 --- a/js/id/ui/source_switch.js +++ b/js/id/ui/source_switch.js @@ -13,8 +13,7 @@ iD.ui.SourceSwitch = function(context) { context.connection() .switch(live ? keys[1] : keys[0]); - context.map() - .flush(); + context.flush(); d3.select(this) .text(live ? t('source_switch.dev') : t('source_switch.live'))