Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #415 from rupato-deriv/Rupato/check-post-messages
Browse files Browse the repository at this point in the history
Rpuato/test check post messages
  • Loading branch information
rupato-deriv authored Feb 26, 2024
2 parents bc72584 + f5737a0 commit 824e794
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/components/Main/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,25 @@ const Main = () => {
}
loginAndSetTokens(token_list)
.then(({ account_info = {} }) => {
console.log(account_info, '1st');
if (account_info?.loginid) {
console.log(account_info, '2nd');
dispatch(setLoginId(account_info?.loginid));
dispatch(updateIsLogged(true));
dispatch(updateActiveAccount(account_info));
applyToolboxPermissions();
syncWithDerivApp();
} else {
console.log(account_info, '3rd');
dispatch(updateIsLogged(false));
}
})
.catch(() => {
console.log('6th');
dispatch(updateIsLogged(false));
})
.finally(() => {
console.log('5th');
resolve();
dispatch(setAccountSwitcherLoader(false));
});
Expand Down
9 changes: 7 additions & 2 deletions src/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,13 @@ export const removeAllTokens = () => {
export const isDone = varName => varName in store;

export const syncWithDerivApp = () => {
console.log('syncWithDerivApp');

Check warning on line 152 in src/storage.js

View workflow job for this annotation

GitHub Actions / Build, Test and Deploy to Cloudflare Pages

Unexpected console statement
const iframe = document.getElementById('localstorage-sync');
const { origin } = getRelatedDeriveOrigin();
console.log({ origin, client_acc: JSON.stringify(getClientAccounts()), active_login_id: getActiveLoginId() });

Check warning on line 155 in src/storage.js

View workflow job for this annotation

GitHub Actions / Build, Test and Deploy to Cloudflare Pages

Unexpected console statement

const postMessages = () => {
console.log('postMessages');

Check warning on line 158 in src/storage.js

View workflow job for this annotation

GitHub Actions / Build, Test and Deploy to Cloudflare Pages

Unexpected console statement
iframe.contentWindow.postMessage(
{
key: CLIENT_ACCOUNT,
Expand All @@ -170,8 +173,10 @@ export const syncWithDerivApp = () => {
};
if (iframe) {
if (document.readyState === 'complete' || document.readyState === 'interactive') {
postMessages();
return;
console.log(document.readyState);

Check warning on line 176 in src/storage.js

View workflow job for this annotation

GitHub Actions / Build, Test and Deploy to Cloudflare Pages

Unexpected console statement
setTimeout(() => {
postMessages();
}, 100);
}
if (!hasReadystateListener) {
hasReadystateListener = true;
Expand Down

0 comments on commit 824e794

Please sign in to comment.