зеркало из https://github.com/mozilla/fxa.git
Merge pull request #17237 from mozilla/FXA-9984
fix(settings): Handle multiple signins to settings
This commit is contained in:
Коммит
63d26f6aa1
|
@ -31,6 +31,8 @@ import PageRecentActivity from './PageRecentActivity';
|
||||||
import PageRecoveryKeyCreate from './PageRecoveryKeyCreate';
|
import PageRecoveryKeyCreate from './PageRecoveryKeyCreate';
|
||||||
import { hardNavigate } from 'fxa-react/lib/utils';
|
import { hardNavigate } from 'fxa-react/lib/utils';
|
||||||
import { SettingsIntegration } from './interfaces';
|
import { SettingsIntegration } from './interfaces';
|
||||||
|
import { currentAccount } from '../../lib/cache';
|
||||||
|
import { setCurrentAccount } from '../../lib/storage-utils';
|
||||||
|
|
||||||
export const Settings = ({
|
export const Settings = ({
|
||||||
integration,
|
integration,
|
||||||
|
@ -38,6 +40,7 @@ export const Settings = ({
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
const { metricsEnabled, hasPassword } = useAccount();
|
const { metricsEnabled, hasPassword } = useAccount();
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
|
const account = useAccount();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (config.metrics.navTiming.enabled && metricsEnabled) {
|
if (config.metrics.navTiming.enabled && metricsEnabled) {
|
||||||
|
@ -51,13 +54,16 @@ export const Settings = ({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function handleWindowFocus() {
|
function handleWindowFocus() {
|
||||||
|
if (account.uid !== currentAccount()?.uid) {
|
||||||
|
setCurrentAccount(account.uid);
|
||||||
|
}
|
||||||
if (session.isDestroyed) {
|
if (session.isDestroyed) {
|
||||||
hardNavigate('/');
|
hardNavigate('/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.addEventListener('focus', handleWindowFocus);
|
window.addEventListener('focus', handleWindowFocus);
|
||||||
return () => window.removeEventListener('focus', handleWindowFocus);
|
return () => window.removeEventListener('focus', handleWindowFocus);
|
||||||
}, [session]);
|
}, [account, session]);
|
||||||
|
|
||||||
const { loading, error } = useInitialSettingsState();
|
const { loading, error } = useInitialSettingsState();
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче