-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ feat: support Liveblocks sync #2611
base: main
Are you sure you want to change the base?
Conversation
@CloudPassenger is attempting to deploy a commit to the LobeHub Team on Vercel. A member of the Team first needs to authorize it. |
Thank you for raising your pull request and contributing to our Community |
Amazing Work! plz rebase main branch~ 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a common method , move it to the uilts folder?
src/config/featureFlags/index.ts
Outdated
@@ -22,6 +23,7 @@ export const FeatureFlagsSchema = z.object({ | |||
export type IFeatureFlags = z.infer<typeof FeatureFlagsSchema>; | |||
|
|||
export const DEFAULT_FEATURE_FLAGS: IFeatureFlags = { | |||
liveblocks_sync: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can be false by default, and enable it by add +liveblocks_sync
src/database/client/core/sync.ts
Outdated
// ====== 2. init webrtc provider ====== // | ||
this.logger(`[WebRTC] init provider... room: ${channel.name}`); | ||
const { WebrtcProvider } = await import('y-webrtc'); | ||
if (channel.webrtc.enabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there can be two methods: connectWithWebRTC
and connectWithLiveBlocks
,
move the implement into these method and make the connect
as entry.
const { t } = useTranslation('common'); | ||
const [haveConfig, setSettings] = useUserStore((s) => [ | ||
!!syncSettingsSelectors.webrtcConfig(s).channelName, | ||
!!channelSyncConfig(method)(s), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make channelSyncConfig
as a selector
a565917
to
28b7d21
Compare
28b7d21
to
b02ef0f
Compare
非常需要一个稳定的同步功能,希望早日上线👍 |
We really need a stable synchronization function and hope it will be online soon👍 |
Sorry, I've been very busy these days so my progress has slowed down, I'll try to keep on top of this pull request and make changes, I'm really sorry. :( |
Take you time, it not hurry for it~ |
b02ef0f
to
b64ff78
Compare
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
This pull request introduces a new feature that improves data synchronisation in LobeChat by integrating the real-time online service provided by Liveblocks.
While the existing WebRTC solution provides a highly encrypted environment, it requires devices to be online at the same time and fails to synchronise data when P2P connections are unstable. By using servers hosted by Liveblocks, we can significantly improve the performance and reliability of data synchronisation.
During deployment, setting the
LIVEBLOCKS_SECRET_KEY
allows the use of the Liveblocks instance configured on the server. Users can also use their public key to connect to their own storage instance, providing a balance between convenience and security.If login authentication is enabled in LobeChat, the user identifier is used as the sync room name by default, seamlessly integrating user authentication and data synchronisation.
Currently, the implementation has passed testing and can achieve bi-directional synchronisation between WebRTC P2P and the Liveblocks server. A demo video is attached:
Lobechat.-.WebRTC.Liveblocks.Sync.mp4
📝 补充信息 | Additional Information
This is a demo version that only integrates the new sync features. In a later update I will update more UI components like the
<SyncStatusInspector />
to make Liveblocks synchronisation compatible.