review fixes
This commit is contained in:
parent
c3c1c9fee3
commit
84f45ea1a2
|
@ -32,10 +32,8 @@ export const TopicCard = (props: TopicProps) => {
|
|||
const subscribe = async (really = true) => {
|
||||
if (really) {
|
||||
follow({ what: FollowingEntity.Topic, slug: topic().slug })
|
||||
// TODO: setSubscribers(topic().stat?.followers as number + 1)
|
||||
} else {
|
||||
unfollow({ what: FollowingEntity.Topic, slug: topic().slug })
|
||||
// TODO: setSubscribers(topic().stat?.followers as number - 1)
|
||||
}
|
||||
}
|
||||
return (
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Show, createMemo } from 'solid-js'
|
||||
import type { Author, Shout } from '../../graphql/types.gen'
|
||||
import type { Author, Reaction, Shout } from '../../graphql/types.gen'
|
||||
import Row2 from '../Feed/Row2'
|
||||
import Row3 from '../Feed/Row3'
|
||||
import Beside from '../Feed/Beside'
|
||||
|
@ -13,13 +13,16 @@ import '../../styles/Topic.scss'
|
|||
import { useStore } from '@nanostores/solid'
|
||||
import { useTopicsStore } from '../../stores/zine/topics'
|
||||
|
||||
// TODO: load reactions on client
|
||||
type AuthorProps = {
|
||||
authorArticles: Shout[]
|
||||
author: Author
|
||||
// FIXME author topics fro server
|
||||
// topics: Topic[]
|
||||
}
|
||||
|
||||
export const AuthorPage = (props: AuthorProps) => {
|
||||
const { getSortedArticles: articles, getArticlesByAuthor } = useArticlesStore({
|
||||
const { getSortedArticles: articles } = useArticlesStore({
|
||||
sortedArticles: props.authorArticles
|
||||
})
|
||||
const { getAuthorEntities: authors } = useAuthorsStore({ authors: [props.author] })
|
||||
|
|
|
@ -55,6 +55,7 @@ export const FeedPage = (props: FeedProps) => {
|
|||
// })
|
||||
|
||||
const loadMore = () => {
|
||||
// FIXME
|
||||
const page = (props.page || 1) + 1
|
||||
loadRecentArticles({ page })
|
||||
}
|
||||
|
@ -98,7 +99,7 @@ export const FeedPage = (props: FeedProps) => {
|
|||
</div>
|
||||
|
||||
<ul class="beside-column">
|
||||
<For each={getTopAuthors()}>
|
||||
<For each={getTopAuthors().slice(0, 5)}>
|
||||
{(author) => (
|
||||
<li>
|
||||
<AuthorCard author={author} compact={true} hasLink={true} />
|
||||
|
@ -127,7 +128,7 @@ export const FeedPage = (props: FeedProps) => {
|
|||
<Show when={getTopTopics().length > 0}>
|
||||
<section class="feed-topics">
|
||||
<h4>{t('Topics')}</h4>
|
||||
<For each={getTopTopics()}>
|
||||
<For each={getTopTopics().slice(0, 5)}>
|
||||
{(topic) => <TopicCard topic={topic} subscribeButtonBottom={true} />}
|
||||
</For>
|
||||
</section>
|
||||
|
|
|
@ -92,6 +92,7 @@ export const HomePage = (props: HomeProps) => {
|
|||
// }, [byLayout()])
|
||||
|
||||
const loadMore = () => {
|
||||
// FIXME
|
||||
const page = (props.page || 1) + 1
|
||||
loadPublishedArticles({ page })
|
||||
}
|
||||
|
|
|
@ -31,16 +31,13 @@ export const SearchPage = (props: Props) => {
|
|||
<div class="search-page wide-container">
|
||||
<form action="/search" class="search-form row">
|
||||
<div class="col-sm-9">
|
||||
{/*FIXME t*/}
|
||||
<input type="search" name="q" onChange={handleQueryChange} placeholder="Введите текст..." />
|
||||
<input type="search" name="q" placeholder="Введите текст..." />
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<button class="button" type="submit" onClick={handleSubmit}>
|
||||
{t('Search')}
|
||||
</button>
|
||||
<button class="button" type="submit">
|
||||
{t('Search')}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { gql } from '@urql/core'
|
||||
|
||||
export default gql`
|
||||
query RefreshSessionQuery {
|
||||
mutation RefreshSessionMutation {
|
||||
refreshSession {
|
||||
error
|
||||
token
|
||||
|
|
|
@ -5,6 +5,8 @@ import { apiClient } from '../../../utils/apiClient'
|
|||
|
||||
const slug = Astro.params.slug.toString()
|
||||
const articles = await apiClient.getArticlesForAuthors({ authorSlugs: [slug] })
|
||||
|
||||
// FIXME get author by slugs
|
||||
const author = articles[0].authors.find((a) => a.slug === slug)
|
||||
|
||||
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { persistentAtom } from '@nanostores/persistent'
|
||||
import { action, atom } from 'nanostores'
|
||||
import { atom } from 'nanostores'
|
||||
import { useStore } from '@nanostores/solid'
|
||||
|
||||
export const locale = persistentAtom<string>('locale', 'ru')
|
||||
|
|
|
@ -7,7 +7,7 @@ import { byCreated, byStat } from '../../utils/sortby'
|
|||
|
||||
export type AuthorsSortBy = 'created' | 'name'
|
||||
|
||||
const sortByStore = atom<AuthorsSortBy>('created')
|
||||
const sortAllByStore = atom<AuthorsSortBy>('created')
|
||||
|
||||
let authorEntitiesStore: WritableAtom<{ [authorSlug: string]: Author }>
|
||||
let authorsByTopicStore: WritableAtom<{ [topicSlug: string]: Author[] }>
|
||||
|
@ -21,7 +21,7 @@ const initStore = (initial: { [authorSlug: string]: Author }) => {
|
|||
|
||||
authorEntitiesStore = atom(initial)
|
||||
|
||||
sortedAuthorsStore = computed([authorEntitiesStore, sortByStore], (authorEntities, sortBy) => {
|
||||
sortedAuthorsStore = computed([authorEntitiesStore, sortAllByStore], (authorEntities, sortBy) => {
|
||||
const authors = Object.values(authorEntities)
|
||||
switch (sortBy) {
|
||||
case 'created': {
|
||||
|
@ -42,6 +42,10 @@ const initStore = (initial: { [authorSlug: string]: Author }) => {
|
|||
})
|
||||
}
|
||||
|
||||
export const setSortAllBy = (sortBy: AuthorsSortBy) => {
|
||||
sortAllByStore.set(sortBy)
|
||||
}
|
||||
|
||||
const addAuthors = (authors: Author[]) => {
|
||||
const newAuthorEntities = authors.reduce((acc, author) => {
|
||||
acc[author.slug] = author
|
||||
|
|
|
@ -3,6 +3,7 @@ import { apiClient } from '../../utils/apiClient'
|
|||
|
||||
export const follow = async ({ what, slug }: { what: FollowingEntity; slug: string }) => {
|
||||
await apiClient.follow({ what, slug })
|
||||
// refresh session
|
||||
// TODO: _store update code
|
||||
}
|
||||
export const unfollow = async ({ what, slug }: { what: FollowingEntity; slug: string }) => {
|
||||
|
|
|
@ -4,10 +4,11 @@ import { atom, computed } from 'nanostores'
|
|||
import type { Topic } from '../../graphql/types.gen'
|
||||
import { useStore } from '@nanostores/solid'
|
||||
import { byCreated, byStat } from '../../utils/sortby'
|
||||
import type { AuthorsSortBy } from './authors'
|
||||
|
||||
export type TopicsSortBy = 'created' | 'name'
|
||||
|
||||
const sortByStore = atom<TopicsSortBy>('created')
|
||||
const sortAllByStore = atom<TopicsSortBy>('created')
|
||||
|
||||
let topicEntitiesStore: WritableAtom<{ [topicSlug: string]: Topic }>
|
||||
let sortedTopicsStore: ReadableAtom<Topic[]>
|
||||
|
@ -22,7 +23,7 @@ const initStore = (initial?: Record<string, Topic>) => {
|
|||
|
||||
topicEntitiesStore = atom<Record<string, Topic>>(initial)
|
||||
|
||||
sortedTopicsStore = computed([topicEntitiesStore, sortByStore], (topicEntities, sortBy) => {
|
||||
sortedTopicsStore = computed([topicEntitiesStore, sortAllByStore], (topicEntities, sortBy) => {
|
||||
const topics = Object.values(topicEntities)
|
||||
switch (sortBy) {
|
||||
case 'created': {
|
||||
|
@ -48,6 +49,10 @@ const initStore = (initial?: Record<string, Topic>) => {
|
|||
})
|
||||
}
|
||||
|
||||
export const setSortAllBy = (sortBy: TopicsSortBy) => {
|
||||
sortAllByStore.set(sortBy)
|
||||
}
|
||||
|
||||
const addTopics = (...args: Topic[][]) => {
|
||||
const allTopics = args.flatMap((topics) => topics || [])
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ import authorsBySlugs from '../graphql/query/authors-by-slugs'
|
|||
|
||||
const log = getLogger('api-client')
|
||||
|
||||
const DEFAULT_AUTHOR_ARTICLES_PAGE_SIZE = 50
|
||||
// TODO: paging
|
||||
const DEFAULT_AUTHOR_ARTICLES_PAGE_SIZE = 999999
|
||||
const DEFAULT_TOPIC_ARTICLES_PAGE_SIZE = 50
|
||||
const DEFAULT_RECENT_ARTICLES_PAGE_SIZE = 50
|
||||
const DEFAULT_REACTIONS_PAGE_SIZE = 50
|
||||
|
|
|
@ -24,6 +24,7 @@ export const byLength = (a: any[], b: any[]) => {
|
|||
return 0
|
||||
}
|
||||
|
||||
// FIXME keyof TopicStat
|
||||
export const byStat = (metric: keyof Stat) => {
|
||||
return (a, b) => {
|
||||
const x = (a?.stat && a.stat[metric]) || 0
|
||||
|
|
Loading…
Reference in New Issue
Block a user