mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-22 10:44:27 +03:00
66 lines
1.6 KiB
JavaScript
66 lines
1.6 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"
|
|
id="home"
|
|
headerStart={
|
|
<button
|
|
type="button"
|
|
class="plain"
|
|
onClick={(e) => {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
states.showSettings = true;
|
|
}}
|
|
>
|
|
<Icon icon="gear" size="l" alt="Settings" />
|
|
</button>
|
|
}
|
|
/>
|
|
<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;
|