phanpy/src/pages/home.jsx
Lim Chee Aun 81ebb61096 Sneak in this little menu
And… fix title leak bug
2023-02-10 13:39:46 +08:00

51 lines
1.3 KiB
JavaScript

import { useEffect } from 'preact/hooks';
import Icon from '../components/icon';
import db from '../utils/db';
import openCompose from '../utils/open-compose';
import states from '../utils/states';
import { getCurrentAccountNS } from '../utils/store-utils';
import Following from './following';
function Home() {
useEffect(() => {
(async () => {
const keys = await db.drafts.keys();
if (keys.length) {
const ns = getCurrentAccountNS();
const ownKeys = keys.filter((key) => key.startsWith(ns));
if (ownKeys.length) {
states.showDrafts = true;
}
}
})();
}, []);
return (
<>
<Following title="Home" path="/" id="home" headerStart={false} />
<button
// hidden={scrollDirection === 'end' && !nearReachStart}
type="button"
id="compose-button"
onClick={(e) => {
if (e.shiftKey) {
const newWin = openCompose();
if (!newWin) {
alert('Looks like your browser is blocking popups.');
states.showCompose = true;
}
} else {
states.showCompose = true;
}
}}
>
<Icon icon="quill" size="xxl" alt="Compose" />
</button>
</>
);
}
export default Home;