blob: 6319fb7da7b80114258833e853d43357a6879e05 [file] [log] [blame]
AdriĆ  Vilanova61f782f2024-05-31 22:57:24 +00001import DependenciesProviderSingleton, {
2 OptionsProviderDependency,
3 StartupDataStorageDependency,
4} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
5import Script, {
6 ScriptEnvironment,
7 ScriptPage,
8 ScriptRunPhase,
9} from '../../../common/architecture/scripts/Script';
10
11export 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}