mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
load features at startup and pass them along in all view models
This commit is contained in:
parent
c4944599cf
commit
f65b43f612
@ -30,6 +30,7 @@ import type {Navigation} from "./navigation/Navigation";
|
|||||||
import type {SegmentType} from "./navigation/index";
|
import type {SegmentType} from "./navigation/index";
|
||||||
import type {IURLRouter} from "./navigation/URLRouter";
|
import type {IURLRouter} from "./navigation/URLRouter";
|
||||||
import type { ITimeFormatter } from "../platform/types/types";
|
import type { ITimeFormatter } from "../platform/types/types";
|
||||||
|
import type { FeatureSet } from "../features";
|
||||||
|
|
||||||
export type Options<T extends object = SegmentType> = {
|
export type Options<T extends object = SegmentType> = {
|
||||||
platform: Platform;
|
platform: Platform;
|
||||||
@ -37,6 +38,7 @@ export type Options<T extends object = SegmentType> = {
|
|||||||
urlRouter: IURLRouter<T>;
|
urlRouter: IURLRouter<T>;
|
||||||
navigation: Navigation<T>;
|
navigation: Navigation<T>;
|
||||||
emitChange?: (params: any) => void;
|
emitChange?: (params: any) => void;
|
||||||
|
features: FeatureSet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -142,6 +144,10 @@ export class ViewModel<N extends object = SegmentType, O extends Options<N> = Op
|
|||||||
return this._options.urlRouter;
|
return this._options.urlRouter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get features(): FeatureSet {
|
||||||
|
return this._options.features;
|
||||||
|
}
|
||||||
|
|
||||||
get navigation(): Navigation<N> {
|
get navigation(): Navigation<N> {
|
||||||
// typescript needs a little help here
|
// typescript needs a little help here
|
||||||
return this._options.navigation as unknown as Navigation<N>;
|
return this._options.navigation as unknown as Navigation<N>;
|
||||||
|
@ -18,6 +18,8 @@ limitations under the License.
|
|||||||
// import {RecordRequester, ReplayRequester} from "./matrix/net/request/replay";
|
// import {RecordRequester, ReplayRequester} from "./matrix/net/request/replay";
|
||||||
import {RootViewModel} from "../../domain/RootViewModel.js";
|
import {RootViewModel} from "../../domain/RootViewModel.js";
|
||||||
import {createNavigation, createRouter} from "../../domain/navigation/index";
|
import {createNavigation, createRouter} from "../../domain/navigation/index";
|
||||||
|
import {FeatureSet} from "../../features";
|
||||||
|
|
||||||
// Don't use a default export here, as we use multiple entries during legacy build,
|
// Don't use a default export here, as we use multiple entries during legacy build,
|
||||||
// which does not support default exports,
|
// which does not support default exports,
|
||||||
// see https://github.com/rollup/plugins/tree/master/packages/multi-entry
|
// see https://github.com/rollup/plugins/tree/master/packages/multi-entry
|
||||||
@ -33,6 +35,7 @@ export async function main(platform) {
|
|||||||
// const request = recorder.request;
|
// const request = recorder.request;
|
||||||
// window.getBrawlFetchLog = () => recorder.log();
|
// window.getBrawlFetchLog = () => recorder.log();
|
||||||
await platform.init();
|
await platform.init();
|
||||||
|
const features = await FeatureSet.load(platform.settingsStorage);
|
||||||
const navigation = createNavigation();
|
const navigation = createNavigation();
|
||||||
platform.setNavigation(navigation);
|
platform.setNavigation(navigation);
|
||||||
const urlRouter = createRouter({navigation, history: platform.history});
|
const urlRouter = createRouter({navigation, history: platform.history});
|
||||||
@ -43,6 +46,7 @@ export async function main(platform) {
|
|||||||
// so we call it that in the view models
|
// so we call it that in the view models
|
||||||
urlRouter: urlRouter,
|
urlRouter: urlRouter,
|
||||||
navigation,
|
navigation,
|
||||||
|
features
|
||||||
});
|
});
|
||||||
await vm.load();
|
await vm.load();
|
||||||
platform.createAndMountRootView(vm);
|
platform.createAndMountRootView(vm);
|
||||||
|
Loading…
Reference in New Issue
Block a user