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';
|
2023-01-13 10:30:09 +03:00
|
|
|
import db from '../utils/db';
|
2023-02-09 17:27:49 +03:00
|
|
|
import openCompose from '../utils/open-compose';
|
|
|
|
import states from '../utils/states';
|
2023-01-13 10:30:09 +03:00
|
|
|
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-01-02 16:36:24 +03:00
|
|
|
|
2023-02-09 17:27:49 +03:00
|
|
|
function Home() {
|
2023-01-13 10:30:09 +03:00
|
|
|
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-01-20 19:23:59 +03:00
|
|
|
<>
|
2023-02-10 08:39:46 +03:00
|
|
|
<Following title="Home" path="/" id="home" headerStart={false} />
|
2023-01-20 19:23:59 +03:00
|
|
|
<button
|
2023-02-09 17:27:49 +03:00
|
|
|
// hidden={scrollDirection === 'end' && !nearReachStart}
|
2023-01-20 19:23:59 +03:00
|
|
|
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;
|