mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
🐛 Fixed Ghost out of date notification
closes #9875 - The solution here is a quick patch and should be cleaned up once https://github.com/TryGhost/Ghost/issues/10236 is implemented
This commit is contained in:
parent
17bc79d57e
commit
1211c70eb3
1 changed files with 18 additions and 5 deletions
|
@ -29,13 +29,26 @@ module.exports = {
|
|||
let allNotifications = _private.fetchAllNotifications();
|
||||
allNotifications = _.orderBy(allNotifications, 'addedAt', 'desc');
|
||||
|
||||
// NOTE: Filtering below is just a patch for bigger problem - notifications are not removed
|
||||
// after Ghost update. Logic below should be removed when Ghost upgrade detection
|
||||
// is done (https://github.com/TryGhost/Ghost/issues/10236) and notifications are
|
||||
// be removed permanently on upgrade event.
|
||||
allNotifications = allNotifications.filter((notification) => {
|
||||
// CASE: do not return old release notification
|
||||
if (!notification.custom && notification.message) {
|
||||
const notificationVersion = notification.message.match(/(\d+\.)(\d+\.)(\d+)/),
|
||||
blogVersion = ghostVersion.full.match(/^(\d+\.)(\d+\.)(\d+)/);
|
||||
const ghost20RegEx = /Ghost 2.0 is now available/gi;
|
||||
|
||||
if (notificationVersion && blogVersion && semver.gt(notificationVersion[0], blogVersion[0])) {
|
||||
// CASE: do not return old release notification
|
||||
if (notification.message && (!notification.custom || notification.message.match(ghost20RegEx))) {
|
||||
let notificationVersion = notification.message.match(/(\d+\.)(\d+\.)(\d+)/);
|
||||
|
||||
if (notification.message.match(ghost20RegEx)) {
|
||||
notificationVersion = '2.0.0';
|
||||
} else {
|
||||
notificationVersion = notificationVersion[0];
|
||||
}
|
||||
|
||||
const blogVersion = ghostVersion.full.match(/^(\d+\.)(\d+\.)(\d+)/);
|
||||
|
||||
if (notificationVersion && blogVersion && semver.gt(notificationVersion, blogVersion[0])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue