From 07a921c92c62ab274a1a7e39f1303ba21426a01d Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 27 Feb 2015 17:22:47 -0500 Subject: [PATCH] Get dynamic title support working --- static/js/services/meta-service.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/static/js/services/meta-service.js b/static/js/services/meta-service.js index 0cd84fc89..f0b4cb989 100644 --- a/static/js/services/meta-service.js +++ b/static/js/services/meta-service.js @@ -4,15 +4,33 @@ angular.module('quay').factory('MetaService', ['$interpolate', 'Config', '$rootScope', '$interval', function($interpolate, Config, $rootScope, $interval) { var metaService = {}; + var intervals = []; var interpolate = function(page, expr, callback) { - $rootScope.$watch(page.scope, function() { + var previous = ''; + + var currentInterval = $interval(function() { var inter = $interpolate(expr, true, null, true); - callback(inter(page.scope)); - }); + var result = inter(page.scope) + + if (result != previous) { + $interval.cancel(currentInterval); + } + + previous = result; + callback(result); + }, 500); + + intervals.push(currentInterval); }; var initial = function(value, default_value, callback) { + for (var i = 0; i < intervals.length; ++i) { + $interval.cancel(intervals[i]); + } + + intervals = []; + if (!value) { callback(default_value); return;