diff --git a/src/graphql/mutation/my-session.ts b/src/graphql/mutation/my-session.ts
index 02964603..49c95baa 100644
--- a/src/graphql/mutation/my-session.ts
+++ b/src/graphql/mutation/my-session.ts
@@ -1,7 +1,7 @@
import { gql } from '@urql/core'
export default gql`
- query RefreshSessionQuery {
+ mutation RefreshSessionMutation {
refreshSession {
error
token
diff --git a/src/stores/ui.ts b/src/stores/ui.ts
index 5ed1fb67..e3bff0d4 100644
--- a/src/stores/ui.ts
+++ b/src/stores/ui.ts
@@ -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
('locale', 'ru')
diff --git a/src/stores/zine/authors.ts b/src/stores/zine/authors.ts
index 733831bb..f8e3500f 100644
--- a/src/stores/zine/authors.ts
+++ b/src/stores/zine/authors.ts
@@ -7,7 +7,7 @@ import { byCreated, byStat } from '../../utils/sortby'
export type AuthorsSortBy = 'created' | 'name'
-const sortByStore = atom('created')
+const sortAllByStore = atom('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
diff --git a/src/stores/zine/common.ts b/src/stores/zine/common.ts
index 1f62a9b7..5b950248 100644
--- a/src/stores/zine/common.ts
+++ b/src/stores/zine/common.ts
@@ -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 }) => {
diff --git a/src/stores/zine/topics.ts b/src/stores/zine/topics.ts
index 95546dc7..dfef8a2a 100644
--- a/src/stores/zine/topics.ts
+++ b/src/stores/zine/topics.ts
@@ -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('created')
+const sortAllByStore = atom('created')
let topicEntitiesStore: WritableAtom<{ [topicSlug: string]: Topic }>
let sortedTopicsStore: ReadableAtom
@@ -22,7 +23,7 @@ const initStore = (initial?: Record) => {
topicEntitiesStore = atom>(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) => {
})
}
+export const setSortAllBy = (sortBy: TopicsSortBy) => {
+ sortAllByStore.set(sortBy)
+}
+
const addTopics = (...args: Topic[][]) => {
const allTopics = args.flatMap((topics) => topics || [])
diff --git a/src/utils/sortby.ts b/src/utils/sortby.ts
index da8f8050..ba25824b 100644
--- a/src/utils/sortby.ts
+++ b/src/utils/sortby.ts
@@ -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