Refresh podcast tabs on focus to have better synchronization with auto-ingest backend

This commit is contained in:
Duncan Sommerville 2015-10-28 13:43:21 -04:00
parent e8643e04eb
commit 05f51a9a2d
3 changed files with 21 additions and 2 deletions

View File

@ -180,7 +180,7 @@ class Rest_PodcastController extends Zend_Rest_Controller
case HttpRequestType::GET:
foreach($ids as $id) {
// TODO: This should use the same code path as the GET action.
// It essentially does, except for the randering of the tab layout.
// It essentially does, except for the rendering of the tab layout.
// That said, not every GET is going to need the page rendered...
// Where should the rendering code for the podcast tabs go? -- Duncan
$responseBody[] = Application_Service_PodcastService::buildPodcastEditorResponse($id, $this->view);

View File

@ -23,6 +23,17 @@ var AIRTIME = (function (AIRTIME) {
tab.contents.find("table").attr("id", "podcast_episodes_" + podcast.id);
var episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable(podcast.episodes, tab);
// Override the switchTo function to reload the table when the tab is focused.
// Should help to reduce the number of cases where the frontend doesn't match the state
// of the backend (due to automatic ingestion).
// Note that these cases should already be very few and far between.
// TODO: make sure this doesn't noticeably slow performance
// XXX: it's entirely possible that this (in the angular app) is not where we want this function...
tab.switchTo = function() {
AIRTIME.tabs.Tab.prototype.switchTo.call(this);
episodeTable.reload($scope.podcast.id);
};
function updatePodcast() {
$http.put(endpoint + $scope.podcast.id, { csrf_token: $scope.csrf, podcast: $scope.podcast })
.success(function() {
@ -193,7 +204,8 @@ var AIRTIME = (function (AIRTIME) {
'iFixedColumns': 1 // Checkbox
}
}
});
}
);
podcastEpisodesTableWidget.getDatatable().addTitles("td");
return podcastEpisodesTableWidget;

View File

@ -327,6 +327,13 @@ var AIRTIME = (function(AIRTIME){
$("#show_builder_table_wrapper").css("top", h + 5);
};
/**
* Expose the Tab object so it can be subclassed
*
* @type {Function}
*/
mod.Tab = Tab;
return AIRTIME;
}(AIRTIME || {}));