mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
rename urlRouter option in view models to urlCreator
This commit is contained in:
parent
0d622164df
commit
5a30855227
@ -70,7 +70,7 @@ export class LoginViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
get cancelUrl() {
|
||||
return this.urlRouter.urlForSegment("session");
|
||||
return this.urlCreator.urlForSegment("session");
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
@ -38,7 +38,7 @@ export class RootViewModel extends ViewModel {
|
||||
async load() {
|
||||
this.track(this.navigation.observe("login").subscribe(() => this._applyNavigation()));
|
||||
this.track(this.navigation.observe("session").subscribe(() => this._applyNavigation()));
|
||||
this._applyNavigation(this.urlRouter.getLastUrl());
|
||||
this._applyNavigation(this.urlCreator.getLastUrl());
|
||||
}
|
||||
|
||||
async _applyNavigation(restoreUrlIfAtDefault) {
|
||||
@ -59,7 +59,7 @@ export class RootViewModel extends ViewModel {
|
||||
} else {
|
||||
try {
|
||||
if (restoreUrlIfAtDefault) {
|
||||
this.urlRouter.pushUrl(restoreUrlIfAtDefault);
|
||||
this.urlCreator.pushUrl(restoreUrlIfAtDefault);
|
||||
} else {
|
||||
const sessionInfos = await this._sessionInfoStorage.getAll();
|
||||
if (sessionInfos.length === 0) {
|
||||
|
@ -76,7 +76,7 @@ class SessionItemViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
get openUrl() {
|
||||
return this.urlRouter.urlForSegment("session", this.id);
|
||||
return this.urlCreator.urlForSegment("session", this.id);
|
||||
}
|
||||
|
||||
get label() {
|
||||
@ -189,6 +189,6 @@ export class SessionPickerViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
get cancelUrl() {
|
||||
return this.urlRouter.urlForSegment("login");
|
||||
return this.urlCreator.urlForSegment("login");
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ export class ViewModel extends EventEmitter {
|
||||
}
|
||||
|
||||
childOptions(explicitOptions) {
|
||||
const {navigation, urlRouter, clock} = this._options;
|
||||
return Object.assign({navigation, urlRouter, clock}, explicitOptions);
|
||||
const {navigation, urlCreator, clock} = this._options;
|
||||
return Object.assign({navigation, urlCreator, clock}, explicitOptions);
|
||||
}
|
||||
|
||||
track(disposable) {
|
||||
@ -99,8 +99,12 @@ export class ViewModel extends EventEmitter {
|
||||
return this._options.clock;
|
||||
}
|
||||
|
||||
get urlRouter() {
|
||||
return this._options.urlRouter;
|
||||
/**
|
||||
* The url router, only meant to be used to create urls with from view models.
|
||||
* @return {URLRouter}
|
||||
*/
|
||||
get urlCreator() {
|
||||
return this._options.urlCreator;
|
||||
}
|
||||
|
||||
get navigation() {
|
||||
|
@ -44,7 +44,7 @@ export class LeftPanelViewModel extends ViewModel {
|
||||
this._roomList = this._roomListFilterMap.sortValues((a, b) => a.compare(b));
|
||||
this._currentTileVM = null;
|
||||
this._setupNavigation();
|
||||
this._closeUrl = this.urlRouter.urlForSegment("session");
|
||||
this._closeUrl = this.urlCreator.urlForSegment("session");
|
||||
}
|
||||
|
||||
get closeUrl() {
|
||||
|
@ -30,7 +30,7 @@ export class RoomTileViewModel extends ViewModel {
|
||||
this._isOpen = false;
|
||||
this._wasUnreadWhenOpening = false;
|
||||
this._hidden = false;
|
||||
this._url = this.urlRouter.openRoomActionUrl(this._room.id);
|
||||
this._url = this.urlCreator.openRoomActionUrl(this._room.id);
|
||||
if (options.isOpen) {
|
||||
this.open();
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ export class RoomViewModel extends ViewModel {
|
||||
this._sendError = null;
|
||||
this._composerVM = new ComposerViewModel(this);
|
||||
this._clearUnreadTimout = null;
|
||||
this._closeUrl = this.urlRouter.urlUntilSegment("session");
|
||||
this._closeUrl = this.urlCreator.urlUntilSegment("session");
|
||||
}
|
||||
|
||||
get closeUrl() {
|
||||
|
@ -143,7 +143,9 @@ export async function main(container, paths, legacyExtras) {
|
||||
sessionInfoStorage,
|
||||
storageFactory,
|
||||
clock,
|
||||
urlRouter,
|
||||
// the only public interface of the router is to create urls,
|
||||
// so we call it that in the view models
|
||||
urlCreator: urlRouter,
|
||||
navigation,
|
||||
updateService: serviceWorkerHandler
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user