mirror of
https://github.com/penxio/penx.git
synced 2026-04-19 03:03:06 -04:00
fix: fix sync penx 101 cloud
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useEffect } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { RouterOutputs } from '@penx/api'
|
||||
import { PENX_101, PENX_101_CLOUD_NAME } from '@penx/constants'
|
||||
import { db } from '@penx/local-db'
|
||||
import { Node } from '@penx/model'
|
||||
import { INode, ISpace } from '@penx/model-types'
|
||||
@@ -25,6 +26,13 @@ export const QueryCloudSpaces = () => {
|
||||
isCloud: true,
|
||||
} as any as ISpace)
|
||||
|
||||
// TODO: this is hard code
|
||||
if (newSpace.name === PENX_101_CLOUD_NAME) {
|
||||
await db.deleteSpace(PENX_101)
|
||||
const spaces = await db.listSpaces()
|
||||
store.space.setSpaces(spaces)
|
||||
}
|
||||
|
||||
// only create nodes if the space is not encrypted
|
||||
if (!space.encrypted) {
|
||||
const nodes = await trpc.node.listBySpaceId.query({ spaceId: space.id })
|
||||
|
||||
@@ -10,6 +10,8 @@ export const SpacePopoverTrigger = forwardRef<HTMLDivElement, {}>(
|
||||
const { activeSpace } = useSpaces()
|
||||
const { close } = usePopoverContext()
|
||||
|
||||
if (!activeSpace) return null
|
||||
|
||||
return (
|
||||
<PopoverTrigger asChild>
|
||||
<Box
|
||||
@@ -33,7 +35,7 @@ export const SpacePopoverTrigger = forwardRef<HTMLDivElement, {}>(
|
||||
<Bullet
|
||||
size={20}
|
||||
innerSize={6}
|
||||
innerColor={activeSpace.color}
|
||||
innerColor={activeSpace?.color}
|
||||
mr1
|
||||
/>
|
||||
<Box flex-1 maxW-180>
|
||||
|
||||
@@ -23,6 +23,8 @@ export const Workbench = () => {
|
||||
|
||||
// console.log('router name==========:', name)
|
||||
|
||||
if (!activeSpace) return null
|
||||
|
||||
return (
|
||||
<EditorProvider space={activeSpace}>
|
||||
{session && <QueryCloudSpaces />}
|
||||
|
||||
@@ -10,6 +10,8 @@ export const PENX_SESSION_USER = 'PENX_SESSION_USER'
|
||||
|
||||
export const PENX_101 = 'penx-101'
|
||||
|
||||
export const PENX_101_CLOUD_NAME = 'penx-101-cloud'
|
||||
|
||||
export const PLATFORM =
|
||||
process.env.NEXT_PUBLIC_PLATFORM || process.env.PLASMO_PUBLIC_PLATFORM
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ export class AppService {
|
||||
if (nodes.length) {
|
||||
const todayNode = await db.getTodayNode(activeSpace.id)
|
||||
|
||||
// if (!todayNode) {
|
||||
// await this.createAndGoToTodayNode(activeSpace.id)
|
||||
// store.app.setAppLoading(false)
|
||||
// return
|
||||
// }
|
||||
if (!todayNode) {
|
||||
await this.createAndGoToTodayNode(activeSpace.id)
|
||||
store.app.setAppLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
let activeNodes = activeSpace.activeNodeIds
|
||||
.map((id) => {
|
||||
|
||||
@@ -66,7 +66,7 @@ export class SpaceStore {
|
||||
const nodes = await db.listNodesBySpaceId(id)
|
||||
const space = await db.getActiveSpace()
|
||||
|
||||
this.store.space.setSpaces([])
|
||||
// this.store.space.setSpaces([])
|
||||
this.store.node.setNodes([])
|
||||
this.store.node.setActiveNodes([])
|
||||
|
||||
@@ -95,11 +95,11 @@ export class SpaceStore {
|
||||
} else {
|
||||
this.setSpaces(spaces)
|
||||
this.store.node.setNodes(nodes)
|
||||
this.store.node.setActiveNodes(activeNodes)
|
||||
this.store.node.selectNode(activeNodes[0])
|
||||
}
|
||||
|
||||
this.store.app.setAppLoading(false)
|
||||
}
|
||||
|
||||
this.store.app.setAppLoading(false)
|
||||
return space
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user