Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface AppProps {
storeService: StoreService;
globalEventService: GlobalEventService;
urlNavigationService: UrlNavigationService;
isFullScreen: boolean;
}

interface PopoverInterface {
Expand Down Expand Up @@ -107,7 +108,9 @@ export const App: React.FC<AppProps> = (props) => {
};

useEffect(() => {
if (props.chatStorage.getChatState() == ChatState.Opened || props.configuration.features?.embedded) {
// we are opening chat on the new page only if it was opened before and if the chat is not in fullscreen mode
const shallOpenChat = !props.isFullScreen && props.chatStorage.getChatState() == ChatState.Opened;
if (shallOpenChat || props.configuration.features?.embedded) {
openChat();
}

Expand Down
11 changes: 11 additions & 0 deletions src/middlewares/device-query.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const fullScreenBreakpoint = 768; // this shall be in sync with the value in src/styles/app.scss

/**
* Check if the device is mobile by running media query.
*/
export const isFullScreen = () => {
// we are implementing this over match media as fullscreen is only if mobile break point is matched
const queryString = `( max-width: ${fullScreenBreakpoint}px )`;
const query = window.matchMedia(queryString);
return query.matches;
};
2 changes: 2 additions & 0 deletions src/spinoco-webchat-plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { GlobalEventService } from "./models/services/global-event-service/globa
import "./styles/app.scss";
import { UrlNavigationService } from "./models/services/dom/url-navigation-service";
import { RuleService } from "./models/services/rule-service";
import { isFullScreen } from "./middlewares/device-query";

declare global {
interface Window {
Expand Down Expand Up @@ -53,6 +54,7 @@ const createWithConfigUrl = (url: string) => {
configuration={configuration}
globalEventService={globalEventService}
urlNavigationService={urlNavigationService}
isFullScreen={isFullScreen()}
/>
</React.StrictMode>,
);
Expand Down
4 changes: 3 additions & 1 deletion src/styles/app.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
$tablet-breakpoint: "768px";


$tablet-breakpoint: "768px"; // when changing breakpoint, also update the `src/middlewares/device-query.tsx` file
$mobile-breakpoint: "384px";

@mixin tablet {
Expand Down