From 8f6bea06bdb217205ed10ff0bd20c42a9d5714c2 Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Wed, 5 Oct 2022 11:55:26 +0300 Subject: [PATCH] some-fixes --- src/graphql/types.gen.ts | 2 +- src/stores/create.ts | 71 ++++++++++++++++++++---------------- src/stores/inbox.ts | 10 ++--- src/stores/zine/reactions.ts | 2 +- src/utils/apiClient.ts | 4 +- src/utils/logger.ts | 5 +-- src/utils/ru2en.ts | 2 +- 7 files changed, 49 insertions(+), 47 deletions(-) diff --git a/src/graphql/types.gen.ts b/src/graphql/types.gen.ts index 9f318698..a2b73043 100644 --- a/src/graphql/types.gen.ts +++ b/src/graphql/types.gen.ts @@ -157,7 +157,7 @@ export type Mutation = { markAsRead: Result rateUser: Result refreshSession: AuthResult - registerUser: User + registerUser: AuthResult removeAuthor: Result sendLink: Result unfollow: Result diff --git a/src/stores/create.ts b/src/stores/create.ts index a60b3664..70610ab3 100644 --- a/src/stores/create.ts +++ b/src/stores/create.ts @@ -1,32 +1,39 @@ -// import { persistentAtom } from '@nanostores/persistent' -// import { Reaction, ReactionKind } from '../graphql/types.gen' -// import { atom, computed } from 'nanostores' -// import { reactionsOrdered } from './zine/reactions' -// -// interface Draft { -// createdAt: Date -// body?: string -// title?: string -// } -// -// interface Collab { -// authors: string[] // slugs -// invites?: string[] -// createdAt: Date -// body?: string -// title?: string -// } -// -// const drafts = persistentAtom('drafts', [], { -// encode: JSON.stringify, -// decode: JSON.parse -// }) // save drafts on device -// const collabs = atom([]) -// // save collabs in backend or in p2p network -// const approvals = computed(reactionsOrdered, (rlist) => rlist.filter((r) => r.kind === ReactionKind.Accept)) -// const proposals = computed(reactionsOrdered, (rlist) => -// rlist.filter((r) => r.kind === ReactionKind.Propose) -// ) -// -// export { drafts, collabs, approvals, proposals } -export {} +import { persistentAtom } from '@nanostores/persistent' +import { Reaction, ReactionKind } from '../graphql/types.gen' +import { atom, computed } from 'nanostores' +import { reactions } from './zine/reactions' + +interface Draft { + createdAt: Date + body?: string + title?: string +} + +interface Collab { + authors: string[] // slugs + invites?: string[] + createdAt: Date + body?: string + title?: string +} + +const drafts = persistentAtom('drafts', [], { + encode: JSON.stringify, + decode: JSON.parse +}) // save drafts on device + +const collabs = atom([]) // save collabs in backend or in p2p network + +/* +const approvals = computed( + reactions, + (rdict) => Object.values(rdict) + .filter((r: Reaction) => r.kind === ReactionKind.Accept) +) +const proposals = computed( + reactions, + (rdict) => Object.values(rdict) + .filter((r: Reaction) => r.kind === ReactionKind.Propose) +) +*/ +export { drafts, collabs /* approvals, proposals */ } diff --git a/src/stores/inbox.ts b/src/stores/inbox.ts index c695c6b0..7223b188 100644 --- a/src/stores/inbox.ts +++ b/src/stores/inbox.ts @@ -1,6 +1,4 @@ -// import { atom } from 'nanostores' -// import type { Chat, Message } from '../graphql/types.gen' -// -// export const chats = atom([]) -// export const messages = atom([]) -export {} +import { atom } from 'nanostores' +import type { ChatResult } from '../graphql/types.gen' + +export const chats = atom([]) diff --git a/src/stores/zine/reactions.ts b/src/stores/zine/reactions.ts index 83ba713f..93018c66 100644 --- a/src/stores/zine/reactions.ts +++ b/src/stores/zine/reactions.ts @@ -7,7 +7,7 @@ import { reduceBy } from '../../utils/reduce' // FIXME let reactionsOrdered: WritableAtom -const reactions = atom<{ [slug: string]: Reaction[] }>({}) // by shout +export const reactions = atom<{ [slug: string]: Reaction[] }>({}) // by shout export const useReactionsStore = (initial?: Reaction[]) => { if (!reactionsOrdered) { diff --git a/src/utils/apiClient.ts b/src/utils/apiClient.ts index abf772a2..c18538b3 100644 --- a/src/utils/apiClient.ts +++ b/src/utils/apiClient.ts @@ -1,15 +1,15 @@ import type { Reaction, Shout, FollowingEntity, AuthResult } from '../graphql/types.gen' +import { getLogger } from './logger' import { publicGraphQLClient } from '../graphql/publicGraphQLClient' +import { privateGraphQLClient } from '../graphql/privateGraphQLClient' import articleBySlug from '../graphql/query/article-by-slug' import articleReactions from '../graphql/query/article-reactions' import articlesRecentAll from '../graphql/query/articles-recent-all' import articlesRecentPublished from '../graphql/query/articles-recent-published' import topicsAll from '../graphql/query/topics-all' -import { getLogger } from './logger' import reactionsForShouts from '../graphql/query/reactions-for-shouts' import mySession from '../graphql/mutation/my-session' -import { privateGraphQLClient } from '../graphql/privateGraphQLClient' import authLogoutQuery from '../graphql/mutation/auth-logout' import authLoginQuery from '../graphql/query/auth-login' import authRegisterMutation from '../graphql/mutation/auth-register' diff --git a/src/utils/logger.ts b/src/utils/logger.ts index 04a169ac..14ce2b34 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -3,10 +3,7 @@ import prefix from 'loglevel-plugin-prefix' import { isDev } from './config' prefix.reg(loglevel) -prefix.apply(loglevel, { - template: '[%n]' -}) - +prefix.apply(loglevel, { template: '[%n]' }) loglevel.setLevel(isDev ? loglevel.levels.TRACE : loglevel.levels.ERROR) export const getLogger = (name: string) => loglevel.getLogger(name) diff --git a/src/utils/ru2en.ts b/src/utils/ru2en.ts index 89900369..c752732c 100644 --- a/src/utils/ru2en.ts +++ b/src/utils/ru2en.ts @@ -56,7 +56,7 @@ const ru2en: { [key: string]: string } = { ь: 'i', Ы: 'Y', ы: 'y', - ъ: "'", + ъ: 'j', Э: 'E', э: 'e', Ю: 'Yu',