2023-02-18 16:14:24 +03:00
|
|
|
import { useEffect } from 'preact/hooks';
|
2023-02-15 05:49:36 +03:00
|
|
|
import { useSnapshot } from 'valtio';
|
2022-12-10 12:14:48 +03:00
|
|
|
|
2023-02-18 16:14:24 +03:00
|
|
|
import Columns from '../components/columns';
|
2022-12-10 12:14:48 +03:00
|
|
|
import Icon from '../components/icon';
|
2023-02-15 05:49:36 +03:00
|
|
|
import Link from '../components/link';
|
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-02-15 05:49:36 +03:00
|
|
|
const snapStates = useSnapshot(states);
|
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-18 16:14:24 +03:00
|
|
|
{snapStates.settings.shortcutsColumnsMode ? (
|
|
|
|
<Columns />
|
2023-02-18 15:48:24 +03:00
|
|
|
) : (
|
|
|
|
<Following
|
|
|
|
title="Home"
|
|
|
|
path="/"
|
|
|
|
id="home"
|
|
|
|
headerStart={false}
|
|
|
|
headerEnd={
|
|
|
|
<Link
|
|
|
|
to="/notifications"
|
|
|
|
class={`button plain ${
|
|
|
|
snapStates.notificationsShowNew ? 'has-badge' : ''
|
|
|
|
}`}
|
|
|
|
onClick={(e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Icon icon="notification" size="l" alt="Notifications" />
|
|
|
|
</Link>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)}
|
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;
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
>
|
2023-02-16 12:51:54 +03:00
|
|
|
<Icon icon="quill" size="xl" alt="Compose" />
|
2023-01-20 19:23:59 +03:00
|
|
|
</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;
|