FIX: Read FAQ wasn't working with a URL on the same site

This commit is contained in:
Robin Ward 2016-08-12 13:47:19 -04:00
parent 11939fa8b9
commit 86c970bac0

View File

@ -4,7 +4,7 @@ import DiscourseURL from 'discourse/lib/url';
import { ajax } from 'discourse/lib/ajax'; import { ajax } from 'discourse/lib/ajax';
createWidget('priority-faq-link', { createWidget('priority-faq-link', {
tagName: 'a.faq-priority', tagName: 'a.faq-priority.widget-link',
buildAttributes(attrs) { buildAttributes(attrs) {
return { href: attrs.href }; return { href: attrs.href };
@ -15,12 +15,14 @@ createWidget('priority-faq-link', {
}, },
click(e) { click(e) {
e.preventDefault();
if (this.siteSettings.faq_url === this.attrs.href) { if (this.siteSettings.faq_url === this.attrs.href) {
e.preventDefault();
ajax("/users/read-faq", { method: "POST" }).then(() => { ajax("/users/read-faq", { method: "POST" }).then(() => {
this.currentUser.set('read_faq', true); this.currentUser.set('read_faq', true);
return DiscourseURL.routeToTag($(e.target).closest('a')[0]); DiscourseURL.routeToTag($(e.target).closest('a')[0]);
}); });
} else {
DiscourseURL.routeToTag($(e.target).closest('a')[0]);
} }
} }
}); });