Skip to content

Commit

Permalink
Sergei / Livechat reinit without page refresh when user changes theme…
Browse files Browse the repository at this point in the history
… or language (binary-com#8447)

* feat: revert back search_params

* refactor: delete comments and unused imports
  • Loading branch information
sergei-deriv committed May 3, 2023
1 parent ddee41b commit 5575c13
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { useCallback, useEffect, useState } from 'react';
import { useHistory, useParams } from 'react-router';
import { useHistory } from 'react-router';
import { liveChatInitialization } from './live-chat';
import Cookies from 'js-cookie';
import { deriv_urls } from '@deriv/shared';

type TQueryParams = {
lang: string;
dark: string;
};

// Todo: Should break this into smaller hooks or utility functions.
const useLiveChat = (has_cookie_account = false) => {
const [isReady, setIsReady] = useState(false);
const [reload, setReload] = useState(false);
const history = useHistory();
const { lang, dark } = useParams<TQueryParams>();
const search_params = window.location.search;
const widget = window.LiveChatWidget;

const liveChatDeletion = () =>
Expand Down Expand Up @@ -110,7 +105,7 @@ const useLiveChat = (has_cookie_account = false) => {

useEffect(() => {
onHistoryChange();
}, [lang, dark, onHistoryChange]);
}, [search_params, onHistoryChange]);

useEffect(() => {
if (isReady && !widget) {
Expand Down

0 comments on commit 5575c13

Please sign in to comment.