some fixes
This commit is contained in:
parent
09098ff307
commit
d0970c9342
|
@ -9,10 +9,6 @@ export const isMac = true
|
||||||
export const mod = isMac ? 'Cmd' : 'Ctrl'
|
export const mod = isMac ? 'Cmd' : 'Ctrl'
|
||||||
export const alt = isMac ? 'Cmd' : 'Alt'
|
export const alt = isMac ? 'Cmd' : 'Alt'
|
||||||
|
|
||||||
export const WEB_URL =
|
|
||||||
//'http://localhost:3000'
|
|
||||||
'https://discoursio-editor-app.vercel.app'
|
|
||||||
|
|
||||||
export interface Args {
|
export interface Args {
|
||||||
cwd?: string
|
cwd?: string
|
||||||
file?: string
|
file?: string
|
||||||
|
|
|
@ -3,10 +3,7 @@ import { v4 as uuidv4 } from 'uuid'
|
||||||
import type { EditorState } from 'prosemirror-state'
|
import type { EditorState } from 'prosemirror-state'
|
||||||
import { undo, redo } from 'prosemirror-history'
|
import { undo, redo } from 'prosemirror-history'
|
||||||
import { selectAll, deleteSelection } from 'prosemirror-commands'
|
import { selectAll, deleteSelection } from 'prosemirror-commands'
|
||||||
import * as Y from 'yjs'
|
|
||||||
import { undo as yUndo, redo as yRedo } from 'y-prosemirror'
|
import { undo as yUndo, redo as yRedo } from 'y-prosemirror'
|
||||||
import { WebrtcProvider } from 'y-webrtc'
|
|
||||||
import { uniqueNamesGenerator, adjectives, animals } from 'unique-names-generator'
|
|
||||||
import { debounce } from 'ts-debounce'
|
import { debounce } from 'ts-debounce'
|
||||||
// import * as remote from '../prosemirror/remote'
|
// import * as remote from '../prosemirror/remote'
|
||||||
import { createSchema, createExtensions, createEmptyText } from '../prosemirror/setup'
|
import { createSchema, createExtensions, createEmptyText } from '../prosemirror/setup'
|
||||||
|
@ -14,8 +11,8 @@ import { State, File, Config, ServiceError, newState } from '.'
|
||||||
// import { isTauri, mod } from '../env'
|
// import { isTauri, mod } from '../env'
|
||||||
import { serialize, createMarkdownParser } from '../prosemirror/markdown'
|
import { serialize, createMarkdownParser } from '../prosemirror/markdown'
|
||||||
import { isEmpty, isInitialized } from '../prosemirror/state'
|
import { isEmpty, isInitialized } from '../prosemirror/state'
|
||||||
import { Awareness } from 'y-protocols/awareness'
|
|
||||||
import { isServer } from 'solid-js/web'
|
import { isServer } from 'solid-js/web'
|
||||||
|
import { roomConnect } from '../../../utils/p2p'
|
||||||
|
|
||||||
const mod = 'Ctrl'
|
const mod = 'Ctrl'
|
||||||
const isTauri = false
|
const isTauri = false
|
||||||
|
@ -445,34 +442,7 @@ export const createCtrl = (initial: State): [Store<State>, any] => {
|
||||||
const backup = state.args?.room && state.collab?.room !== state.args.room
|
const backup = state.args?.room && state.collab?.room !== state.args.room
|
||||||
const room = state.args?.room ?? uuidv4()
|
const room = state.args?.room ?? uuidv4()
|
||||||
|
|
||||||
window.history.replaceState(null, '', `/${room}`)
|
const [type, provider] = roomConnect(room)
|
||||||
|
|
||||||
const ydoc = new Y.Doc()
|
|
||||||
const type = ydoc.getXmlFragment('prosemirror')
|
|
||||||
const webrtcOptions = {
|
|
||||||
awareness: new Awareness(ydoc),
|
|
||||||
filterBcConns: true,
|
|
||||||
maxConns: 33,
|
|
||||||
signaling: [
|
|
||||||
// 'wss://signaling.discours.io',
|
|
||||||
// 'wss://stun.l.google.com:19302',
|
|
||||||
'wss://y-webrtc-signaling-eu.herokuapp.com',
|
|
||||||
'wss://signaling.yjs.dev'
|
|
||||||
],
|
|
||||||
peerOpts: {},
|
|
||||||
password: ''
|
|
||||||
}
|
|
||||||
const provider = new WebrtcProvider(room, ydoc, webrtcOptions)
|
|
||||||
const username = uniqueNamesGenerator({
|
|
||||||
dictionaries: [adjectives, animals],
|
|
||||||
style: 'capital',
|
|
||||||
separator: ' ',
|
|
||||||
length: 2
|
|
||||||
})
|
|
||||||
|
|
||||||
provider.awareness.setLocalStateField('user', {
|
|
||||||
name: username
|
|
||||||
})
|
|
||||||
|
|
||||||
const extensions = createExtensions({
|
const extensions = createExtensions({
|
||||||
config: state.config,
|
config: state.config,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { createEffect, createSignal, Show, Suspense } from 'solid-js'
|
import { createEffect, createSignal, Show, Suspense } from 'solid-js'
|
||||||
import { FullArticle } from '../Article/FullArticle'
|
import { FullArticle } from '../Article/FullArticle'
|
||||||
import { t } from '../../utils/intl'
|
import { t } from '../../utils/intl'
|
||||||
|
|
||||||
import type { Shout } from '../../graphql/types.gen'
|
import type { Shout } from '../../graphql/types.gen'
|
||||||
import { loadArticleReactions, useReactionsStore } from '../../stores/zine/reactions'
|
import { loadArticleReactions, useReactionsStore } from '../../stores/zine/reactions'
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ export const HomeView = (props: HomeProps) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Show when={locale()}>
|
<Show when={locale() && getSortedArticles().at(0) !== undefined}>
|
||||||
<NavTopics topics={getRandomTopics()} />
|
<NavTopics topics={getRandomTopics()} />
|
||||||
|
|
||||||
<Row5 articles={getSortedArticles().slice(0, 5)} />
|
<Row5 articles={getSortedArticles().slice(0, 5)} />
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { gql } from '@urql/core'
|
import { gql } from '@urql/core'
|
||||||
|
|
||||||
export default gql`
|
export default gql`
|
||||||
query AuthorssAllQuery($limit: Int!, $offset: Int!) {
|
query AuthorsAllQuery {
|
||||||
authorsAll(limit: $limit, offset: $offset) {
|
authorsAll {
|
||||||
_id: slug
|
_id: slug
|
||||||
slug
|
slug
|
||||||
name
|
name
|
||||||
|
|
|
@ -3,7 +3,7 @@ import type { Reaction } from '../../graphql/types.gen'
|
||||||
import { useStore } from '@nanostores/solid'
|
import { useStore } from '@nanostores/solid'
|
||||||
import { apiClient } from '../../utils/apiClient'
|
import { apiClient } from '../../utils/apiClient'
|
||||||
import { reduceBy } from '../../utils/reduce'
|
import { reduceBy } from '../../utils/reduce'
|
||||||
|
// import { roomConnect } from '../../utils/p2p'
|
||||||
// FIXME
|
// FIXME
|
||||||
|
|
||||||
let reactionsOrdered: WritableAtom<Reaction[]>
|
let reactionsOrdered: WritableAtom<Reaction[]>
|
||||||
|
@ -26,8 +26,9 @@ export const loadArticleReactions = async ({
|
||||||
limit?: number
|
limit?: number
|
||||||
offset?: number
|
offset?: number
|
||||||
}): Promise<void> => {
|
}): Promise<void> => {
|
||||||
const resp = await apiClient.getArticleReactions({ articleSlug, limit, offset })
|
const data = await apiClient.getArticleReactions({ articleSlug, limit, offset })
|
||||||
reactionsOrdered.set(resp)
|
// TODO: const [data, provider] = roomConnect(articleSlug)
|
||||||
|
reactionsOrdered.set(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadReactions = async ({
|
export const loadReactions = async ({
|
||||||
|
|
36
src/utils/p2p.ts
Normal file
36
src/utils/p2p.ts
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import { uniqueNamesGenerator, adjectives, animals } from 'unique-names-generator'
|
||||||
|
import { Awareness } from 'y-protocols/awareness'
|
||||||
|
import { WebrtcProvider } from 'y-webrtc'
|
||||||
|
import * as Y from 'yjs'
|
||||||
|
import type { Reaction } from '../graphql/types.gen'
|
||||||
|
|
||||||
|
export const roomConnect = (room, keyname = 'reactions'): [Reaction[], WebrtcProvider] => {
|
||||||
|
const ydoc = new Y.Doc()
|
||||||
|
const yarray = ydoc.getArray(keyname)
|
||||||
|
const webrtcOptions = {
|
||||||
|
awareness: new Awareness(ydoc),
|
||||||
|
filterBcConns: true,
|
||||||
|
maxConns: 33,
|
||||||
|
signaling: [
|
||||||
|
// 'wss://signaling.discours.io',
|
||||||
|
// 'wss://stun.l.google.com:19302',
|
||||||
|
'wss://y-webrtc-signaling-eu.herokuapp.com',
|
||||||
|
'wss://signaling.yjs.dev'
|
||||||
|
],
|
||||||
|
peerOpts: {},
|
||||||
|
password: ''
|
||||||
|
}
|
||||||
|
const provider = new WebrtcProvider(room, ydoc, webrtcOptions)
|
||||||
|
const username = uniqueNamesGenerator({
|
||||||
|
dictionaries: [adjectives, animals],
|
||||||
|
style: 'capital',
|
||||||
|
separator: ' ',
|
||||||
|
length: 2
|
||||||
|
})
|
||||||
|
|
||||||
|
provider.awareness.setLocalStateField('user', {
|
||||||
|
name: username
|
||||||
|
})
|
||||||
|
const data = yarray.toArray() as Reaction[]
|
||||||
|
return [data, provider]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user