blob: 41e6b5d1a84913a7dac1713d4b28f7e90e0f7796 [file] [log] [blame]
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +02001import Feature from '../common/architecture/features/Feature';
Adrià Vilanova Martínez58cc67c2024-04-21 16:43:01 +02002import AutoRefreshFeature from './autoRefresh/autoRefresh.feature';
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +02003import InfiniteScrollFeature from './infiniteScroll/infiniteScroll.feature';
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +02004import ScriptFilterListProvider from '../common/architecture/scripts/ScriptFilterListProvider';
Adrià Vilanova Martínez66836fd2024-05-04 22:43:06 +02005import ExtraInfoFeature from './extraInfo/extraInfo.feature';
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +02006
7export type ConcreteFeatureClass = { new (): Feature };
8
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +02009export default class Features extends ScriptFilterListProvider {
Adrià Vilanova Martínez58cc67c2024-04-21 16:43:01 +020010 private features: ConcreteFeatureClass[] = [
11 AutoRefreshFeature,
Adrià Vilanova Martínez66836fd2024-05-04 22:43:06 +020012 ExtraInfoFeature,
Adrià Vilanova Martínez58cc67c2024-04-21 16:43:01 +020013 InfiniteScrollFeature,
14 ];
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020015 private initializedFeatures: Feature[];
16
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +020017 protected getUnfilteredScriptsList() {
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020018 const features = this.getFeatures();
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +020019 return features.map((feature) => feature.getScripts()).flat(1);
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020020 }
21
22 private getFeatures() {
23 if (this.initializedFeatures === undefined) {
24 this.initializedFeatures = this.features.map((feature) => new feature());
25 }
26 return this.initializedFeatures;
27 }
28}