From 049a477008f380e26d2a66b25dbedbfbfdd6eba5 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Wed, 27 Apr 2022 12:27:19 +0530 Subject: [PATCH 1/9] Pass flowSelector from Client.startRegistration --- src/matrix/Client.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/matrix/Client.js b/src/matrix/Client.js index b24c1ec9..21175a7f 100644 --- a/src/matrix/Client.js +++ b/src/matrix/Client.js @@ -132,14 +132,15 @@ export class Client { }); } - async startRegistration(homeserver, username, password, initialDeviceDisplayName) { + async startRegistration(homeserver, username, password, initialDeviceDisplayName, flowSelector) { const request = this._platform.request; const hsApi = new HomeServerApi({homeserver, request}); const registration = new Registration(hsApi, { username, password, initialDeviceDisplayName, - }); + }, + flowSelector); return registration; } From c07a42292cb5ef7829d938f860afbb1175717f28 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Wed, 27 Apr 2022 12:28:48 +0530 Subject: [PATCH 2/9] Include Platform change in sdk docs --- doc/SDK.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/SDK.md b/doc/SDK.md index 54e37cca..cd81f15b 100644 --- a/doc/SDK.md +++ b/doc/SDK.md @@ -53,7 +53,7 @@ import "hydrogen-view-sdk/theme-element-light.css"; async function main() { const app = document.querySelector('#app')! const config = {}; - const platform = new Platform(app, assetPaths, config, { development: import.meta.env.DEV }); + const platform = new Platform({container: app, assetPaths, config, options: { development: import.meta.env.DEV }}); const navigation = createNavigation(); platform.setNavigation(navigation); const urlRouter = createRouter({ From 83664a1b13d266eb0b6d49f09a37f28753b293dc Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Wed, 27 Apr 2022 12:38:12 +0530 Subject: [PATCH 3/9] viewClassForTile is needed for TimelineView --- doc/SDK.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/SDK.md b/doc/SDK.md index cd81f15b..3f5bdb09 100644 --- a/doc/SDK.md +++ b/doc/SDK.md @@ -31,7 +31,8 @@ import { createNavigation, createRouter, RoomViewModel, - TimelineView + TimelineView, + viewClassForTile } from "hydrogen-view-sdk"; import downloadSandboxPath from 'hydrogen-view-sdk/download-sandbox.html?url'; import workerPath from 'hydrogen-view-sdk/main.js?url'; @@ -88,7 +89,7 @@ async function main() { navigation, }); await vm.load(); - const view = new TimelineView(vm.timelineViewModel); + const view = new TimelineView(vm.timelineViewModel, viewClassForTile); app.appendChild(view.mount()); } } From 139a87de994463f4ce95efb498832be4b5b2a49c Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Sun, 8 May 2022 19:14:51 +0530 Subject: [PATCH 4/9] Pass a copy of the options to the tiles --- src/domain/session/room/timeline/TilesCollection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/domain/session/room/timeline/TilesCollection.js b/src/domain/session/room/timeline/TilesCollection.js index 173b0cf6..d8dd660d 100644 --- a/src/domain/session/room/timeline/TilesCollection.js +++ b/src/domain/session/room/timeline/TilesCollection.js @@ -35,7 +35,7 @@ export class TilesCollection extends BaseObservableList { _createTile(entry) { const Tile = this._tileOptions.tileClassForEntry(entry); if (Tile) { - return new Tile(entry, this._tileOptions); + return new Tile(entry, { ...this._tileOptions }); } } From 6beff7e55255a8c6635dd855d2906113d360c261 Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Mon, 9 May 2022 14:09:45 +0200 Subject: [PATCH 5/9] override emitChange so no need to clone option object for all tiles instead, we don't store the emitChange in the options but rather on the tile itself. --- .../session/room/timeline/TilesCollection.js | 2 +- .../session/room/timeline/tiles/SimpleTile.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/domain/session/room/timeline/TilesCollection.js b/src/domain/session/room/timeline/TilesCollection.js index d8dd660d..173b0cf6 100644 --- a/src/domain/session/room/timeline/TilesCollection.js +++ b/src/domain/session/room/timeline/TilesCollection.js @@ -35,7 +35,7 @@ export class TilesCollection extends BaseObservableList { _createTile(entry) { const Tile = this._tileOptions.tileClassForEntry(entry); if (Tile) { - return new Tile(entry, { ...this._tileOptions }); + return new Tile(entry, this._tileOptions); } } diff --git a/src/domain/session/room/timeline/tiles/SimpleTile.js b/src/domain/session/room/timeline/tiles/SimpleTile.js index b8a7121e..04141576 100644 --- a/src/domain/session/room/timeline/tiles/SimpleTile.js +++ b/src/domain/session/room/timeline/tiles/SimpleTile.js @@ -22,6 +22,7 @@ export class SimpleTile extends ViewModel { constructor(entry, options) { super(options); this._entry = entry; + this._emitUpdate = undefined; } // view model props for all subclasses // hmmm, could also do instanceof ... ? @@ -67,16 +68,20 @@ export class SimpleTile extends ViewModel { // TilesCollection contract below setUpdateEmit(emitUpdate) { - this.updateOptions({emitChange: paramName => { + this._emitUpdate = emitUpdate; + } + + /** overrides the emitChange in ViewModel to also emit the update over the tiles collection */ + emitChange(changedProps) { + if (this._emitUpdate) { // it can happen that after some network call // we switched away from the room and the response // comes in, triggering an emitChange in a tile that // has been disposed already (and hence the change // callback has been cleared by dispose) We should just ignore this. - if (emitUpdate) { - emitUpdate(this, paramName); - } - }}); + this._emitUpdate(this, changedProps); + } + super.emitChange(changedProps); } get upperEntry() { From 3888291758a82fd59d20c31549861a048b2fe67c Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Mon, 9 May 2022 14:10:50 +0200 Subject: [PATCH 6/9] updateOptions is unused,not the best idea since options is/can be shared --- src/domain/ViewModel.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/domain/ViewModel.ts b/src/domain/ViewModel.ts index 8b8581ae..8c12829a 100644 --- a/src/domain/ViewModel.ts +++ b/src/domain/ViewModel.ts @@ -115,10 +115,6 @@ export class ViewModel extends EventEmitter<{change return result; } - updateOptions(options: O): void { - this._options = Object.assign(this._options, options); - } - emitChange(changedProps: any): void { if (this._options.emitChange) { this._options.emitChange(changedProps); From e903d3a6a47200d950b180ffab6d7d9a8226b3bf Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Mon, 9 May 2022 14:12:31 +0200 Subject: [PATCH 7/9] mark options as readonly --- src/domain/ViewModel.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/domain/ViewModel.ts b/src/domain/ViewModel.ts index 8c12829a..0bc52f6e 100644 --- a/src/domain/ViewModel.ts +++ b/src/domain/ViewModel.ts @@ -40,9 +40,9 @@ export type Options = { export class ViewModel extends EventEmitter<{change: never}> { private disposables?: Disposables; private _isDisposed = false; - private _options: O; + private _options: Readonly; - constructor(options: O) { + constructor(options: Readonly) { super(); this._options = options; } @@ -51,7 +51,7 @@ export class ViewModel extends EventEmitter<{change return Object.assign({}, this._options, explicitOptions); } - get options(): O { return this._options; } + get options(): Readonly { return this._options; } // makes it easier to pass through dependencies of a sub-view model getOption(name: N): O[N] { From b7675f46c4ea7ed956c0a48e5fa6ec11f03a603e Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Wed, 27 Apr 2022 10:20:22 +0100 Subject: [PATCH 8/9] bump sdk version --- scripts/sdk/base-manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sdk/base-manifest.json b/scripts/sdk/base-manifest.json index 7730bbac..312f2913 100644 --- a/scripts/sdk/base-manifest.json +++ b/scripts/sdk/base-manifest.json @@ -1,7 +1,7 @@ { "name": "hydrogen-view-sdk", "description": "Embeddable matrix client library, including view components", - "version": "0.0.10", + "version": "0.0.11", "main": "./hydrogen.es.js", "type": "module" } From 6fde6bbf6b63aecbe5348fa7497df0345bf9204a Mon Sep 17 00:00:00 2001 From: Bruno Windels <274386+bwindels@users.noreply.github.com> Date: Wed, 11 May 2022 14:58:57 +0200 Subject: [PATCH 9/9] bump sdk version --- scripts/sdk/base-manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sdk/base-manifest.json b/scripts/sdk/base-manifest.json index 312f2913..0ed9fdab 100644 --- a/scripts/sdk/base-manifest.json +++ b/scripts/sdk/base-manifest.json @@ -1,7 +1,7 @@ { "name": "hydrogen-view-sdk", "description": "Embeddable matrix client library, including view components", - "version": "0.0.11", + "version": "0.0.12", "main": "./hydrogen.es.js", "type": "module" }