mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-22 19:14:52 +01:00
correctly pass options to ViewModel ctor
This commit is contained in:
parent
0eefc88fe3
commit
b0e59c30dd
@ -4,12 +4,12 @@ import {SessionPickerViewModel} from "./SessionPickerViewModel.js";
|
||||
import {ViewModel} from "./ViewModel.js";
|
||||
|
||||
export class BrawlViewModel extends ViewModel {
|
||||
constructor({createSessionContainer, sessionInfoStorage, storageFactory, clock}) {
|
||||
super();
|
||||
constructor(options) {
|
||||
super(options);
|
||||
const {createSessionContainer, sessionInfoStorage, storageFactory} = options;
|
||||
this._createSessionContainer = createSessionContainer;
|
||||
this._sessionInfoStorage = sessionInfoStorage;
|
||||
this._storageFactory = storageFactory;
|
||||
this._clock = clock;
|
||||
|
||||
this._error = null;
|
||||
this._sessionViewModel = null;
|
||||
|
@ -3,8 +3,9 @@ import {SyncStatus} from "../matrix/Sync.js";
|
||||
import {ViewModel} from "./ViewModel.js";
|
||||
|
||||
export class SessionLoadViewModel extends ViewModel {
|
||||
constructor({createAndStartSessionContainer, sessionCallback, homeserver, deleteSessionOnCancel}) {
|
||||
super();
|
||||
constructor(options) {
|
||||
super(options);
|
||||
const {createAndStartSessionContainer, sessionCallback, homeserver, deleteSessionOnCancel} = options;
|
||||
this._createAndStartSessionContainer = createAndStartSessionContainer;
|
||||
this._sessionCallback = sessionCallback;
|
||||
this._homeserver = homeserver;
|
||||
|
@ -4,7 +4,7 @@ import {ViewModel} from "./ViewModel.js";
|
||||
|
||||
class SessionItemViewModel extends ViewModel {
|
||||
constructor(sessionInfo, pickerVM) {
|
||||
super();
|
||||
super({});
|
||||
this._pickerVM = pickerVM;
|
||||
this._sessionInfo = sessionInfo;
|
||||
this._isDeleting = false;
|
||||
@ -100,8 +100,9 @@ class SessionItemViewModel extends ViewModel {
|
||||
|
||||
|
||||
export class SessionPickerViewModel extends ViewModel {
|
||||
constructor({storageFactory, sessionInfoStorage, sessionCallback, createSessionContainer}) {
|
||||
super();
|
||||
constructor(options) {
|
||||
super(options);
|
||||
const {storageFactory, sessionInfoStorage, sessionCallback, createSessionContainer} = options;
|
||||
this._storageFactory = storageFactory;
|
||||
this._sessionInfoStorage = sessionInfoStorage;
|
||||
this._sessionCallback = sessionCallback;
|
||||
|
@ -6,10 +6,10 @@ import {EventEmitter} from "../utils/EventEmitter.js";
|
||||
import {Disposables} from "../utils/Disposables.js";
|
||||
|
||||
export class ViewModel extends EventEmitter {
|
||||
constructor(options) {
|
||||
constructor({clock} = {}) {
|
||||
super();
|
||||
this.disposables = null;
|
||||
this._options = options;
|
||||
this._options = {clock};
|
||||
}
|
||||
|
||||
childOptions(explicitOptions) {
|
||||
@ -21,6 +21,7 @@ export class ViewModel extends EventEmitter {
|
||||
this.disposables = new Disposables();
|
||||
}
|
||||
this.disposables.track(disposable);
|
||||
return disposable;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
@ -29,8 +30,18 @@ export class ViewModel extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
disposeTracked(disposable) {
|
||||
if (this.disposables) {
|
||||
return this.disposables.disposeTracked(disposable);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: this will need to support binding
|
||||
// if any of the expr is a function, assume the function is a binding, and return a binding function ourselves
|
||||
//
|
||||
// translated string should probably always be bindings, unless we're fine with a refresh when changing the language?
|
||||
// we probably are, if we're using routing with a url, we could just refresh.
|
||||
i18n(parts, ...expr) {
|
||||
// just concat for now
|
||||
let result = "";
|
||||
@ -46,4 +57,8 @@ export class ViewModel extends EventEmitter {
|
||||
emitChange(changedProps) {
|
||||
this.emit("change", changedProps);
|
||||
}
|
||||
|
||||
get clock() {
|
||||
return this._options.clock;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user