AdriĆ Vilanova | 61f782f | 2024-05-31 22:57:24 +0000 | [diff] [blame] | 1 | import DependenciesProviderSingleton, { |
| 2 | OptionsProviderDependency, |
| 3 | StartupDataStorageDependency, |
| 4 | } from '../../../common/architecture/dependenciesProvider/DependenciesProvider'; |
| 5 | import Script, { |
| 6 | ScriptEnvironment, |
| 7 | ScriptPage, |
| 8 | ScriptRunPhase, |
| 9 | } from '../../../common/architecture/scripts/Script'; |
| 10 | |
| 11 | export default class EnableLoadDraftsFlagInDataStartupScript extends Script { |
| 12 | page = ScriptPage.CommunityConsole; |
| 13 | environment = ScriptEnvironment.ContentScript; |
| 14 | runPhase = ScriptRunPhase.Start; |
| 15 | |
| 16 | async execute() { |
| 17 | const dependenciesProvider = DependenciesProviderSingleton.getInstance(); |
| 18 | const optionsProvider = dependenciesProvider.getDependency( |
| 19 | OptionsProviderDependency, |
| 20 | ); |
| 21 | if (await optionsProvider.isEnabled('loaddrafts')) { |
| 22 | const startupDataStorage = dependenciesProvider.getDependency( |
| 23 | StartupDataStorageDependency, |
| 24 | ); |
| 25 | startupDataStorage.enqueueModification((startupDataModel) => { |
| 26 | startupDataModel.data[4][13] = true; |
| 27 | }); |
| 28 | // NOTE: Workaround because otherwise the modifications would be applied too late. |
| 29 | startupDataStorage.applyModifications(); |
| 30 | } |
| 31 | } |
| 32 | } |