Skip to content
Snippets Groups Projects
Commit 529ea62a authored by RMidhunSuresh's avatar RMidhunSuresh
Browse files

Use a segment to minimize CB

parent bee810a7
No related branches found
No related tags found
No related merge requests found
...@@ -56,7 +56,7 @@ function allowsChild(parent, child) { ...@@ -56,7 +56,7 @@ function allowsChild(parent, child) {
const { type } = child; const { type } = child;
switch (parent?.type) { switch (parent?.type) {
case undefined: case undefined:
return type === "start" || type === "account-setup" || type === "timeline"; return type === "start" || type === "account-setup" || type === "timeline" || type === "minimize";
default: default:
return false; return false;
} }
......
...@@ -36,7 +36,7 @@ class PolicyAgreementView extends TemplateView<AccountSetupViewModel> { ...@@ -36,7 +36,7 @@ class PolicyAgreementView extends TemplateView<AccountSetupViewModel> {
t.div({ className: "PolicyAgreementView_btn-collection" }, t.div({ className: "PolicyAgreementView_btn-collection" },
[ [
t.button({ onClick: () => vm.completeRegistration(), className: "PolicyAgreementView_next", }, "Accept and continue to chat"), t.button({ onClick: () => vm.completeRegistration(), className: "PolicyAgreementView_next", }, "Accept and continue to chat"),
t.button({ onClick: () => (window as any).sendMinimizeToParent(), className: "button-action PolicyAgreementView_cancel", }, "Cancel"), t.button({ onClick: () => vm.minimize(), className: "button-action PolicyAgreementView_cancel", }, "Cancel"),
]), ]),
]); ]);
} }
......
...@@ -97,6 +97,11 @@ export class AccountSetupViewModel extends ViewModel { ...@@ -97,6 +97,11 @@ export class AccountSetupViewModel extends ViewModel {
} }
} }
minimize(): void {
(window as any).sendMinimizeToParent();
this.navigation.push("minimize");
}
private get _homeserver(): string { private get _homeserver(): string {
return this._config.homeserver; return this._config.homeserver;
} }
......
...@@ -13,13 +13,11 @@ function createCustomTileClassForEntry(ownUserId: string) { ...@@ -13,13 +13,11 @@ function createCustomTileClassForEntry(ownUserId: string) {
export class ChatterboxViewModel extends ViewModel { export class ChatterboxViewModel extends ViewModel {
private _roomViewModel?: typeof RoomViewModel; private _roomViewModel?: typeof RoomViewModel;
private _loginPromise: Promise<void>; private _loginPromise: Promise<void>;
private _minimize: () => void;
constructor(options) { constructor(options) {
super(options); super(options);
this._client = options.client; this._client = options.client;
this._loginPromise = options.loginPromise; this._loginPromise = options.loginPromise;
this._minimize = options.minimize;
} }
async load() { async load() {
...@@ -102,7 +100,7 @@ export class ChatterboxViewModel extends ViewModel { ...@@ -102,7 +100,7 @@ export class ChatterboxViewModel extends ViewModel {
minimize() { minimize() {
(window as any).sendMinimizeToParent(); (window as any).sendMinimizeToParent();
this._minimize(); this.navigation.push("minimize");
} }
get timelineViewModel() { get timelineViewModel() {
......
...@@ -23,21 +23,27 @@ export class RootViewModel extends ViewModel { ...@@ -23,21 +23,27 @@ export class RootViewModel extends ViewModel {
this._config = config; this._config = config;
this._client = new Client(this.platform); this._client = new Client(this.platform);
this._setupNavigation(); this._setupNavigation();
this._messageFromParent.on("maximize", () => this._showTimeline(Promise.resolve())); this._messageFromParent.on("maximize", () => this.start());
// Chatterbox can be minimized via the start button on the parent page! // Chatterbox can be minimized via the start button on the parent page!
this._messageFromParent.on("minimize", () => this.minimizeChatterbox()); this._messageFromParent.on("minimize", () => this.navigation.push("minimize"));
} }
private _setupNavigation() { private _setupNavigation() {
this.navigation.observe("account-setup").subscribe(() => this._showAccountSetup()); this.navigation.observe("account-setup").subscribe(() => this._showAccountSetup());
this.navigation.observe("timeline").subscribe((loginPromise) => this._showTimeline(loginPromise)); this.navigation.observe("timeline").subscribe((loginPromise) => this._showTimeline(loginPromise));
this.navigation.observe("minimize").subscribe(() => this.minimizeChatterbox());
} }
async start() { async start() {
const sessionAlreadyExists = await this.attemptStartWithExistingSession(); const sessionAlreadyExists = await this.attemptStartWithExistingSession();
if (sessionAlreadyExists) { if (sessionAlreadyExists) {
this._watchNotificationCount(); if (!this._isWatchingNotificationCount) {
this._watchNotificationCount();
}
if (this._startMinimized) { if (this._startMinimized) {
// when CB is maximized, this function is run again
// don't start in minimized state then
this._startMinimized = false;
return; return;
} }
this.navigation.push("timeline"); this.navigation.push("timeline");
...@@ -55,7 +61,6 @@ export class RootViewModel extends ViewModel { ...@@ -55,7 +61,6 @@ export class RootViewModel extends ViewModel {
config: this._config, config: this._config,
state: this._state, state: this._state,
loginPromise, loginPromise,
minimize: () => this.minimizeChatterbox()
}) })
)); ));
await this._chatterBoxViewModel.load(); await this._chatterBoxViewModel.load();
...@@ -122,6 +127,7 @@ export class RootViewModel extends ViewModel { ...@@ -122,6 +127,7 @@ export class RootViewModel extends ViewModel {
minimizeChatterbox() { minimizeChatterbox() {
this._chatterBoxViewModel = this.disposeTracked(this._chatterBoxViewModel); this._chatterBoxViewModel = this.disposeTracked(this._chatterBoxViewModel);
this._accountSetupViewModel = this.disposeTracked(this._chatterBoxViewModel);
this._activeSection = ""; this._activeSection = "";
this.emitChange("chatterboxViewModel"); this.emitChange("chatterboxViewModel");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment