Skip to content

Commit

Permalink
Lint issues fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
rleojoseph committed Mar 21, 2024
1 parent 3569d9b commit e94b228
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions js-miniapp-sample/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,42 @@ function App() {
const classes = useStyles();
const [toastVisible, setToastVisible] = useState(false);

const updateLoadingStatus = () => {
if (document.readyState === 'complete') {
miniAppDidFinishLoad();
}
};

useEffect(() => {
try {
const platform = MiniApp.getPlatform();
if (platform === 'iOS') {
if (typeof updateLoadingStatus === 'function') {
updateLoadingStatus();
function updateLoadingStatus() {
if (document.readyState === 'complete') {
miniAppDidFinishLoad();
}
}
if (platform === 'iOS') {
updateLoadingStatus();
} else {
if (typeof updateLoadingStatus === 'function') {
document.onreadystatechange = function () {
updateLoadingStatus();
};
}
document.onreadystatechange = function () {
updateLoadingStatus();
};
}
} catch (e) {
console.log(e);
}
}, []);

function miniAppDidFinishLoad() {
MiniApp.miniappUtils
.miniAppFinishedLoading()
.then((response) => {
console.log('miniAppFinishedLoading(): ', response);
setToastVisible(true);
const timer = setTimeout(() => setToastVisible(false), 5000);
return () => clearTimeout(timer);
})
.catch((miniAppError) => {
console.log('miniAppFinishedLoading - Error: ', miniAppError);
});
try {
MiniApp.miniappUtils
.miniAppFinishedLoading()
.then((response) => {
console.log('miniAppFinishedLoading(): ', response);
setToastVisible(true);
const timer = setTimeout(() => setToastVisible(false), 5000);
return () => clearTimeout(timer);
})
.catch((miniAppError) => {
console.log('miniAppFinishedLoading - Error: ', miniAppError);
});
} catch (e) {
console.log(e);
}
}

return (
Expand Down

0 comments on commit e94b228

Please sign in to comment.