phanpy/src/pages/home.jsx

67 lines
1.6 KiB
React
Raw Normal View History

2023-02-09 14:27:49 +00:00
import { useEffect } from 'preact/hooks';
2022-12-10 09:14:48 +00:00
import Icon from '../components/icon';
import db from '../utils/db';
2023-02-09 14:27:49 +00:00
import openCompose from '../utils/open-compose';
import states from '../utils/states';
import { getCurrentAccountNS } from '../utils/store-utils';
2022-12-10 09:14:48 +00:00
2023-02-09 14:27:49 +00:00
import Following from './following';
2023-02-09 14:27:49 +00:00
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;
}
}
})();
}, []);
2022-12-10 09:14:48 +00:00
return (
<>
2023-02-09 14:27:49 +00:00
<Following
title="Home"
id="home"
headerStart={
<button
type="button"
class="plain"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
states.showSettings = true;
}}
>
2023-02-09 14:27:49 +00:00
<Icon icon="gear" size="l" alt="Settings" />
</button>
}
/>
<button
2023-02-09 14:27:49 +00:00
// 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>
</>
2022-12-10 09:14:48 +00:00
);
2022-12-16 05:27:04 +00:00
}
2023-02-09 14:27:49 +00:00
export default Home;