2021-11-16 04:26:39 -05:00
|
|
|
import { action } from "@ember/object";
|
2019-10-23 12:30:52 -04:00
|
|
|
import Component from "@ember/component";
|
2018-02-13 15:58:32 -05:00
|
|
|
import DiscourseURL from "discourse/lib/url";
|
|
|
|
|
2019-10-23 12:30:52 -04:00
|
|
|
export default Component.extend({
|
2021-11-16 04:26:39 -05:00
|
|
|
tagName: "",
|
2018-02-13 15:58:32 -05:00
|
|
|
|
2021-11-16 04:26:39 -05:00
|
|
|
@action
|
|
|
|
openLinks(event) {
|
|
|
|
const dataset = event.target.dataset;
|
2020-07-21 14:29:02 -04:00
|
|
|
|
2021-11-16 04:26:39 -05:00
|
|
|
if (dataset.linkPostId) {
|
|
|
|
event.preventDefault();
|
2020-07-21 14:29:02 -04:00
|
|
|
|
2021-11-16 04:26:39 -05:00
|
|
|
this.store.find("post", dataset.linkPostId).then((post) => {
|
|
|
|
DiscourseURL.routeTo(post.url);
|
|
|
|
});
|
|
|
|
} else if (dataset.linkTopicId) {
|
|
|
|
event.preventDefault();
|
2020-07-21 14:29:02 -04:00
|
|
|
|
2021-11-16 04:26:39 -05:00
|
|
|
DiscourseURL.routeTo(`/t/${dataset.linkTopicId}`);
|
|
|
|
}
|
2018-02-13 15:58:32 -05:00
|
|
|
},
|
|
|
|
});
|