Change followers modal logic (#257)

This commit is contained in:
Ilya Y 2023-10-12 23:32:42 +03:00 committed by GitHub
parent 13b92c2201
commit b1db22aa23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 6 additions and 40 deletions

View File

@ -48,8 +48,6 @@ const pagesMap: Record<keyof typeof ROUTES, Component<PageProps>> = {
author: AuthorPage, author: AuthorPage,
authorComments: AuthorPage, authorComments: AuthorPage,
authorAbout: AuthorPage, authorAbout: AuthorPage,
authorFollowing: AuthorPage,
authorFollowers: AuthorPage,
inbox: InboxPage, inbox: InboxPage,
expo: ExpoPage, expo: ExpoPage,
expoLayout: ExpoPage, expoLayout: ExpoPage,

View File

@ -640,6 +640,7 @@
margin-top: 1rem; margin-top: 1rem;
margin-right: 3rem; margin-right: 3rem;
vertical-align: top; vertical-align: top;
border-bottom: unset !important;
&:last-child { &:last-child {
margin-right: 0; margin-right: 0;

View File

@ -14,7 +14,6 @@ import { openPage, redirectPage } from '@nanostores/router'
import { useLocalize } from '../../../context/localize' import { useLocalize } from '../../../context/localize'
import { ConditionalWrapper } from '../../_shared/ConditionalWrapper' import { ConditionalWrapper } from '../../_shared/ConditionalWrapper'
import { Modal } from '../../Nav/Modal' import { Modal } from '../../Nav/Modal'
import { showModal } from '../../../stores/ui'
import { SubscriptionFilter } from '../../../pages/types' import { SubscriptionFilter } from '../../../pages/types'
import { isAuthor } from '../../../utils/isAuthor' import { isAuthor } from '../../../utils/isAuthor'
import { AuthorBadge } from '../AuthorBadge' import { AuthorBadge } from '../AuthorBadge'
@ -22,8 +21,6 @@ import { TopicBadge } from '../../Topic/TopicBadge'
import { Button } from '../../_shared/Button' import { Button } from '../../_shared/Button'
import { getShareUrl, SharePopup } from '../../Article/SharePopup' import { getShareUrl, SharePopup } from '../../Article/SharePopup'
import stylesHeader from '../../Nav/Header/Header.module.scss' import stylesHeader from '../../Nav/Header/Header.module.scss'
import { getDescription } from '../../../utils/meta'
import { Popover } from '../../_shared/Popover'
type Props = { type Props = {
caption?: string caption?: string
@ -52,7 +49,6 @@ type Props = {
export const AuthorCard = (props: Props) => { export const AuthorCard = (props: Props) => {
const { t, lang } = useLocalize() const { t, lang } = useLocalize()
const { page } = useRouter()
const { const {
session, session,
isSessionLoaded, isSessionLoaded,
@ -122,12 +118,6 @@ export const AuthorCard = (props: Props) => {
} }
}) })
createEffect(() => {
if (page().route === 'authorFollowing') {
showModal('following')
}
})
const handleCloseFollowModals = () => { const handleCloseFollowModals = () => {
redirectPage(router, 'author', { slug: props.author.slug }) redirectPage(router, 'author', { slug: props.author.slug })
} }
@ -225,20 +215,14 @@ export const AuthorCard = (props: Props) => {
<div class={styles.subscribersContainer}> <div class={styles.subscribersContainer}>
<Switch> <Switch>
<Match when={props.followers && props.followers.length > 0 && !props.isCurrentUser}> <Match when={props.followers && props.followers.length > 0 && !props.isCurrentUser}>
<div <a href="?modal=followers" class={styles.subscribers}>
class={styles.subscribers}
onClick={() => {
redirectPage(router, 'authorFollowers', { slug: props.author.slug })
showModal('followers')
}}
>
<For each={props.followers.slice(0, 3)}> <For each={props.followers.slice(0, 3)}>
{(f) => <Userpic name={f.name} userpic={f.userpic} class={styles.userpic} />} {(f) => <Userpic name={f.name} userpic={f.userpic} class={styles.userpic} />}
</For> </For>
<div class={styles.subscribersCounter}> <div class={styles.subscribersCounter}>
{t('SubscriptionWithCount', { count: props.followers.length })} {t('SubscriptionWithCount', { count: props.followers.length })}
</div> </div>
</div> </a>
</Match> </Match>
<Match when={props.followers && props.followers.length > 0 && props.isCurrentUser}> <Match when={props.followers && props.followers.length > 0 && props.isCurrentUser}>
<Button <Button
@ -250,13 +234,7 @@ export const AuthorCard = (props: Props) => {
</Switch> </Switch>
<Switch> <Switch>
<Match when={props.following && props.following.length > 0 && !props.isCurrentUser}> <Match when={props.following && props.following.length > 0 && !props.isCurrentUser}>
<div <a href="?modal=following" class={styles.subscribers}>
class={styles.subscribers}
onClick={() => {
redirectPage(router, 'authorFollowing', { slug: props.author.slug })
showModal('following')
}}
>
<For each={props.following.slice(0, 3)}> <For each={props.following.slice(0, 3)}>
{(f) => { {(f) => {
if ('name' in f) { if ('name' in f) {
@ -270,7 +248,7 @@ export const AuthorCard = (props: Props) => {
<div class={styles.subscribersCounter}> <div class={styles.subscribersCounter}>
{t('SubscriberWithCount', { count: props?.following.length ?? 0 })} {t('SubscriberWithCount', { count: props?.following.length ?? 0 })}
</div> </div>
</div> </a>
</Match> </Match>
<Match when={props.following && props.following.length > 0 && props.isCurrentUser}> <Match when={props.following && props.following.length > 0 && props.isCurrentUser}>
<SharePopup <SharePopup

View File

@ -26,7 +26,7 @@ export const ProfilePopup = (props: ProfilePopupProps) => {
<a href={getPagePath(router, 'drafts')}>{t('Drafts')}</a> <a href={getPagePath(router, 'drafts')}>{t('Drafts')}</a>
</li> </li>
<li> <li>
<a href={`${getPagePath(router, 'authorFollowing', { slug: user().slug })}`}> <a href={`${getPagePath(router, 'author', { slug: user().slug })}?modal=following`}>
{t('Subscriptions')} {t('Subscriptions')}
</a> </a>
</li> </li>

View File

@ -207,7 +207,6 @@ export const AuthorView = (props: Props) => {
</div> </div>
</div> </div>
</Match> </Match>
<Match when={page().route === 'author'}> <Match when={page().route === 'author'}>
<Show when={sortedArticles().length === 1}> <Show when={sortedArticles().length === 1}>
<Row1 article={sortedArticles()[0]} noauthor={true} nodate={true} /> <Row1 article={sortedArticles()[0]} noauthor={true} nodate={true} />

View File

@ -1,4 +0,0 @@
import { ROUTES } from '../stores/router'
import { getServerRoute } from '../utils/getServerRoute'
export default getServerRoute(ROUTES.authorFollowers)

View File

@ -1,4 +0,0 @@
import { ROUTES } from '../stores/router'
import { getServerRoute } from '../utils/getServerRoute'
export default getServerRoute(ROUTES.authorFollowing)

View File

@ -18,8 +18,6 @@ export const ROUTES = {
author: '/author/:slug', author: '/author/:slug',
authorComments: '/author/:slug/comments', authorComments: '/author/:slug/comments',
authorAbout: '/author/:slug/about', authorAbout: '/author/:slug/about',
authorFollowers: '/author/:slug/followers',
authorFollowing: '/author/:slug/following',
feed: '/feed', feed: '/feed',
feedMy: '/feed/my', feedMy: '/feed/my',
feedNotifications: '/feed/notifications', feedNotifications: '/feed/notifications',