diff --git a/TODO b/TODO index 6dc9b627..4f31f1d4 100644 --- a/TODO +++ b/TODO @@ -5,7 +5,6 @@ first major release. - posts/upload: ability to paste many urls (unsure) - posts/listing: add buttons for toggling safety - users: add user-configurable "about me" (should support Markdown) -- tags: refresh tags.json when editing post - tags: add tag merging - tags: add tag descriptions - tags: add tag edit snapshots (backed-only) diff --git a/public_html/js/Presenters/PostEditPresenter.js b/public_html/js/Presenters/PostEditPresenter.js index b4439946..fb5d0cca 100644 --- a/public_html/js/Presenters/PostEditPresenter.js +++ b/public_html/js/Presenters/PostEditPresenter.js @@ -5,7 +5,8 @@ App.Presenters.PostEditPresenter = function( util, promise, api, - auth) { + auth, + tagList) { var $target; var post; @@ -132,6 +133,7 @@ App.Presenters.PostEditPresenter = function( promise.wait(api.put('/posts/' + post.id, formData)) .then(function(response) { + tagList.refreshTags(); if (typeof(updateCallback) !== 'undefined') { updateCallback(post = response.json); } @@ -153,4 +155,4 @@ App.Presenters.PostEditPresenter = function( }; -App.DI.register('postEditPresenter', ['util', 'promise', 'api', 'auth'], App.Presenters.PostEditPresenter); +App.DI.register('postEditPresenter', ['util', 'promise', 'api', 'auth', 'tagList'], App.Presenters.PostEditPresenter); diff --git a/public_html/js/Presenters/TagPresenter.js b/public_html/js/Presenters/TagPresenter.js index a3029cfb..1519b2f2 100644 --- a/public_html/js/Presenters/TagPresenter.js +++ b/public_html/js/Presenters/TagPresenter.js @@ -8,6 +8,7 @@ App.Presenters.TagPresenter = function( promise, auth, api, + tagList, router, keyboard, topNavigationPresenter, @@ -117,6 +118,7 @@ App.Presenters.TagPresenter = function( tag = response.json; render(); renderPosts(posts); + tagList.refreshTags(); }).fail(function(response) { window.alert(response.json && response.json.error || 'An error occured.'); }); @@ -147,4 +149,4 @@ App.Presenters.TagPresenter = function( }; -App.DI.register('tagPresenter', ['_', 'jQuery', 'util', 'promise', 'auth', 'api', 'router', 'keyboard', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.TagPresenter); +App.DI.register('tagPresenter', ['_', 'jQuery', 'util', 'promise', 'auth', 'api', 'tagList', 'router', 'keyboard', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.TagPresenter); diff --git a/public_html/js/Services/TagList.js b/public_html/js/Services/TagList.js index 6ba1691d..8410f071 100644 --- a/public_html/js/Services/TagList.js +++ b/public_html/js/Services/TagList.js @@ -4,22 +4,25 @@ App.Services = App.Services || {}; App.Services.TagList = function(jQuery) { var tags = []; - jQuery.ajax({ - success: function(data, textStatus, xhr) { - tags = data; - }, - error: function(xhr, textStatus, errorThrown) { - console.log(new Error(errorThrown)); - }, - type: 'GET', - url: '/data/tags.json', - }); + function refreshTags() { + jQuery.ajax({ + success: function(data, textStatus, xhr) { + tags = data; + }, + error: function(xhr, textStatus, errorThrown) { + console.log(new Error(errorThrown)); + }, + type: 'GET', + url: '/data/tags.json', + }); + } function getTags() { return tags; } return { + refreshTags: refreshTags, getTags: getTags, }; };