mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 20:03:43 +08:00
FIX: throttles topic tracking shortcut and enforces topic id (#9159)
This commit is contained in:
parent
b4b0443d63
commit
c4cd864c26
|
@ -4,6 +4,7 @@ import DiscourseURL from "discourse/lib/url";
|
||||||
import Composer from "discourse/models/composer";
|
import Composer from "discourse/models/composer";
|
||||||
import { minimumOffset } from "discourse/lib/offset-calculator";
|
import { minimumOffset } from "discourse/lib/offset-calculator";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
import { throttle } from "@ember/runloop";
|
||||||
|
|
||||||
const bindings = {
|
const bindings = {
|
||||||
"!": { postAction: "showFlags" },
|
"!": { postAction: "showFlags" },
|
||||||
|
@ -299,34 +300,26 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
setTrackingToMuted(event) {
|
setTrackingToMuted(event) {
|
||||||
this.appEvents.trigger("topic-notifications-button:changed", {
|
throttle(this, "_setTracking", { id: 0, event }, 250, true);
|
||||||
type: "notification",
|
|
||||||
id: 0,
|
|
||||||
event
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setTrackingToRegular(event) {
|
setTrackingToRegular(event) {
|
||||||
this.appEvents.trigger("topic-notifications-button:changed", {
|
throttle(this, "_setTracking", { id: 1, event }, 250, true);
|
||||||
type: "notification",
|
|
||||||
id: 1,
|
|
||||||
event
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setTrackingToTracking(event) {
|
setTrackingToTracking(event) {
|
||||||
this.appEvents.trigger("topic-notifications-button:changed", {
|
throttle(this, "_setTracking", { id: 2, event }, 250, true);
|
||||||
type: "notification",
|
|
||||||
id: 2,
|
|
||||||
event
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setTrackingToWatching(event) {
|
setTrackingToWatching(event) {
|
||||||
|
throttle(this, "_setTracking", { id: 3, event }, 250, true);
|
||||||
|
},
|
||||||
|
|
||||||
|
_setTracking(params) {
|
||||||
this.appEvents.trigger("topic-notifications-button:changed", {
|
this.appEvents.trigger("topic-notifications-button:changed", {
|
||||||
type: "notification",
|
type: "notification",
|
||||||
id: 3,
|
id: params.id,
|
||||||
event
|
event: params.event
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,17 @@ export default Component.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
_changeTopicNotificationLevel(level) {
|
_changeTopicNotificationLevel(level) {
|
||||||
|
// this change is coming from a keyboard event
|
||||||
|
if (level.event) {
|
||||||
|
const topicSectionNode = level.event.target.querySelector("#topic");
|
||||||
|
if (topicSectionNode && topicSectionNode.dataset.topicId) {
|
||||||
|
const topicId = parseInt(topicSectionNode.dataset.topicId, 10);
|
||||||
|
if (topicId && topicId !== this.topic.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (level.id !== this.notificationLevel) {
|
if (level.id !== this.notificationLevel) {
|
||||||
this.topic.details.updateNotifications(level.id);
|
this.topic.details.updateNotifications(level.id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user