Move notifications link from Following to Home

This commit is contained in:
Lim Chee Aun 2023-02-15 10:49:36 +08:00
parent f198571367
commit d324d3a672
2 changed files with 24 additions and 20 deletions

View file

@ -1,8 +1,6 @@
import { useEffect, useRef } from 'preact/hooks';
import { useSnapshot } from 'valtio';
import Icon from '../components/icon';
import Link from '../components/link';
import Timeline from '../components/timeline';
import { api } from '../utils/api';
import states from '../utils/states';
@ -11,7 +9,7 @@ import useTitle from '../utils/useTitle';
const LIMIT = 20;
function Following({ title, path, id, headerStart }) {
function Following({ title, path, id, ...props }) {
useTitle(title || 'Following', path, '/l/f');
const { masto, instance } = api();
const snapStates = useSnapshot(states);
@ -109,20 +107,6 @@ function Following({ title, path, id, headerStart }) {
};
}, []);
const headerEnd = (
<Link
to="/notifications"
class={`button plain ${
snapStates.notificationsShowNew ? 'has-badge' : ''
}`}
onClick={(e) => {
e.stopPropagation();
}}
>
<Icon icon="notification" size="l" alt="Notifications" />
</Link>
);
return (
<Timeline
title={title || 'Following'}
@ -132,9 +116,8 @@ function Following({ title, path, id, headerStart }) {
fetchItems={fetchHome}
checkForUpdates={checkForUpdates}
useItemID
headerStart={headerStart}
headerEnd={headerEnd}
boostsCarousel={snapStates.settings.boostsCarousel}
{...props}
/>
);
}

View file

@ -1,6 +1,8 @@
import { useEffect } from 'preact/hooks';
import { useSnapshot } from 'valtio';
import Icon from '../components/icon';
import Link from '../components/link';
import db from '../utils/db';
import openCompose from '../utils/open-compose';
import states from '../utils/states';
@ -9,6 +11,7 @@ import { getCurrentAccountNS } from '../utils/store-utils';
import Following from './following';
function Home() {
const snapStates = useSnapshot(states);
useEffect(() => {
(async () => {
const keys = await db.drafts.keys();
@ -24,7 +27,25 @@ function Home() {
return (
<>
<Following title="Home" path="/" id="home" headerStart={false} />
<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>
}
/>
<button
// hidden={scrollDirection === 'end' && !nearReachStart}
type="button"