Skip to content

Commit

Permalink
fix: 🐛 change version
Browse files Browse the repository at this point in the history
  • Loading branch information
potter-sun committed Feb 7, 2024
1 parent ec9b8d2 commit 27a735f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions packages/login/src/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ function WebLoginProvider({
const [bridgeType, setBridgeType] = useState('unknown');
const [loginId, setLoginId] = useState(0);

const initVersion = useMemo(
() => (localStorage.getItem(DISCOVER_LOGIN_EARGERLY_KEY) ? localStorage.getItem(WEB_LOGIN_VERSION) || 'v1' : 'v2'),
[],
);
const initVersion = useMemo(() => {
if (localStorage.getItem(DISCOVER_LOGIN_EARGERLY_KEY)) {
return localStorage.getItem(WEB_LOGIN_VERSION) || 'v1';
} else {
return localStorage.getItem(WEB_LOGIN_VERSION) || 'v2';
}
}, []);

const [version, setVersion] = useState<string>(initVersion);
const [changeVerBtnClicked, setChangeVerBtnClicked] = useState<{ version: string }>();
Expand Down Expand Up @@ -137,7 +140,7 @@ function WebLoginProvider({
useEffect(() => {
localStorage.setItem(WEB_LOGIN_VERSION, version === 'v1' ? 'v1' : 'v2');
eventEmitter.emit(WebLoginEvents.CHANGE_PORTKEY_VERSION, changeVerBtnClicked?.version);
}, [version]);
}, [changeVerBtnClicked?.version, eventEmitter, version]);

const setLoginStateInternal = useCallback(
(newLoginState: WebLoginState) => {
Expand Down Expand Up @@ -445,6 +448,7 @@ function WebLoginProvider({
<ExtraWallets
headerClassName={headerClassName}
contentClassName={contentClassName}
version={version}
portkeyApi={version === 'v1' ? portkeyApiV1 : portkeyApi}
elfApi={elfApi}
discoverApi={discoverApi}
Expand Down
3 changes: 2 additions & 1 deletion packages/login/src/wallets/extraWallets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface IProps {
elfApi: WalletHookInterface;
discoverApi: DiscoverInterface;
isBridgeNotExist: boolean;
version?: string;
}
export default function ExtraWallets({
headerClassName,
Expand All @@ -36,10 +37,10 @@ export default function ExtraWallets({
elfApi,
discoverApi,
isBridgeNotExist,
version = 'v2',
}: IProps) {
const isMobileDevice = isMobile();
const { commonConfig, portkey: portkeyOpts, extraWallets } = useContext(ExtraWalletContext);
const { version } = useWebLogin();
const isDiscoverMobileNotExist = useMemo(() => {
// console.log(discoverApi.discoverDetected, 'discoverApi.discoverDetected');
return (
Expand Down

0 comments on commit 27a735f

Please sign in to comment.