0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-01 02:41:39 -05:00

Fixed handling of labs flag for Offers

no-issue

Because we only called `init` if the labs flag is enabled, when starting
up a site without the flag enabled - the listener for adding redirects
wasn't active. So new Offers would not have their redirects setup.
This commit is contained in:
Fabien O'Carroll 2021-10-12 14:13:47 +02:00 committed by Fabien 'egg' O'Carroll
parent f8b19f286a
commit 37deda3587

View file

@ -25,15 +25,22 @@ module.exports = {
this.api = offersModule.api;
this.repository = offersModule.repository;
let initCalled = false;
if (labs.isSet('offers')) {
// handles setting up redirects
await offersModule.init();
const promise = offersModule.init();
initCalled = true;
await promise;
}
// TODO: Delete after GA
let offersEnabled = labs.isSet('offers');
events.on('settings.labs.edited', async () => {
if (labs.isSet('offers') !== offersEnabled) {
if (labs.isSet('offers') && !initCalled) {
const promise = offersModule.init();
initCalled = true;
await promise;
} else if (labs.isSet('offers') !== offersEnabled) {
offersEnabled = labs.isSet('offers');
if (offersEnabled) {