mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: extra indexed db update on mount (reload) causing repeated popups of unsaved changes (#4808)
* docs: update self-host guide link in README (#4704) found via: - https://github.com/makeplane/docs/issues/48 - https://github.com/makeplane/plane/pull/3109 * fix: extra indexed db update on mount causing repeated popups on unload * revert: old stuff --------- Co-authored-by: jon ⚝ <jon@allmende.io>
This commit is contained in:
parent
c5b1d95c76
commit
71c77d30a0
@ -48,7 +48,7 @@ Meet [Plane](https://dub.sh/plane-website-readme), an open-source project manage
|
|||||||
|
|
||||||
The easiest way to get started with Plane is by creating a [Plane Cloud](https://app.plane.so) account.
|
The easiest way to get started with Plane is by creating a [Plane Cloud](https://app.plane.so) account.
|
||||||
|
|
||||||
If you would like to self-host Plane, please see our [deployment guide](https://docs.plane.so/self-hosting/overview).
|
If you would like to self-host Plane, please see our [deployment guide](https://docs.plane.so/docker-compose).
|
||||||
|
|
||||||
| Installation methods | Docs link |
|
| Installation methods | Docs link |
|
||||||
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
|
@ -59,6 +59,9 @@ export const useDocumentEditor = ({
|
|||||||
// indexedDB provider
|
// indexedDB provider
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const localProvider = new IndexeddbPersistence(id, provider.document);
|
const localProvider = new IndexeddbPersistence(id, provider.document);
|
||||||
|
localProvider.on("synced", () => {
|
||||||
|
provider.setHasIndexedDBSynced(true);
|
||||||
|
});
|
||||||
return () => {
|
return () => {
|
||||||
localProvider?.destroy();
|
localProvider?.destroy();
|
||||||
};
|
};
|
||||||
|
@ -13,6 +13,10 @@ export interface CompleteCollaboratorProviderConfiguration {
|
|||||||
* onChange callback
|
* onChange callback
|
||||||
*/
|
*/
|
||||||
onChange: (updates: Uint8Array) => void;
|
onChange: (updates: Uint8Array) => void;
|
||||||
|
/**
|
||||||
|
* Whether connection to the database has been established and all available content has been loaded or not.
|
||||||
|
*/
|
||||||
|
hasIndexedDBSynced: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CollaborationProviderConfiguration = Required<Pick<CompleteCollaboratorProviderConfiguration, "name">> &
|
export type CollaborationProviderConfiguration = Required<Pick<CompleteCollaboratorProviderConfiguration, "name">> &
|
||||||
@ -24,6 +28,7 @@ export class CollaborationProvider {
|
|||||||
// @ts-expect-error cannot be undefined
|
// @ts-expect-error cannot be undefined
|
||||||
document: undefined,
|
document: undefined,
|
||||||
onChange: () => {},
|
onChange: () => {},
|
||||||
|
hasIndexedDBSynced: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(configuration: CollaborationProviderConfiguration) {
|
constructor(configuration: CollaborationProviderConfiguration) {
|
||||||
@ -45,7 +50,12 @@ export class CollaborationProvider {
|
|||||||
return this.configuration.document;
|
return this.configuration.document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setHasIndexedDBSynced(hasIndexedDBSynced: boolean) {
|
||||||
|
this.configuration.hasIndexedDBSynced = hasIndexedDBSynced;
|
||||||
|
}
|
||||||
|
|
||||||
documentUpdateHandler(update: Uint8Array, origin: any) {
|
documentUpdateHandler(update: Uint8Array, origin: any) {
|
||||||
|
if (!this.configuration.hasIndexedDBSynced) return;
|
||||||
// return if the update is from the provider itself
|
// return if the update is from the provider itself
|
||||||
if (origin === this) return;
|
if (origin === this) return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user