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:
parent
f8b19f286a
commit
37deda3587
1 changed files with 9 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue