Skip to content

Commit

Permalink
Merge pull request #219 from nspcc-dev/feature/196-autodetect_neoline
Browse files Browse the repository at this point in the history
Autodetect Neoline
  • Loading branch information
roman-khimov authored Aug 27, 2024
2 parents 5aa6657 + 2b6ef6f commit 8df2b96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export const App = () => {
preset: 'forbid',
});
const [walletData, setWalletData] = useState(null);
const [isNeoLineSupport, setNeoLineSupport] = useState(false);

const [modal, setModal] = useState({
current: null,
Expand All @@ -180,6 +181,12 @@ export const App = () => {
}, 2000);
};

useEffect(() => {
window.addEventListener('NEOLine.NEO.EVENT.READY', () => {
setNeoLineSupport(true);
});
}, []); // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
if (wcSdk.isConnected() && location.pathname.indexOf('/getobject') === -1) {
setWalletData({
Expand Down Expand Up @@ -1817,6 +1824,7 @@ export const App = () => {
element={<Home
onModal={onModal}
dapi={dapi}
isNeoLineSupport={isNeoLineSupport}
onConnectWallet={onConnectWallet}
/>}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
const Home = ({
onModal,
onConnectWallet,
isNeoLineSupport,
dapi,
}) => {

Expand Down Expand Up @@ -39,6 +40,7 @@ const Home = ({
<Button
className="btn_connect_wallet"
onClick={() => onConnectWallet('neoline')}
style={isNeoLineSupport ? { border: '2px solid #00e599', background: '#00dc9633' } : {}}
>
NeoLine
<img src="/img/icons/wallets/neoline.svg" alt="neoline logo" />
Expand Down

0 comments on commit 8df2b96

Please sign in to comment.