Topbar unread drawer #28
+12
-8
@@ -289,14 +289,18 @@
|
|||||||
.off('show.bs.dropdown.westgateUnread')
|
.off('show.bs.dropdown.westgateUnread')
|
||||||
.on('show.bs.dropdown.westgateUnread', '.wg-topbar [component="unread"]', function () {
|
.on('show.bs.dropdown.westgateUnread', '.wg-topbar [component="unread"]', function () {
|
||||||
const menuEl = this.querySelector('[data-wg-unread-menu]');
|
const menuEl = this.querySelector('[data-wg-unread-menu]');
|
||||||
require(['api'], function (api) {
|
const relativePath = (window.config && window.config.relative_path) || '';
|
||||||
api.get('/unread', {}, function (err, data) {
|
fetch(relativePath + '/api/unread', {
|
||||||
if (err) {
|
headers: { accept: 'application/json' },
|
||||||
renderUnreadMenu(menuEl, []);
|
}).then(function (res) {
|
||||||
return;
|
if (!res.ok) {
|
||||||
}
|
throw new Error('unread fetch failed: ' + res.status);
|
||||||
renderUnreadMenu(menuEl, data && data.topics);
|
}
|
||||||
});
|
return res.json();
|
||||||
|
}).then(function (data) {
|
||||||
|
renderUnreadMenu(menuEl, data && data.topics);
|
||||||
|
}).catch(function () {
|
||||||
|
renderUnreadMenu(menuEl, []);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ assert(
|
|||||||
'client.js should fetch unread topics when the unread dropdown opens'
|
'client.js should fetch unread topics when the unread dropdown opens'
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
client.includes("api.get('/unread'"),
|
client.includes("'/api/unread'"),
|
||||||
'client.js should load the unread list from the /unread API'
|
'client.js should load the unread list from the /unread API'
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
|
|||||||
Reference in New Issue
Block a user