FIX: stop sync of tracking state when list is filtered

This stops sync of tracking state when list is filtered, in the past this
would cause the tracking state to go off wack.

Additionally this introduces an alias for "filter=tracking", called "f=tracking"

This was done cause the term "filter" is used internally in 2 different ways
the main way is for /unread /new filtering.

Trying to also call a query param "filter" causes enormous amounts of
internal pain, this circumvents the issue.
This commit is contained in:
Sam Saffron 2020-08-06 16:33:45 +10:00
parent 255b0e9f14
commit ba482c251c
No known key found for this signature in database
GPG Key ID: B9606168D2FFD9F5
4 changed files with 18 additions and 5 deletions

View File

@ -14,7 +14,8 @@ export const queryParams = {
q: { replace: true, refreshModel: true }, q: { replace: true, refreshModel: true },
tags: { replace: true }, tags: { replace: true },
before: { replace: true, refreshModel: true }, before: { replace: true, refreshModel: true },
bumped_before: { replace: true, refreshModel: true } bumped_before: { replace: true, refreshModel: true },
f: { replace: true, refreshModel: true }
}; };
// Basic controller options // Basic controller options

View File

@ -315,7 +315,7 @@ const TopicTrackingState = EmberObject.extend({
}); });
}, },
sync(list, filter) { sync(list, filter, queryParams) {
const tracker = this, const tracker = this,
states = tracker.states; states = tracker.states;
@ -368,7 +368,18 @@ const TopicTrackingState = EmberObject.extend({
}); });
// Correct missing states, safeguard in case message bus is corrupt // Correct missing states, safeguard in case message bus is corrupt
if ((filter === "new" || filter === "unread") && !list.more_topics_url) { let shouldCompensate =
(filter === "new" || filter === "unread") && !list.more_topics_url;
if (shouldCompensate && queryParams) {
Object.keys(queryParams).forEach(k => {
if (k !== "ascending" && k !== "order") {
shouldCompensate = false;
}
});
}
if (shouldCompensate) {
const ids = {}; const ids = {};
list.topics.forEach(r => (ids["t" + r.id] = true)); list.topics.forEach(r => (ids["t" + r.id] = true));

View File

@ -65,7 +65,7 @@ function findTopicList(store, tracking, filter, filterParams, extras) {
}).then(function(list) { }).then(function(list) {
list.set("listParams", filterParams); list.set("listParams", filterParams);
if (tracking) { if (tracking) {
tracking.sync(list, list.filter); tracking.sync(list, list.filter, filterParams);
tracking.trackIncoming(list.filter); tracking.trackIncoming(list.filter);
} }
Session.currentProp("topicList", list); Session.currentProp("topicList", list);

View File

@ -52,6 +52,7 @@ class TopicQuery
state state
search search
q q
f
group_name group_name
tags tags
match_all_tags match_all_tags
@ -806,7 +807,7 @@ class TopicQuery
end end
end end
if (filter = options[:filter]) && @user if (filter = (options[:filter] || options[:f])) && @user
action = action =
if filter == "bookmarked" if filter == "bookmarked"
PostActionType.types[:bookmark] PostActionType.types[:bookmark]