diff --git a/app/volt/tasks/live_query/live_query.rb b/app/volt/tasks/live_query/live_query.rb index 2b3ef2c9..2b53fdf0 100644 --- a/app/volt/tasks/live_query/live_query.rb +++ b/app/volt/tasks/live_query/live_query.rb @@ -3,7 +3,7 @@ # Tracks a channel and a query on a collection. Alerts # the listener when the data in the query changes. class LiveQuery - attr_reader :current_ids, :collection, :query + attr_reader :current_ids, :collection, :query, :channels def initialize(pool, data_store, collection, query) @pool = pool diff --git a/app/volt/tasks/query_tasks.rb b/app/volt/tasks/query_tasks.rb index 6a9b0d1b..c356109d 100644 --- a/app/volt/tasks/query_tasks.rb +++ b/app/volt/tasks/query_tasks.rb @@ -45,6 +45,10 @@ def initial_data def remove_listener(collection, query) live_query = @volt_app.live_query_pool.lookup(collection, query) live_query.remove_channel(@channel) + + # If query has no more channels remove it from channel_live_queries + @volt_app.channel_live_queries[@channel].delete(live_query) if live_query.channels.blank? + return true end # Removes a channel from all associated live queries