{t('Feed settings')}
diff --git a/src/components/Views/FourOuFour.tsx b/src/components/Views/FourOuFour.tsx
index add7879a..bd9974fc 100644
--- a/src/components/Views/FourOuFour.tsx
+++ b/src/components/Views/FourOuFour.tsx
@@ -1,5 +1,5 @@
import { t } from '../../utils/intl'
-import { Icon } from '../Nav/Icon'
+import { Icon } from '../_shared/Icon'
import styles from '../../styles/FourOuFour.module.scss'
import { clsx } from 'clsx'
diff --git a/src/components/Views/Home.tsx b/src/components/Views/Home.tsx
index 4d45592f..8fd58639 100644
--- a/src/components/Views/Home.tsx
+++ b/src/components/Views/Home.tsx
@@ -11,15 +11,10 @@ import RowShort from '../Feed/RowShort'
import Slider from '../Feed/Slider'
import Group from '../Feed/Group'
import type { Shout, Topic } from '../../graphql/types.gen'
-import { Icon } from '../Nav/Icon'
+import { Icon } from '../_shared/Icon'
import { t } from '../../utils/intl'
import { useTopicsStore } from '../../stores/zine/topics'
-import {
- loadPublishedArticles,
- loadTopArticles,
- loadTopMonthArticles,
- useArticlesStore
-} from '../../stores/zine/articles'
+import { loadShoutsBy, useArticlesStore } from '../../stores/zine/articles'
import { useTopAuthorsStore } from '../../stores/zine/topAuthors'
import { locale } from '../../stores/ui'
import { restoreScrollPosition, saveScrollPosition } from '../../utils/scroll'
@@ -27,7 +22,7 @@ import { splitToPages } from '../../utils/splitToPages'
type HomeProps = {
randomTopics: Topic[]
- recentPublishedArticles: Shout[]
+ shouts: Shout[]
}
export const PRERENDERED_ARTICLES_COUNT = 5
@@ -37,26 +32,24 @@ const LOAD_MORE_PAGE_SIZE = 16 // Row1 + Row3 + Row2 + Beside (3 + 1) + Row1 + R
export const HomeView = (props: HomeProps) => {
const {
sortedArticles,
+ articlesByLayout,
topArticles,
- topMonthArticles,
- topViewedArticles,
topCommentedArticles,
- articlesByLayout
+ topMonthArticles,
+ topViewedArticles
} = useArticlesStore({
- sortedArticles: props.recentPublishedArticles
+ shouts: props.shouts
})
const { randomTopics, topTopics } = useTopicsStore({
randomTopics: props.randomTopics
})
const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false)
-
const { topAuthors } = useTopAuthorsStore()
onMount(async () => {
- loadTopArticles()
- loadTopMonthArticles()
if (sortedArticles().length < PRERENDERED_ARTICLES_COUNT + CLIENT_LOAD_ARTICLES_COUNT) {
- const { hasMore } = await loadPublishedArticles({
+ const { hasMore } = await loadShoutsBy({
+ by: {},
limit: CLIENT_LOAD_ARTICLES_COUNT,
offset: sortedArticles().length
})
@@ -84,7 +77,8 @@ export const HomeView = (props: HomeProps) => {
const loadMore = async () => {
saveScrollPosition()
- const { hasMore } = await loadPublishedArticles({
+ const { hasMore } = await loadShoutsBy({
+ by: { visibility: 'public' },
limit: LOAD_MORE_PAGE_SIZE,
offset: sortedArticles().length
})
diff --git a/src/components/Views/Inbox.tsx b/src/components/Views/Inbox.tsx
index 47b67d91..6b131834 100644
--- a/src/components/Views/Inbox.tsx
+++ b/src/components/Views/Inbox.tsx
@@ -1,59 +1,158 @@
+import { For, createSignal, Show, onMount, createEffect } from 'solid-js'
import type { Author } from '../../graphql/types.gen'
import { AuthorCard } from '../Author/Card'
-import { Icon } from '../Nav/Icon'
-import '../../styles/Inbox.scss'
+import { Icon } from '../_shared/Icon'
+import { Loading } from '../Loading'
+import DialogCard from '../Inbox/DialogCard'
+import Search from '../Inbox/Search'
+import { useAuthorsStore } from '../../stores/zine/authors'
+import MarkdownIt from 'markdown-it'
+// const { session } = useAuthStore()
+import '../../styles/Inbox.scss'
+// Для моков
+import { createClient } from '@urql/core'
+import { findAndLoadGraphQLConfig } from '@graphql-codegen/cli'
+// import { useAuthStore } from '../../stores/auth'
+import { useSession } from '../../context/session'
+
+const md = new MarkdownIt({
+ linkify: true
+})
+const OWNER_ID = '501'
+const client = createClient({
+ url: 'https://graphqlzero.almansi.me/api'
+})
+
+// console.log('!!! session:', session)
// interface InboxProps {
// chats?: Chat[]
// messages?: Message[]
// }
+const messageQuery = `
+query Comments ($options: PageQueryOptions) {
+ comments(options: $options) {
+ data {
+ id
+ body
+ email
+ }
+ }
+}
+`
+const newMessageQuery = `
+mutation postComment($messageBody: String!) {
+ createComment(
+ input: { body: $messageBody, email: "test@test.com", name: "User" }
+ ) {
+ id
+ body
+ name
+ email
+ }
+}
+`
+
+const userSearch = (array: Author[], keyword: string) => {
+ const searchTerm = keyword.toLowerCase()
+ return array.filter((value) => {
+ return value.name.toLowerCase().match(new RegExp(searchTerm, 'g'))
+ })
+}
+
+const postMessage = async (msg: string) => {
+ const response = await client.mutation(newMessageQuery, { messageBody: msg }).toPromise()
+ return response.data.createComment
+}
+
export const InboxView = () => {
- // TODO: get user session
+ const [messages, setMessages] = createSignal([])
+ const [authors, setAuthors] = createSignal
([])
+ const [postMessageText, setPostMessageText] = createSignal('')
+ const [loading, setLoading] = createSignal(false)
+ const [currentSlug, setCurrentSlug] = createSignal()
+
+ const { session } = useSession()
+ const { sortedAuthors } = useAuthorsStore()
+
+ createEffect(() => {
+ setAuthors(sortedAuthors())
+ setCurrentSlug(session()?.user?.slug)
+ })
+
+ // Поиск по диалогам
+ const getQuery = (query) => {
+ if (query().length >= 2) {
+ const match = userSearch(authors(), query())
+ console.log('!!! match:', match)
+ setAuthors(match)
+ } else {
+ setAuthors(sortedAuthors())
+ }
+ }
+
+ const fetchMessages = async (query) => {
+ const response = await client
+ .query(query, {
+ options: { slice: { start: 0, end: 3 } }
+ })
+ .toPromise()
+ if (response.error) console.debug('getMessages', response.error)
+ setMessages(response.data.comments.data)
+ }
+
+ let chatWindow
+ onMount(async () => {
+ setLoading(true)
+ try {
+ await fetchMessages(messageQuery)
+ } catch (error) {
+ setLoading(false)
+ console.error([fetchMessages], error)
+ } finally {
+ setLoading(false)
+ chatWindow.scrollTop = chatWindow.scrollHeight
+ }
+ })
+
+ const handleSubmit = async () => {
+ try {
+ const post = await postMessage(postMessageText())
+ setMessages((prev) => [...prev, post])
+ setPostMessageText('')
+ chatWindow.scrollTop = chatWindow.scrollHeight
+ } catch (error) {
+ console.error('[post message error]:', error)
+ }
+ }
+
+ let formParent // autoresize ghost element
+ const handleChangeMessage = (event) => {
+ setPostMessageText(event.target.value)
+ }
+ createEffect(() => {
+ formParent.dataset.replicatedValue = postMessageText()
+ })
+
return (
-
-
+
-
-
-
- -
-
-
12:15
-
- Lorem ipsum dolor sit amet, consectetur adipisicing elit.
-
-
- -
-
-
19:48
-
- Assumenda delectus deleniti dolores doloribus ducimus, et expedita facere iste laborum,
- nihil similique suscipit, ut voluptatem. Accusantium consequuntur doloremque ex molestiae
- nemo.
-
-
-
+
@@ -64,59 +163,55 @@ export const InboxView = () => {
-
-
-
- Круто, беру в оборот!
-
-
+
+
+
+
+
+ {(comment: { body: string; id: string; email: string }) => (
+
+
+
+
+
+ {comment.email} id: {comment.id}
+
+
+
-
-
-
+ )}
+
-
-
- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut beatae earum iste itaque
- libero perspiciatis possimus quod! Accusamus, aliquam amet consequuntur debitis dolorum
- esse laudantium magni omnis rerum voluptatem voluptates!
-
-
- Отредактировано
-
-
-
-
-
-
-
-
-
-
-
- Нужна грамотная инфраструктура для сообщений, если ожидается нагрузка - надо опираться на
- это. Но в целом это несложно сделать.
-
-
-
-
-
-
+ {/*
*/}
+ {/* */}
+ {/*
*/}
-
+
diff --git a/src/components/Views/Search.tsx b/src/components/Views/Search.tsx
index a899cde8..b63dffd8 100644
--- a/src/components/Views/Search.tsx
+++ b/src/components/Views/Search.tsx
@@ -3,7 +3,7 @@ import '../../styles/Search.scss'
import type { Shout } from '../../graphql/types.gen'
import { ArticleCard } from '../Feed/Card'
import { t } from '../../utils/intl'
-import { useArticlesStore, loadSearchResults } from '../../stores/zine/articles'
+import { useArticlesStore, loadShoutsBy } from '../../stores/zine/articles'
import { handleClientRouteLinkClick, useRouter } from '../../stores/router'
type SearchPageSearchParams = {
@@ -16,7 +16,7 @@ type Props = {
}
export const SearchView = (props: Props) => {
- const { sortedArticles } = useArticlesStore({ sortedArticles: props.results })
+ const { sortedArticles } = useArticlesStore({ shouts: props.results })
const [getQuery, setQuery] = createSignal(props.query)
const { searchParams } = useRouter
()
@@ -28,7 +28,7 @@ export const SearchView = (props: Props) => {
const handleSubmit = (_ev) => {
// TODO page
// TODO sort
- loadSearchResults({ query: getQuery() })
+ loadShoutsBy({ by: { title: getQuery(), body: getQuery() }, limit: 50 })
}
return (
diff --git a/src/components/Views/Topic.tsx b/src/components/Views/Topic.tsx
index fca408f4..81316cd6 100644
--- a/src/components/Views/Topic.tsx
+++ b/src/components/Views/Topic.tsx
@@ -8,7 +8,7 @@ import { FullTopic } from '../Topic/Full'
import { t } from '../../utils/intl'
import { useRouter } from '../../stores/router'
import { useTopicsStore } from '../../stores/zine/topics'
-import { loadTopicArticles, useArticlesStore } from '../../stores/zine/articles'
+import { loadShoutsBy, useArticlesStore } from '../../stores/zine/articles'
import { useAuthorsStore } from '../../stores/zine/authors'
import { restoreScrollPosition, saveScrollPosition } from '../../utils/scroll'
import { splitToPages } from '../../utils/splitToPages'
@@ -22,7 +22,7 @@ type TopicsPageSearchParams = {
interface TopicProps {
topic: Topic
- topicArticles: Shout[]
+ shouts: Shout[]
topicSlug: string
}
@@ -34,7 +34,7 @@ export const TopicView = (props: TopicProps) => {
const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false)
- const { sortedArticles } = useArticlesStore({ sortedArticles: props.topicArticles })
+ const { sortedArticles } = useArticlesStore({ shouts: props.shouts })
const { topicEntities } = useTopicsStore({ topics: [props.topic] })
const { authorsByTopic } = useAuthorsStore()
@@ -44,8 +44,8 @@ export const TopicView = (props: TopicProps) => {
const loadMore = async () => {
saveScrollPosition()
- const { hasMore } = await loadTopicArticles({
- topicSlug: topic().slug,
+ const { hasMore } = await loadShoutsBy({
+ by: { topic: topic().slug },
limit: LOAD_MORE_PAGE_SIZE,
offset: sortedArticles().length
})
diff --git a/src/components/Nav/Icon.module.scss b/src/components/_shared/Icon.module.scss
similarity index 100%
rename from src/components/Nav/Icon.module.scss
rename to src/components/_shared/Icon.module.scss
diff --git a/src/components/Nav/Icon.tsx b/src/components/_shared/Icon.tsx
similarity index 100%
rename from src/components/Nav/Icon.tsx
rename to src/components/_shared/Icon.tsx
diff --git a/src/components/Layouts/MainLayout.tsx b/src/components/_shared/PageWrap.tsx
similarity index 90%
rename from src/components/Layouts/MainLayout.tsx
rename to src/components/_shared/PageWrap.tsx
index ab86ac4a..4043d237 100644
--- a/src/components/Layouts/MainLayout.tsx
+++ b/src/components/_shared/PageWrap.tsx
@@ -6,7 +6,7 @@ import '../../styles/app.scss'
import { Show } from 'solid-js'
import { clsx } from 'clsx'
-type MainLayoutProps = {
+type PageWrapProps = {
headerTitle?: string
children: JSX.Element
isHeaderFixed?: boolean
@@ -14,7 +14,7 @@ type MainLayoutProps = {
class?: string
}
-export const MainLayout = (props: MainLayoutProps) => {
+export const PageWrap = (props: PageWrapProps) => {
const isHeaderFixed = props.isHeaderFixed !== undefined ? props.isHeaderFixed : true
return (
diff --git a/src/components/types.ts b/src/components/types.ts
index 866bb4f5..b0d5489a 100644
--- a/src/components/types.ts
+++ b/src/components/types.ts
@@ -1,18 +1,18 @@
// in a separate file to avoid circular dependencies
import type { Author, Chat, Shout, Topic } from '../graphql/types.gen'
+import type { LayoutType } from '../stores/zine/layouts'
// all the things (she said) that could be passed from the server
export type PageProps = {
randomTopics?: Topic[]
article?: Shout
- authorArticles?: Shout[]
- topicArticles?: Shout[]
- homeArticles?: Shout[]
+ shouts?: Shout[]
author?: Author
allAuthors?: Author[]
topic?: Topic
allTopics?: Topic[]
searchQuery?: string
+ layout?: LayoutType
// other types?
searchResults?: Shout[]
chats?: Chat[]
diff --git a/src/graphql/mutation/create-chat.ts b/src/graphql/mutation/create-chat.ts
new file mode 100644
index 00000000..b700707b
--- /dev/null
+++ b/src/graphql/mutation/create-chat.ts
@@ -0,0 +1,12 @@
+import { gql } from '@urql/core'
+
+export default gql`
+ mutation CreateChat($title: String, $members: [String]!) {
+ createChat(title: $title, members: $members) {
+ error
+ chat {
+ id
+ }
+ }
+ }
+`
diff --git a/src/graphql/mutation/increment-view.ts b/src/graphql/mutation/increment-view.ts
deleted file mode 100644
index 14c84b69..00000000
--- a/src/graphql/mutation/increment-view.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- mutation IncrementViewMutation($shout: String!) {
- incrementView(shout: $shout) {
- error
- }
- }
-`
diff --git a/src/graphql/query/article-by-slug.ts b/src/graphql/query/article-by-slug.ts
deleted file mode 100644
index d0d1fe5c..00000000
--- a/src/graphql/query/article-by-slug.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query GetShoutBySlugQuery($slug: String!) {
- getShoutBySlug(slug: $slug) {
- _id: slug
- slug
- title
- subtitle
- layout
- cover
- # community
- body
- authors {
- _id: slug
- name
- slug
- userpic
- caption
- }
- mainTopic
- topics {
- title
- body
- slug
- stat {
- _id: shouts
- shouts
- authors
- followers
- }
- }
- createdAt
- updatedAt
- publishedAt
- stat {
- _id: viewed
- viewed
- reacted
- rating
- commented
- }
- }
- }
-`
diff --git a/src/graphql/query/articles-for-authors.ts b/src/graphql/query/articles-for-authors.ts
deleted file mode 100644
index 1c178999..00000000
--- a/src/graphql/query/articles-for-authors.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query ShoutsForAuthorsQuery($slugs: [String]!, $limit: Int!, $offset: Int!) {
- shoutsByAuthors(slugs: $slugs, limit: $limit, offset: $offset) {
- _id: slug
- title
- subtitle
- layout
- slug
- cover
- # community
- mainTopic
- topics {
- title
- body
- slug
- stat {
- _id: shouts
- shouts
- authors
- followers
- }
- }
- authors {
- _id: slug
- name
- slug
- bio
- links
- userpic
- }
- createdAt
- publishedAt
- stat {
- _id: viewed
- viewed
- reacted
- }
- }
- }
-`
diff --git a/src/graphql/query/articles-for-communities.ts b/src/graphql/query/articles-for-communities.ts
deleted file mode 100644
index 7951f5e5..00000000
--- a/src/graphql/query/articles-for-communities.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query ShoutsForCommunitiesQuery($slugs: [String]!, $limit: Int!, $offset: Int!) {
- shoutsByCommunities(slugs: $slugs, limit: $limit, offset: $offset) {
- _id: slug
- title
- subtitle
- layout
- slug
- cover
- # community { ... }
- mainTopic
- topics {
- title
- body
- slug
- stat {
- _id: shouts
- shouts
- authors
- followers
- }
- }
- authors {
- _id: slug
- name
- slug
- userpic
- }
- createdAt
- publishedAt
- stat {
- _id: viewed
- viewed
- reacted
- }
- }
- }
-`
diff --git a/src/graphql/query/articles-for-feed.ts b/src/graphql/query/articles-for-feed.ts
deleted file mode 100644
index 564682c2..00000000
--- a/src/graphql/query/articles-for-feed.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query ShoutsBySessionQuery($limit: Int!, $offset: Int!) {
- shoutsForFeed(limit: $limit, offset: $offset) {
- _id: slug
- title
- subtitle
- layout
- slug
- cover
- # community
- mainTopic
- topics {
- title
- body
- slug
- stat {
- _id: shouts
- shouts
- authors
- followers
- }
- }
- authors {
- _id: slug
- name
- slug
- userpic
- }
- createdAt
- publishedAt
- stat {
- _id: viewed
- viewed
- reacted
- rating
- commented
- }
- }
- }
-`
diff --git a/src/graphql/query/articles-for-topics.ts b/src/graphql/query/articles-for-topics.ts
deleted file mode 100644
index 37b23744..00000000
--- a/src/graphql/query/articles-for-topics.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query ShoutsForTopicsQuery($slugs: [String]!, $limit: Int!, $offset: Int!) {
- shoutsByTopics(slugs: $slugs, limit: $limit, offset: $offset) {
- _id: slug
- title
- subtitle
- layout
- slug
- cover
- # community
- mainTopic
- topics {
- title
- body
- slug
- stat {
- _id: shouts
- shouts
- authors
- followers
- }
- }
- authors {
- _id: slug
- name
- slug
- userpic
- }
- createdAt
- publishedAt
- stat {
- _id: viewed
- viewed
- reacted
- }
- }
- }
-`
diff --git a/src/graphql/query/articles-recent-published.ts b/src/graphql/query/articles-load-by.ts
similarity index 80%
rename from src/graphql/query/articles-recent-published.ts
rename to src/graphql/query/articles-load-by.ts
index f1566c1c..a2d0891a 100644
--- a/src/graphql/query/articles-recent-published.ts
+++ b/src/graphql/query/articles-load-by.ts
@@ -1,14 +1,16 @@
import { gql } from '@urql/core'
export default gql`
- query RecentPublishedQuery($limit: Int!, $offset: Int!) {
- recentPublished(limit: $limit, offset: $offset) {
+ query LoadShoutsByQuery($by: ShoutsBy, $limit: Int!, $offset: Int!) {
+ loadShoutsBy(by: $by, limit: $limit, offset: $offset) {
_id: slug
title
subtitle
slug
layout
cover
+ # community
+ mainTopic
topics {
title
body
@@ -26,10 +28,8 @@ export default gql`
slug
userpic
}
- # community
- mainTopic
- publishedAt
createdAt
+ publishedAt
stat {
_id: viewed
viewed
diff --git a/src/graphql/query/articles-recent-all.ts b/src/graphql/query/articles-recent-all.ts
deleted file mode 100644
index 98ecf597..00000000
--- a/src/graphql/query/articles-recent-all.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query RecentAllQuery($limit: Int!, $offset: Int!) {
- recentAll(limit: $limit, offset: $offset) {
- _id: slug
- title
- subtitle
- slug
- layout
- cover
- topics {
- title
- body
- slug
- stat {
- _id: shouts
- shouts
- authors
- followers
- }
- }
- authors {
- _id: slug
- name
- slug
- userpic
- }
- # community
- mainTopic
- createdAt
- stat {
- _id: viewed
- viewed
- reacted
- rating
- }
- }
- }
-`
diff --git a/src/graphql/query/articles-top-month.ts b/src/graphql/query/articles-top-month.ts
deleted file mode 100644
index eed65ce7..00000000
--- a/src/graphql/query/articles-top-month.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query TopMonthShoutsQuery($limit: Int!, $offset: Int!) {
- topMonth(limit: $limit, offset: $offset) {
- _id: slug
- title
- subtitle
- layout
- slug
- cover
- # community
- mainTopic
- topics {
- title
- body
- slug
- stat {
- _id: shouts
- shouts
- authors
- followers
- }
- }
- authors {
- _id: slug
- name
- slug
- userpic
- }
- createdAt
- publishedAt
- stat {
- _id: viewed
- viewed
- reacted
- }
- }
- }
-`
diff --git a/src/graphql/query/articles-top-rated.ts b/src/graphql/query/articles-top-rated.ts
deleted file mode 100644
index 96060302..00000000
--- a/src/graphql/query/articles-top-rated.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query TopOverallShoutsQuery($limit: Int!, $offset: Int!) {
- topOverall(limit: $limit, offset: $offset) {
- _id: slug
- title
- subtitle
- slug
- layout
- cover
- # community
- mainTopic
- topics {
- title
- body
- slug
- stat {
- _id: shouts
- shouts
- authors
- followers
- }
- }
- authors {
- _id: slug
- name
- slug
- userpic
- }
- createdAt
- publishedAt
- stat {
- _id: viewed
- viewed
- reacted
- rating
- }
- }
- }
-`
diff --git a/src/graphql/query/articles-top-viewed.ts b/src/graphql/query/articles-top-viewed.ts
deleted file mode 100644
index 32252add..00000000
--- a/src/graphql/query/articles-top-viewed.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query TopViewedShoutsQuery($limit: Int!, $offset: Int!) {
- topViewed(limit: $limit, offset: $offset) {
- _id: slug
- title
- subtitle
- slug
- layout
- cover
- # community
- mainTopic
- topics {
- title
- body
- slug
- stat {
- _id: shouts
- shouts
- authors
- followers
- }
- }
- authors {
- _id: slug
- name
- slug
- userpic
- }
- createdAt
- publishedAt
- stat {
- _id: viewed
- viewed
- reacted
- rating
- }
- }
- }
-`
diff --git a/src/graphql/query/articles-for-author-reactions.ts b/src/graphql/query/author-reacted-shouts.ts
similarity index 100%
rename from src/graphql/query/articles-for-author-reactions.ts
rename to src/graphql/query/author-reacted-shouts.ts
diff --git a/src/graphql/query/authors-by-slugs.ts b/src/graphql/query/authors-load-by.ts
similarity index 66%
rename from src/graphql/query/authors-by-slugs.ts
rename to src/graphql/query/authors-load-by.ts
index c21c62c0..6463c488 100644
--- a/src/graphql/query/authors-by-slugs.ts
+++ b/src/graphql/query/authors-load-by.ts
@@ -1,8 +1,8 @@
import { gql } from '@urql/core'
export default gql`
- query GetAuthorsBySlugsQuery($slugs: [String]!) {
- getUsersBySlugs(slugs: $slugs) {
+ query AuthorLoadByQuery($by: AuthorsBy, $limit: Int, $offset: Int) {
+ loadAuthorsBy(by: $by, limit: $limit, offset: $offset) {
_id: slug
slug
name
diff --git a/src/graphql/query/chat-messages-load-by.ts b/src/graphql/query/chat-messages-load-by.ts
new file mode 100644
index 00000000..48796e30
--- /dev/null
+++ b/src/graphql/query/chat-messages-load-by.ts
@@ -0,0 +1,16 @@
+import { gql } from '@urql/core'
+
+export default gql`
+ query LoadMessagesQuery($by: MessagesBy!, $limit: Int, $offset: Int) {
+ loadMessagesBy(by: $by, limit: $limit, offset: $offset) {
+ error
+ messages {
+ author
+ body
+ createdAt
+ updatedAt
+ seen
+ }
+ }
+ }
+`
diff --git a/src/graphql/query/chats-load.ts b/src/graphql/query/chats-load.ts
new file mode 100644
index 00000000..de9b8610
--- /dev/null
+++ b/src/graphql/query/chats-load.ts
@@ -0,0 +1,26 @@
+import { gql } from '@urql/core'
+
+export default gql`
+ query GetChatsQuery($limit: Int, $offset: Int) {
+ loadChats(limit: $limit, offset: $offset) {
+ error
+ chats {
+ title
+ description
+ updatedAt
+ messages {
+ id
+ author
+ body
+ replyTo
+ createdAt
+ }
+ users {
+ slug
+ name
+ userpic
+ }
+ }
+ }
+ }
+`
diff --git a/src/graphql/query/collections-for-me.ts b/src/graphql/query/collections-for-me.ts
deleted file mode 100644
index 7080e2a6..00000000
--- a/src/graphql/query/collections-for-me.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query {
- getMyCollections {
- id
- title
- desc
- slug
- amount
- }
- }
-`
diff --git a/src/graphql/query/collections-for-user.ts b/src/graphql/query/collections-for-user.ts
deleted file mode 100644
index 5f390068..00000000
--- a/src/graphql/query/collections-for-user.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query CollectionsUserQuery($slug: String!) {
- getUserCollections(user: $slug) {
- id
- title
- desc
- slug
- amount
- }
- }
-`
diff --git a/src/graphql/query/my-chats.ts b/src/graphql/query/my-chats.ts
deleted file mode 100644
index 043eab0b..00000000
--- a/src/graphql/query/my-chats.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query GetChatsQuery {
- myChats {
- messages {
- chatId
- id
- author
- body
- replyTo
- createdAt
- }
- users {
- slug
- name
- pic
- }
- title
- createdAt
- }
- }
-`
diff --git a/src/graphql/query/reactions-for-shouts.ts b/src/graphql/query/reactions-load-by.ts
similarity index 71%
rename from src/graphql/query/reactions-for-shouts.ts
rename to src/graphql/query/reactions-load-by.ts
index 40469e97..70990f49 100644
--- a/src/graphql/query/reactions-for-shouts.ts
+++ b/src/graphql/query/reactions-load-by.ts
@@ -1,8 +1,8 @@
import { gql } from '@urql/core'
export default gql`
- query ReactionsForShoutsQuery($shouts: [String]!, $limit: Int!, $offset: Int!) {
- reactionsForShouts(shouts: $shouts, limit: $limit, offset: $offset) {
+ query LoadReactionsByQuery($by: ReactionsBy, $limit: Int!, $offset: Int!) {
+ loadReactionsBy(by: $by, limit: $limit, offset: $offset) {
id
createdBy {
slug
diff --git a/src/graphql/query/search-results.ts b/src/graphql/query/search-results.ts
deleted file mode 100644
index 1f551664..00000000
--- a/src/graphql/query/search-results.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { gql } from '@urql/core'
-
-export default gql`
- query SearchResultsQuery($q: String!, $limit: Int!, $offset: Int!) {
- searchQuery(q: $q, limit: $limit, offset: $offset) {
- _id: slug
- title
- subtitle
- layout
- slug
- cover
- # community
- mainTopic
- topics {
- title
- body
- slug
- stat {
- _id: shouts
- shouts
- authors
- followers
- }
- }
- authors {
- _id: slug
- name
- slug
- userpic
- }
- createdAt
- publishedAt
- stat {
- _id: viewed
- viewed
- reacted
- rating
- commented
- }
- }
- }
-`
diff --git a/src/graphql/types.gen.ts b/src/graphql/types.gen.ts
index 8f2e7454..7ea1e0cf 100644
--- a/src/graphql/types.gen.ts
+++ b/src/graphql/types.gen.ts
@@ -41,6 +41,17 @@ export type AuthorStat = {
rating?: Maybe
}
+export type AuthorsBy = {
+ createdAt?: InputMaybe
+ days?: InputMaybe
+ lastSeen?: InputMaybe
+ name?: InputMaybe
+ order?: InputMaybe
+ slug?: InputMaybe
+ stat?: InputMaybe
+ topic?: InputMaybe
+}
+
export type Chat = {
admins?: Maybe>>
createdAt: Scalars['Int']
@@ -88,12 +99,6 @@ export type Collection = {
title: Scalars['String']
}
-export type CollectionInput = {
- desc?: InputMaybe
- pic?: InputMaybe
- title: Scalars['String']
-}
-
export type Community = {
createdAt: Scalars['DateTime']
createdBy: User
@@ -104,12 +109,6 @@ export type Community = {
slug: Scalars['String']
}
-export type CommunityInput = {
- desc?: InputMaybe
- pic?: InputMaybe
- title: Scalars['String']
-}
-
export enum FollowingEntity {
Author = 'AUTHOR',
Community = 'COMMUNITY',
@@ -133,25 +132,28 @@ export enum MessageStatus {
Updated = 'UPDATED'
}
+export type MessagesBy = {
+ author?: InputMaybe
+ body?: InputMaybe
+ chat?: InputMaybe
+ days?: InputMaybe
+ order?: InputMaybe
+ stat?: InputMaybe
+}
+
export type Mutation = {
confirmEmail: AuthResult
createChat: Result
- createCollection: Result
- createCommunity: Result
createMessage: Result
createReaction: Result
createShout: Result
createTopic: Result
deleteChat: Result
- deleteCollection: Result
- deleteCommunity: Result
deleteMessage: Result
deleteReaction: Result
deleteShout: Result
destroyTopic: Result
- enterChat: Result
follow: Result
- incrementView: Result
inviteAuthor: Result
inviteChat: Result
markAsRead: Result
@@ -162,9 +164,8 @@ export type Mutation = {
sendLink: Result
unfollow: Result
updateChat: Result
- updateCollection: Result
- updateCommunity: Result
updateMessage: Result
+ updateOnlineStatus: Result
updateProfile: Result
updateReaction: Result
updateShout: Result
@@ -180,14 +181,6 @@ export type MutationCreateChatArgs = {
title?: InputMaybe
}
-export type MutationCreateCollectionArgs = {
- collection: CollectionInput
-}
-
-export type MutationCreateCommunityArgs = {
- community: CommunityInput
-}
-
export type MutationCreateMessageArgs = {
body: Scalars['String']
chatId: Scalars['String']
@@ -210,14 +203,6 @@ export type MutationDeleteChatArgs = {
chatId: Scalars['String']
}
-export type MutationDeleteCollectionArgs = {
- slug: Scalars['String']
-}
-
-export type MutationDeleteCommunityArgs = {
- slug: Scalars['String']
-}
-
export type MutationDeleteMessageArgs = {
chatId: Scalars['String']
id: Scalars['Int']
@@ -235,19 +220,11 @@ export type MutationDestroyTopicArgs = {
slug: Scalars['String']
}
-export type MutationEnterChatArgs = {
- chatId: Scalars['String']
-}
-
export type MutationFollowArgs = {
slug: Scalars['String']
what: FollowingEntity
}
-export type MutationIncrementViewArgs = {
- shout: Scalars['String']
-}
-
export type MutationInviteAuthorArgs = {
author: Scalars['String']
shout: Scalars['String']
@@ -293,14 +270,6 @@ export type MutationUpdateChatArgs = {
chat: ChatInput
}
-export type MutationUpdateCollectionArgs = {
- collection: CollectionInput
-}
-
-export type MutationUpdateCommunityArgs = {
- community: CommunityInput
-}
-
export type MutationUpdateMessageArgs = {
body: Scalars['String']
chatId: Scalars['String']
@@ -348,98 +317,66 @@ export type ProfileInput = {
export type Query = {
authorsAll: Array>
- collectionsAll: Array>
getAuthor: User
getCollabs: Array>
- getCommunities: Array>
- getCommunity: Community
- getShoutBySlug: Shout
getTopic: Topic
- getUserCollections: Array>
- getUserRoles: Array>
- getUsersBySlugs: Array>
isEmailUsed: Scalars['Boolean']
+ loadAuthorsBy: Array>
loadChats: Result
- loadMessages: Result
+ loadMessagesBy: Result
+ loadReactionsBy: Array>
+ loadShoutsBy: Array>
markdownBody: Scalars['String']
- reactionsByAuthor: Array>
- reactionsForShouts: Array>
- recentAll: Array>
- recentCandidates: Array>
- recentCommented: Array>
- recentLayoutShouts: Array>
- recentPublished: Array>
- recentReacted: Array>
- searchChats: Result
- searchMessages: Result
- searchQuery?: Maybe>>
searchUsers: Result
- shoutsByAuthors: Array>
- shoutsByCollection: Array>
- shoutsByCommunities: Array>
- shoutsByLayout: Array>
- shoutsByTopics: Array>
- shoutsForFeed: Array>
signIn: AuthResult
signOut: AuthResult
- topAuthors: Array>
- topCommented: Array>
- topLayoutShouts: Array>
- topMonth: Array>
- topMonthLayoutShouts: Array>
- topOverall: Array>
- topPublished: Array>
topicsAll: Array>
topicsByAuthor: Array>
topicsByCommunity: Array>
topicsRandom: Array>
userFollowedAuthors: Array>
- userFollowedCommunities: Array>
userFollowedTopics: Array>
userFollowers: Array>
- userReactedShouts: Array>
}
export type QueryGetAuthorArgs = {
slug: Scalars['String']
}
-export type QueryGetCommunityArgs = {
- slug?: InputMaybe
-}
-
-export type QueryGetShoutBySlugArgs = {
- slug: Scalars['String']
-}
-
export type QueryGetTopicArgs = {
slug: Scalars['String']
}
-export type QueryGetUserCollectionsArgs = {
- author: Scalars['String']
-}
-
-export type QueryGetUserRolesArgs = {
- slug: Scalars['String']
-}
-
-export type QueryGetUsersBySlugsArgs = {
- slugs: Array>
-}
-
export type QueryIsEmailUsedArgs = {
email: Scalars['String']
}
-export type QueryLoadChatsArgs = {
- amount?: InputMaybe
+export type QueryLoadAuthorsByArgs = {
+ by?: InputMaybe
+ limit?: InputMaybe
offset?: InputMaybe
}
-export type QueryLoadMessagesArgs = {
- amount?: InputMaybe
- chatId: Scalars['String']
+export type QueryLoadChatsArgs = {
+ limit?: InputMaybe
+ offset?: InputMaybe
+}
+
+export type QueryLoadMessagesByArgs = {
+ by: MessagesBy
+ limit?: InputMaybe
+ offset?: InputMaybe
+}
+
+export type QueryLoadReactionsByArgs = {
+ by: ReactionBy
+ limit?: InputMaybe
+ offset?: InputMaybe
+}
+
+export type QueryLoadShoutsByArgs = {
+ by?: InputMaybe
+ limit?: InputMaybe
offset?: InputMaybe
}
@@ -447,106 +384,10 @@ export type QueryMarkdownBodyArgs = {
body: Scalars['String']
}
-export type QueryReactionsByAuthorArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
- slug: Scalars['String']
-}
-
-export type QueryReactionsForShoutsArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
- shouts: Array>
-}
-
-export type QueryRecentAllArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
-}
-
-export type QueryRecentCandidatesArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
-}
-
-export type QueryRecentCommentedArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
-}
-
-export type QueryRecentLayoutShoutsArgs = {
- amount?: InputMaybe
- layout: Scalars['String']
- offset?: InputMaybe
-}
-
-export type QueryRecentPublishedArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
-}
-
-export type QueryRecentReactedArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
-}
-
-export type QuerySearchChatsArgs = {
- amount?: InputMaybe
- offset?: InputMaybe
- q: Scalars['String']
-}
-
-export type QuerySearchMessagesArgs = {
- amount?: InputMaybe
- offset?: InputMaybe
- q: Scalars['String']
-}
-
-export type QuerySearchQueryArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
- q?: InputMaybe
-}
-
export type QuerySearchUsersArgs = {
- amount?: InputMaybe
+ limit?: InputMaybe
offset?: InputMaybe
- q: Scalars['String']
-}
-
-export type QueryShoutsByAuthorsArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
- slugs: Array>
-}
-
-export type QueryShoutsByCollectionArgs = {
- collection: Scalars['String']
- limit: Scalars['Int']
- offset: Scalars['Int']
-}
-
-export type QueryShoutsByCommunitiesArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
- slugs: Array>
-}
-
-export type QueryShoutsByLayoutArgs = {
- amount: Scalars['Int']
- layout?: InputMaybe
- offset: Scalars['Int']
-}
-
-export type QueryShoutsByTopicsArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
- slugs: Array>
-}
-
-export type QueryShoutsForFeedArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
+ query: Scalars['String']
}
export type QuerySignInArgs = {
@@ -555,44 +396,6 @@ export type QuerySignInArgs = {
password?: InputMaybe
}
-export type QueryTopAuthorsArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
-}
-
-export type QueryTopCommentedArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
-}
-
-export type QueryTopLayoutShoutsArgs = {
- amount?: InputMaybe
- layout: Scalars['String']
- offset?: InputMaybe
-}
-
-export type QueryTopMonthArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
-}
-
-export type QueryTopMonthLayoutShoutsArgs = {
- amount?: InputMaybe
- layout: Scalars['String']
- offset?: InputMaybe
-}
-
-export type QueryTopOverallArgs = {
- limit: Scalars['Int']
- offset: Scalars['Int']
-}
-
-export type QueryTopPublishedArgs = {
- daysago: Scalars['Int']
- limit: Scalars['Int']
- offset: Scalars['Int']
-}
-
export type QueryTopicsByAuthorArgs = {
author: Scalars['String']
}
@@ -609,10 +412,6 @@ export type QueryUserFollowedAuthorsArgs = {
slug: Scalars['String']
}
-export type QueryUserFollowedCommunitiesArgs = {
- slug: Scalars['String']
-}
-
export type QueryUserFollowedTopicsArgs = {
slug: Scalars['String']
}
@@ -621,10 +420,6 @@ export type QueryUserFollowersArgs = {
slug: Scalars['String']
}
-export type QueryUserReactedShoutsArgs = {
- slug: Scalars['String']
-}
-
export type Rating = {
rater: Scalars['String']
value: Scalars['Int']
@@ -647,6 +442,17 @@ export type Reaction = {
updatedAt?: Maybe
}
+export type ReactionBy = {
+ author?: InputMaybe
+ body?: InputMaybe
+ days?: InputMaybe
+ order?: InputMaybe
+ shout?: InputMaybe
+ shouts?: InputMaybe>>
+ stat?: InputMaybe
+ topic?: InputMaybe
+}
+
export type ReactionInput = {
body?: InputMaybe
kind: Scalars['Int']
@@ -757,6 +563,20 @@ export type ShoutInput = {
visibleForUsers?: InputMaybe>>
}
+export type ShoutsBy = {
+ author?: InputMaybe
+ body?: InputMaybe
+ days?: InputMaybe
+ layout?: InputMaybe
+ order?: InputMaybe
+ slug?: InputMaybe
+ stat?: InputMaybe
+ title?: InputMaybe
+ topic?: InputMaybe
+ topics?: InputMaybe>>
+ visibility?: InputMaybe
+}
+
export type Stat = {
commented?: Maybe
ranking?: Maybe
diff --git a/src/layouts/zine.astro b/src/layouts/zine.astro
deleted file mode 100644
index 41be19e4..00000000
--- a/src/layouts/zine.astro
+++ /dev/null
@@ -1,23 +0,0 @@
----
-import { setLocale } from '../stores/ui';
-import '../styles/app.scss'
-import { t } from '../utils/intl'
-
-const lang = Astro.url.searchParams.get('lang') || 'ru'
-console.log('[layout] server locale is', lang)
-setLocale(lang)
-
----
-
-
-
-
-
- {t('Discours')}
-
-
-
-
-
-
-
diff --git a/src/locales/ru.json b/src/locales/ru.json
index 979fffde..900d6684 100644
--- a/src/locales/ru.json
+++ b/src/locales/ru.json
@@ -171,6 +171,10 @@
"Link sent, check your email": "Ссылка отправлена, проверьте почту",
"Create post": "Создать публикацию",
"Just start typing...": "Просто начните печатать...",
+ "Artworks": "Артворки",
+ "Audio": "Аудио",
+ "Video": "Видео",
+ "Literature": "Литература",
"We can't find you, check email or": "Не можем вас найти, проверьте адрес электронной почты или",
"register": "зарегистрируйтесь"
}
diff --git a/src/main.astro b/src/main.astro
new file mode 100644
index 00000000..a4fcae67
--- /dev/null
+++ b/src/main.astro
@@ -0,0 +1,30 @@
+---
+import { setLocale } from './stores/ui'
+import './styles/app.scss'
+import { t } from './utils/intl'
+
+// Setting locale for prerendered content here
+
+const lang = Astro.url.searchParams.get('lang') || 'ru'
+console.log('[main.astro] astro runtime locale is', lang)
+setLocale(lang)
+
+---
+
+
+
+
+
+ {t('Discours')}
+
+
+
+
+
+
+
+
diff --git a/src/pages/404.astro b/src/pages/404.astro
index e1a8d16a..3fcad65b 100644
--- a/src/pages/404.astro
+++ b/src/pages/404.astro
@@ -1,5 +1,5 @@
---
-import Zine from '../layouts/zine.astro'
+import Prerendered from '../main.astro'
import { Root } from '../components/Root'
import { initRouter } from '../stores/router'
@@ -9,6 +9,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
+
-
+
diff --git a/src/pages/[...slug].astro b/src/pages/[...slug].astro
index 9ca1dbfd..0e0e13c0 100644
--- a/src/pages/[...slug].astro
+++ b/src/pages/[...slug].astro
@@ -1,6 +1,6 @@
---
import { Root } from '../components/Root'
-import Zine from '../layouts/zine.astro'
+import Prerendered from '../main.astro'
import { apiClient } from '../utils/apiClient'
import { initRouter } from '../stores/router'
@@ -9,7 +9,7 @@ if (slug.endsWith('.map')) {
return Astro.redirect('/404')
}
-const article = await apiClient.getArticle({ slug })
+const article = await apiClient.loadShoutsBy({ by: { slug }, limit: 1})
if (!article) {
return Astro.redirect('/404')
}
@@ -20,6 +20,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
-
-
+
+
+
diff --git a/src/pages/about/discussion-rules.astro b/src/pages/about/discussion-rules.astro
index d41f44f0..c7354d08 100644
--- a/src/pages/about/discussion-rules.astro
+++ b/src/pages/about/discussion-rules.astro
@@ -1,5 +1,5 @@
---
-import Zine from '../../layouts/zine.astro'
+import Prerendered from '../../main.astro'
import { Root } from '../../components/Root'
import { initRouter } from '../../stores/router'
@@ -9,6 +9,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
+
-
+
diff --git a/src/pages/about/dogma.astro b/src/pages/about/dogma.astro
index d41f44f0..c7354d08 100644
--- a/src/pages/about/dogma.astro
+++ b/src/pages/about/dogma.astro
@@ -1,5 +1,5 @@
---
-import Zine from '../../layouts/zine.astro'
+import Prerendered from '../../main.astro'
import { Root } from '../../components/Root'
import { initRouter } from '../../stores/router'
@@ -9,6 +9,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
+
-
+
diff --git a/src/pages/about/guide.astro b/src/pages/about/guide.astro
index d41f44f0..c7354d08 100644
--- a/src/pages/about/guide.astro
+++ b/src/pages/about/guide.astro
@@ -1,5 +1,5 @@
---
-import Zine from '../../layouts/zine.astro'
+import Prerendered from '../../main.astro'
import { Root } from '../../components/Root'
import { initRouter } from '../../stores/router'
@@ -9,6 +9,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
+
-
+
diff --git a/src/pages/about/help.astro b/src/pages/about/help.astro
index d41f44f0..891e0539 100644
--- a/src/pages/about/help.astro
+++ b/src/pages/about/help.astro
@@ -1,14 +1,18 @@
---
-import Zine from '../../layouts/zine.astro'
+import Prerendered from '../../main.astro'
import { Root } from '../../components/Root'
import { initRouter } from '../../stores/router'
const { pathname, search } = Astro.url
initRouter(pathname, search)
+Astro.response.headers.set(
+ "Content-Security-Policy",
+ "frame-src 'self' https://*.discours.io https://widget.cloudpayments.ru; frame-ancestors 'self' https://*.discours.io https://widget.cloudpayments.ru;"
+)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
+
-
+
diff --git a/src/pages/about/manifest.astro b/src/pages/about/manifest.astro
index d41f44f0..c7354d08 100644
--- a/src/pages/about/manifest.astro
+++ b/src/pages/about/manifest.astro
@@ -1,5 +1,5 @@
---
-import Zine from '../../layouts/zine.astro'
+import Prerendered from '../../main.astro'
import { Root } from '../../components/Root'
import { initRouter } from '../../stores/router'
@@ -9,6 +9,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
+
-
+
diff --git a/src/pages/about/partners.astro b/src/pages/about/partners.astro
index d41f44f0..c7354d08 100644
--- a/src/pages/about/partners.astro
+++ b/src/pages/about/partners.astro
@@ -1,5 +1,5 @@
---
-import Zine from '../../layouts/zine.astro'
+import Prerendered from '../../main.astro'
import { Root } from '../../components/Root'
import { initRouter } from '../../stores/router'
@@ -9,6 +9,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
+
-
+
diff --git a/src/pages/about/principles.astro b/src/pages/about/principles.astro
index d41f44f0..c7354d08 100644
--- a/src/pages/about/principles.astro
+++ b/src/pages/about/principles.astro
@@ -1,5 +1,5 @@
---
-import Zine from '../../layouts/zine.astro'
+import Prerendered from '../../main.astro'
import { Root } from '../../components/Root'
import { initRouter } from '../../stores/router'
@@ -9,6 +9,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
+
-
+
diff --git a/src/pages/about/projects.astro b/src/pages/about/projects.astro
index d41f44f0..c7354d08 100644
--- a/src/pages/about/projects.astro
+++ b/src/pages/about/projects.astro
@@ -1,5 +1,5 @@
---
-import Zine from '../../layouts/zine.astro'
+import Prerendered from '../../main.astro'
import { Root } from '../../components/Root'
import { initRouter } from '../../stores/router'
@@ -9,6 +9,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
+
-
+
diff --git a/src/pages/about/terms-of-use.astro b/src/pages/about/terms-of-use.astro
index d41f44f0..c7354d08 100644
--- a/src/pages/about/terms-of-use.astro
+++ b/src/pages/about/terms-of-use.astro
@@ -1,5 +1,5 @@
---
-import Zine from '../../layouts/zine.astro'
+import Prerendered from '../../main.astro'
import { Root } from '../../components/Root'
import { initRouter } from '../../stores/router'
@@ -9,6 +9,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
+
-
+
diff --git a/src/pages/about/thanks.astro b/src/pages/about/thanks.astro
index d41f44f0..c7354d08 100644
--- a/src/pages/about/thanks.astro
+++ b/src/pages/about/thanks.astro
@@ -1,5 +1,5 @@
---
-import Zine from '../../layouts/zine.astro'
+import Prerendered from '../../main.astro'
import { Root } from '../../components/Root'
import { initRouter } from '../../stores/router'
@@ -9,6 +9,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
+
-
+
diff --git a/src/pages/author/[slug]/index.astro b/src/pages/author/[slug]/index.astro
index f7a2cc9b..efcd8ffd 100644
--- a/src/pages/author/[slug]/index.astro
+++ b/src/pages/author/[slug]/index.astro
@@ -1,13 +1,13 @@
---
import { Root } from '../../../components/Root'
-import Zine from '../../../layouts/zine.astro'
+import Prerendered from '../../../main.astro'
import { apiClient } from '../../../utils/apiClient'
import { initRouter } from '../../../stores/router'
import { PRERENDERED_ARTICLES_COUNT } from '../../../components/Views/Author'
const slug = Astro.params.slug.toString()
-const articles = await apiClient.getArticlesForAuthors({ authorSlugs: [slug], limit: PRERENDERED_ARTICLES_COUNT })
-const author = await apiClient.getAuthor({ slug })
+const shouts = await apiClient.loadShoutsBy({ by: { author: slug } , limit: PRERENDERED_ARTICLES_COUNT })
+const author = await apiClient.loadAuthorsBy({ by: { slug } })
const { pathname, search } = Astro.url
initRouter(pathname, search)
@@ -15,6 +15,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
-
-
+
+
+
diff --git a/src/pages/authors.astro b/src/pages/authors.astro
index 2b5b1176..7483a581 100644
--- a/src/pages/authors.astro
+++ b/src/pages/authors.astro
@@ -1,6 +1,6 @@
---
import { Root } from '../components/Root'
-import Zine from '../layouts/zine.astro'
+import Prerendered from '../main.astro'
import { apiClient } from '../utils/apiClient'
import { initRouter } from '../stores/router'
@@ -10,6 +10,6 @@ const { pathname, search } = Astro.url
initRouter(pathname, search)
---
-
+
-
+
diff --git a/src/pages/connect.astro b/src/pages/connect.astro
index e1a8d16a..3fcad65b 100644
--- a/src/pages/connect.astro
+++ b/src/pages/connect.astro
@@ -1,5 +1,5 @@
---
-import Zine from '../layouts/zine.astro'
+import Prerendered from '../main.astro'
import { Root } from '../components/Root'
import { initRouter } from '../stores/router'
@@ -9,6 +9,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
+
-
+
diff --git a/src/pages/create.astro b/src/pages/create.astro
index defdaefe..b4ffc2d1 100644
--- a/src/pages/create.astro
+++ b/src/pages/create.astro
@@ -1,6 +1,6 @@
---
import { Root } from '../components/Root'
-import Zine from '../layouts/zine.astro'
+import Prerendered from '../main.astro'
import { initRouter } from '../stores/router'
const { pathname, search } = Astro.url
@@ -8,6 +8,6 @@ initRouter(pathname, search)
---
-
+
-
+
diff --git a/src/pages/expo/[...layout].astro b/src/pages/expo/[...layout].astro
new file mode 100644
index 00000000..858bbf01
--- /dev/null
+++ b/src/pages/expo/[...layout].astro
@@ -0,0 +1,21 @@
+---
+import { Root } from '../../components/Root'
+import Prerendered from '../../main.astro'
+import { apiClient } from '../../utils/apiClient'
+import { initRouter } from '../../stores/router'
+import type { LayoutType } from '../../stores/zine/layouts'
+import { Layout } from '../../components/EditorExample/components/Layout'
+
+const layout = (Astro.params.layout?.toString() || 'article') as LayoutType
+if (!layout || layout.endsWith('.map')) {
+ return Astro.redirect('/404')
+}
+const shouts = await apiClient.loadShoutsBy({ by: { layout } })
+const { pathname, search } = Astro.url
+initRouter(pathname, search)
+---
+
+
+
+
+
diff --git a/src/pages/feed/index.astro b/src/pages/feed/index.astro
index e9063068..9ab066a5 100644
--- a/src/pages/feed/index.astro
+++ b/src/pages/feed/index.astro
@@ -1,12 +1,12 @@
---
import { Root } from '../../components/Root'
-import Zine from '../../layouts/zine.astro'
+import Prerendered from '../../main.astro'
import { initRouter } from '../../stores/router'
const { pathname, search } = Astro.url
initRouter(pathname, search)
---
-
+
-
+
diff --git a/src/pages/feed/settings.astro b/src/pages/feed/settings.astro
new file mode 100644
index 00000000..98564ae8
--- /dev/null
+++ b/src/pages/feed/settings.astro
@@ -0,0 +1,12 @@
+---
+import Prerendered from '../../main.astro'
+import { Root } from '../../components/Root'
+import { initRouter } from '../../stores/router'
+
+const { pathname, search } = Astro.url
+initRouter(pathname, search)
+---
+
+
+
+
diff --git a/src/pages/feed/settings.astro.bak b/src/pages/feed/settings.astro.bak
deleted file mode 100644
index 11bef960..00000000
--- a/src/pages/feed/settings.astro.bak
+++ /dev/null
@@ -1,13 +0,0 @@
----
-import Zine from '../../layouts/zine.astro'
-import { FeedSettings } from '../../components/Views/FeedSettings'
-
-import { initRouter } from '../../stores/router'
-
-const { pathname, search } = Astro.url
-initRouter(pathname, search)
----
-
-
-
-
diff --git a/src/pages/inbox.astro b/src/pages/inbox.astro
index 8e7abf67..e613673f 100644
--- a/src/pages/inbox.astro
+++ b/src/pages/inbox.astro
@@ -1,15 +1,13 @@
---
-import Zine from '../layouts/zine.astro'
+import Prerendered from '../main.astro'
import { Root } from '../components/Root'
import { apiClient } from '../utils/apiClient'
import { initRouter } from '../stores/router'
-const chatrooms = await apiClient.getInboxes()
-
const { pathname, search } = Astro.url
initRouter(pathname, search)
---
-
-
-
+
+
+
diff --git a/src/pages/index.astro b/src/pages/index.astro
index 9bbde9a4..2bf6b0bd 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -1,12 +1,13 @@
---
-import Zine from '../layouts/zine.astro'
+import Prerendered from '../main.astro'
import { Root } from '../components/Root'
import { apiClient } from '../utils/apiClient'
import { initRouter } from '../stores/router'
import { PRERENDERED_ARTICLES_COUNT } from '../components/Views/Home'
const randomTopics = await apiClient.getRandomTopics({ amount: 12 })
-const articles = await apiClient.getRecentPublishedArticles({ limit: PRERENDERED_ARTICLES_COUNT })
+const articles = await apiClient.loadShoutsBy(
+ { by: { visibility: "public" }, limit: PRERENDERED_ARTICLES_COUNT, offset: 0 })
const { pathname, search } = Astro.url
initRouter(pathname, search)
@@ -14,7 +15,7 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
-
-
+
+
+
diff --git a/src/pages/search.astro b/src/pages/search.astro
index 7de5f5a7..21dd5fad 100644
--- a/src/pages/search.astro
+++ b/src/pages/search.astro
@@ -1,17 +1,17 @@
---
import { Root } from '../components/Root'
-import Zine from '../layouts/zine.astro'
+import Prerendered from '../main.astro'
import { apiClient } from '../utils/apiClient'
import { initRouter } from '../stores/router'
const params: URLSearchParams = Astro.url.searchParams
const q = params.get('q')
-const searchResults = await apiClient.getSearchResults({ query: q, limit: 50 })
+const searchResults = await apiClient.loadShoutsBy({ by: { title: q, body: q }, limit: 50 })
const { pathname, search } = Astro.url
initRouter(pathname, search)
---
-
+
-
+
diff --git a/src/pages/topic/[slug].astro b/src/pages/topic/[slug].astro
index c8f61246..4b43c5c0 100644
--- a/src/pages/topic/[slug].astro
+++ b/src/pages/topic/[slug].astro
@@ -1,11 +1,11 @@
---
import { Root } from '../../components/Root'
-import Zine from '../../layouts/zine.astro'
+import Prerendered from '../../main.astro'
import { apiClient } from '../../utils/apiClient'
import { PRERENDERED_ARTICLES_COUNT } from '../../components/Views/Topic'
const slug = Astro.params.slug?.toString() || ''
-const articles = await apiClient.getArticlesForTopics({ topicSlugs: [slug], limit: PRERENDERED_ARTICLES_COUNT })
+const shouts = await apiClient.loadShoutsBy({ by: { topics: [slug] }, limit: PRERENDERED_ARTICLES_COUNT })
const topic = await apiClient.getTopic({ slug })
import { initRouter } from '../../stores/router'
@@ -16,6 +16,6 @@ initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
---
-
-
-
+
+
+
diff --git a/src/pages/topics.astro b/src/pages/topics.astro
index eda7b67a..9b115358 100644
--- a/src/pages/topics.astro
+++ b/src/pages/topics.astro
@@ -1,6 +1,6 @@
---
import { Root } from '../components/Root'
-import Zine from '../layouts/zine.astro'
+import Prerendered from '../main.astro'
import { apiClient } from '../utils/apiClient'
import { initRouter } from '../stores/router'
@@ -10,7 +10,7 @@ const { pathname, search } = Astro.url
initRouter(pathname, search)
---
-
+
-
+
diff --git a/src/stores/editor.ts b/src/stores/editor.ts
index 8acb0c42..c79bb596 100644
--- a/src/stores/editor.ts
+++ b/src/stores/editor.ts
@@ -1,8 +1,8 @@
-import { persistentMap } from '@nanostores/persistent'
+import { createStorageSignal } from '@solid-primitives/storage'
import type { Reaction } from '../graphql/types.gen'
-import { atom } from 'nanostores'
import { createSignal } from 'solid-js'
+// TODO: store drafts
// import type { Draft } from '../components/EditorExample/store/context'
interface Collab {
@@ -13,18 +13,13 @@ interface Collab {
title?: string
}
-export const drafts = persistentMap<{ [key: string]: string }>(
- 'drafts',
- {},
- {
- encode: JSON.stringify,
- decode: JSON.parse
- }
-) // save drafts on device
-
-export const collabs = atom([]) // save collabs in backend or in p2p network
+export const drafts = createStorageSignal<{ [key: string]: string }>('drafts', {}) // save drafts on device
+export const [collabs, setCollabs] = createSignal([]) // save collabs in backend or in p2p network
export const [editorReactions, setReactions] = createSignal([])
/*
+
+TODO: approvals and proposals derived stores
+
const approvals = computed(
reactions,
(rdict) => Object.values(rdict)
diff --git a/src/stores/inbox.ts b/src/stores/inbox.ts
index bbf7c471..72996b41 100644
--- a/src/stores/inbox.ts
+++ b/src/stores/inbox.ts
@@ -1,4 +1,4 @@
-import { atom } from 'nanostores'
+import { createSignal } from 'solid-js'
import type { Chat } from '../graphql/types.gen'
-export const chats = atom([])
+export const [chats, setChats] = createSignal([])
diff --git a/src/stores/router.ts b/src/stores/router.ts
index ab156ef2..01fb8a37 100644
--- a/src/stores/router.ts
+++ b/src/stores/router.ts
@@ -25,12 +25,15 @@ export interface Routes {
projects: void
termsOfUse: void
thanks: void
+ expo: 'layout'
+ inbox: void // TODO: добавить ID текущего юзера
}
const searchParamsStore = createSearchParams()
const routerStore = createRouter(
{
home: '/',
+ inbox: '/inbox',
connect: '/connect',
create: '/create',
topics: '/topics',
@@ -49,7 +52,8 @@ const routerStore = createRouter(
principles: '/about/principles',
projects: '/about/projects',
termsOfUse: '/about/terms-of-use',
- thanks: '/about/thanks'
+ thanks: '/about/thanks',
+ expo: '/expo/:layout'
},
{
search: false,
diff --git a/src/stores/ui.ts b/src/stores/ui.ts
index d71801a8..cbff3f54 100644
--- a/src/stores/ui.ts
+++ b/src/stores/ui.ts
@@ -1,10 +1,8 @@
-//import { persistentAtom } from '@nanostores/persistent'
import { createSignal } from 'solid-js'
import { useRouter } from './router'
import type { AuthModalSearchParams, ConfirmEmailSearchParams } from '../components/Nav/AuthModal/types'
import type { RootSearchParams } from '../components/types'
-//export const locale = persistentAtom('locale', 'ru')
export const [locale, setLocale] = createSignal('ru')
export type ModalType = 'auth' | 'subscribe' | 'feedback' | 'thank' | 'donate'
type WarnKind = 'error' | 'warn' | 'info'
diff --git a/src/stores/zine/articles.ts b/src/stores/zine/articles.ts
index a7ac1eee..9638d803 100644
--- a/src/stores/zine/articles.ts
+++ b/src/stores/zine/articles.ts
@@ -1,4 +1,4 @@
-import type { Author, Shout, ShoutInput, Topic } from '../../graphql/types.gen'
+import type { Author, Shout, ShoutInput, ShoutsBy, Topic } from '../../graphql/types.gen'
import { apiClient } from '../../utils/apiClient'
import { addAuthorsByTopic } from './authors'
import { addTopicsByAuthor } from './topics'
@@ -123,95 +123,17 @@ const addSortedArticles = (articles: Shout[]) => {
setSortedArticles((prevSortedArticles) => [...prevSortedArticles, ...articles])
}
-export const loadFeed = async ({
- limit,
- offset
-}: {
- limit: number
- offset?: number
-}): Promise<{ hasMore: boolean }> => {
- // TODO: load actual feed
- return await loadRecentArticles({ limit, offset })
-}
-
-export const loadRecentArticles = async ({
- limit,
- offset
-}: {
- limit: number
- offset?: number
-}): Promise<{ hasMore: boolean }> => {
- const newArticles = await apiClient.getRecentArticles({ limit: limit + 1, offset })
- const hasMore = newArticles.length === limit + 1
-
- if (hasMore) {
- newArticles.splice(-1)
- }
-
- addArticles(newArticles)
- addSortedArticles(newArticles)
-
- return { hasMore }
-}
-
-export const loadPublishedArticles = async ({
+export const loadShoutsBy = async ({
+ by,
limit,
offset = 0
}: {
+ by: ShoutsBy
limit: number
offset?: number
}): Promise<{ hasMore: boolean }> => {
- const newArticles = await apiClient.getPublishedArticles({ limit: limit + 1, offset })
- const hasMore = newArticles.length === limit + 1
-
- if (hasMore) {
- newArticles.splice(-1)
- }
-
- addArticles(newArticles)
- addSortedArticles(newArticles)
-
- return { hasMore }
-}
-
-export const loadAuthorArticles = async ({
- authorSlug,
- limit,
- offset = 0
-}: {
- authorSlug: string
- limit: number
- offset?: number
-}): Promise<{ hasMore: boolean }> => {
- const newArticles = await apiClient.getArticlesForAuthors({
- authorSlugs: [authorSlug],
- limit: limit + 1,
- offset
- })
-
- const hasMore = newArticles.length === limit + 1
-
- if (hasMore) {
- newArticles.splice(-1)
- }
-
- addArticles(newArticles)
- addSortedArticles(newArticles)
-
- return { hasMore }
-}
-
-export const loadTopicArticles = async ({
- topicSlug,
- limit,
- offset
-}: {
- topicSlug: string
- limit: number
- offset: number
-}): Promise<{ hasMore: boolean }> => {
- const newArticles = await apiClient.getArticlesForTopics({
- topicSlugs: [topicSlug],
+ const newArticles = await apiClient.loadShoutsBy({
+ by,
limit: limit + 1,
offset
})
@@ -232,46 +154,6 @@ export const resetSortedArticles = () => {
setSortedArticles([])
}
-export const loadTopMonthArticles = async (): Promise => {
- const articles = await apiClient.getTopMonthArticles()
- addArticles(articles)
- setTopMonthArticles(articles)
-}
-
-export const loadTopArticles = async (): Promise => {
- const articles = await apiClient.getTopArticles()
- addArticles(articles)
- setTopArticles(articles)
-}
-
-export const loadSearchResults = async ({
- query,
- limit,
- offset
-}: {
- query: string
- limit?: number
- offset?: number
-}): Promise => {
- const newArticles = await apiClient.getSearchResults({ query, limit, offset })
- addArticles(newArticles)
- addSortedArticles(newArticles)
-}
-
-export const incrementView = async ({ articleSlug }: { articleSlug: string }): Promise => {
- await apiClient.incrementView({ articleSlug })
-}
-
-export const loadArticle = async ({ slug }: { slug: string }): Promise => {
- const article = await apiClient.getArticle({ slug })
-
- if (!article) {
- throw new Error(`Can't load article, slug: "${slug}"`)
- }
-
- addArticles([article])
-}
-
export const createArticle = async ({ article }: { article: ShoutInput }) => {
try {
await apiClient.createArticle({ article })
@@ -281,27 +163,26 @@ export const createArticle = async ({ article }: { article: ShoutInput }) => {
}
type InitialState = {
- sortedArticles?: Shout[]
- topRatedArticles?: Shout[]
- topRatedMonthArticles?: Shout[]
+ shouts?: Shout[]
}
export const useArticlesStore = (initialState: InitialState = {}) => {
- addArticles([...(initialState.sortedArticles || [])])
+ addArticles([...(initialState.shouts || [])])
- if (initialState.sortedArticles) {
- setSortedArticles([...initialState.sortedArticles])
+ if (initialState.shouts) {
+ setSortedArticles([...initialState.shouts])
}
return {
articleEntities,
sortedArticles,
- articlesByTopic,
+ loadShoutsBy,
articlesByAuthor,
- topArticles,
+ articlesByLayout,
+ articlesByTopic,
topMonthArticles,
- topViewedArticles,
+ topArticles,
topCommentedArticles,
- articlesByLayout
+ topViewedArticles
}
}
diff --git a/src/stores/zine/layouts.ts b/src/stores/zine/layouts.ts
new file mode 100644
index 00000000..9ff3d4a0
--- /dev/null
+++ b/src/stores/zine/layouts.ts
@@ -0,0 +1,58 @@
+import type { Shout, ShoutsBy } from '../../graphql/types.gen'
+import { apiClient } from '../../utils/apiClient'
+import { useArticlesStore } from './articles'
+import { createSignal } from 'solid-js'
+
+export type LayoutType = 'article' | 'audio' | 'video' | 'image' | 'literature'
+
+const [sortedLayoutShouts, setSortedLayoutShouts] = createSignal