phanpy/src/pages/home.jsx

67 lines
1.6 KiB
React
Raw Normal View History

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