Skip to content

Commit

Permalink
[semver:patch] Fix panel opening states after pre-loading
Browse files Browse the repository at this point in the history
  • Loading branch information
DvirMalka committed Oct 31, 2022
1 parent 86155d2 commit c112b3b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 24 deletions.
8 changes: 6 additions & 2 deletions dist/development/strigo.sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -13411,7 +13411,10 @@ ${JSON.stringify(parsedContext)}` : "");
case "rendered" /* RENDERED */: {
LoggerInstance.info("Panel rendered message received");
setSessionValue("isRendered", true);
window.Strigo?.expandPanel();
removeLoader();
if (shouldPanelBeOpen()) {
window.Strigo?.expandPanel();
}
break;
}
default: {
Expand Down Expand Up @@ -13677,9 +13680,10 @@ ${JSON.stringify(parsedContext)}` : "");
this.config.configured = true;
LoggerInstance.info("Finished SDK setup.");
if (openWidget2) {
const shouldPanelBeOpen2 = shouldPanelBeOpen();
this.open();
setSessionValue("shouldPanelBeOpen", false);
this.collapse();
setSessionValue("shouldPanelBeOpen", shouldPanelBeOpen2);
}
} catch (err) {
LoggerInstance.error("Could not setup SDK", { err });
Expand Down
4 changes: 2 additions & 2 deletions dist/development/styles/strigo-academy-hat.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
border-radius: 50%;
display: inline-block;
box-sizing: border-box;
animation: rotation 0.6s linear infinite;
animation: rotation 0.5s linear infinite;
}
@keyframes rotation {
0% {
Expand All @@ -32,7 +32,7 @@
align-items: center;
justify-content: center;
cursor: pointer;
box-shadow: 0px 2px 1px rgba(0, 0, 0, 0.12), 0px 5px 8px rgba(0, 0, 0, 0.26);
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.2);
border-radius: 8px 0px 0px 8px;
background-color: var(--customizable-hat-bg-color);
z-index: 9999999999;
Expand Down
30 changes: 15 additions & 15 deletions dist/production/strigo.sdk.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/production/styles/strigo-academy-hat.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/modules/listeners/listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as configManager from '../config/config';
import overlayWidget from '../widgets/overlay';
import { Logger } from '../../services/logger';
import { WidgetFlavors } from '../widgets/widget.types';
import { openWidget } from '../document/document';
import { openWidget, removeLoader } from '../document/document';

import { EventTypes, MessageTypes } from './listeners.types';

Expand Down Expand Up @@ -82,6 +82,7 @@ function onHostEventHandler(ev: MessageEvent<unknown>): void {
case MessageTypes.RENDERED: {
Logger.info('Panel rendered message received');
sessionManager.setSessionValue('isRendered', true);
removeLoader();

if (sessionManager.shouldPanelBeOpen()) {
window.Strigo?.expandPanel();
Expand Down
2 changes: 1 addition & 1 deletion src/modules/session/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export function getSession(): StrigoSession {
}

export function shouldPanelBeOpen(): boolean {

return getSession() ? getSession().shouldPanelBeOpen : true;

}

export function getWidgetFlavor(): WidgetFlavors {
Expand Down
7 changes: 5 additions & 2 deletions src/strigo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class StrigoSDK implements IStrigoSDK {
init(): void {
try {
Logger.info('Initializing SDK...');
sessionManager.setSessionValue('shouldPanelBeOpen', true);

if (this.config.initialized) {
Logger.info('SDK was already initialized');
Expand Down Expand Up @@ -150,10 +149,14 @@ class StrigoSDK implements IStrigoSDK {
Logger.info('Finished SDK setup.');

if (openWidget) {
// Save the original state of the panel
const shouldPanelBeOpen = sessionManager.shouldPanelBeOpen();
this.open();

// Collapse the panel so it would open when fully loaded
this.collapse();

// Return the original state of the panel after collapsing
sessionManager.setSessionValue('shouldPanelBeOpen', shouldPanelBeOpen);
}
} catch (err) {
Logger.error('Could not setup SDK', { err });
Expand Down

0 comments on commit c112b3b

Please sign in to comment.