-
Notifications
You must be signed in to change notification settings - Fork 59k
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
[Cloud Sync] #2854
base: main
Are you sure you want to change the base?
[Cloud Sync] #2854
Conversation
[+] Add support for GithubGist synchronization in useSyncStore - Updated the `WebDavConfig` interface to include the `filename` property. - Added the `GistConfig` interface to define the filename, gistId, and token for GitHub Gist synchronization. - Modified the `createPersistStore` function in the `useSyncStore` module to include the `githubGist` and `upstash` properties in the initial state, with empty values for their respective properties. - Added the `lastUpdateTime` and `syncing` properties to the initial state to track the last update time and synchronization status. - Updated the `sync` method to handle the synchronization logic for WebDAV, including merging the remote state, updating the local state, and overwriting access control settings if specified. - Implemented the `markUpdateTime` method to update the last update time when performing synchronization. - Added the `countSync` method to check if all required configuration values for the selected provider are filled. - Modified the `export` method to generate a backup file name based on the current date and time. - Updated the `import` method to handle importing JSON files split into multiple chunks. - Updated the `sync` method to handle merging filtered topics and updating masks. - Added the necessary dependencies and ensured that the `createSyncClient` function in the `cloud` module accepts the required arguments for setting up the data. These changes extend the `useSyncStore` module to support synchronization with WebDAV in addition to GitHub Gist and Upstash. The module now provides methods to sync, export, import, and check synchronization state with the selected provider. The code also includes improvements for handling synchronization and merging state, as well as managing access control settings. [+] Fix locale language inconsistencies in `useSyncStore` - Updated the text strings in the `useSyncStore` module to ensure consistent and accurate locale language usage throughout the codebase.
- Fix 'client.set is not a function' error and update 'set' method to handle different value types - Introduce separate synchronization methods for WebDAV and GitHub Gist providers - Implement provider-specific synchronization logic in the 'sync' method - Update 'syncWebDAV' to correctly set data using 'client.set' with 'filename' and 'JSON.stringify(localState)' - Update 'syncGitHubGist' to properly set data using 'client.set' with 'localState' and 'value - Enhance 'set' method in 'SyncClient' to accept both 'Object' and 'string' as 'value' parameters - Ensure correct passing of 'localState' and 'value' in 'syncGitHubGist' method for GitHub Gist synchronization
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.
Github Gist ✅
- Enhance 'set' method in 'SyncClient' to accept both 'Object' and 'string' as 'value' parameters
[+] Update `check` method to use `PROPFIND` instead of `MKCOL` In the `webdav.ts` module, updated the `check` method to use the `PROPFIND` method instead of `MKCOL` to check if the file exists. This change was made to handle cases where the server does not allow the `MKCOL` method. The `PROPFIND` method is used to retrieve the properties of the file, and if the response status is either 200 (OK), 207 (Multi-Status), or 404 (Not Found), it considers the file to exist.
- fix(settings): remove unnecessary code for syncing with GitHub Gist provider - fix(sync): change console.error to console.log for failed remote state retrieval from file - fix(gist): simplify logic for checking if Gist exists or not
[+] feat(gist.ts): implement content chunking for gist creation
[+] fix(sync.ts): swap merge order in mergeWithUpdate function
[+] feat(route.ts): change runtime from nodejs to edge [+] refactor(sync.ts): extract default sync state to a constant [+] fix(sync.ts): correct accessControl properties assignment [+] feat(sync.ts): add migration function for version 1.1 to update upstash username
[+] fix(route.ts): set CORS headers for preflight requests in handle function [+] feat(route.ts): add support for Access-Control-Allow-Origin, Access-Control-Allow-Methods, Access-Control-Allow-Headers, and Access-Control-Max-Age headers in preflight requests
[+] feat(format.ts): add function to split a string into chunks based on byte size
[+] fix(gist.ts): fix indentation and remove unnecessary comments [+] chore(gist.ts): update console.log messages for better readability [+] fix(webdav.ts): update console.log messages for better readability
[+] refactor(settings.tsx): remove unnecessary code and reorganize CheckButton component logic
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.
Look great to me.
@@ -150,7 +150,7 @@ export function mergeWithUpdate<T extends { lastUpdateTime?: number }>( | |||
remoteState: T, | |||
) { | |||
const localUpdateTime = localState.lastUpdateTime ?? 0; | |||
const remoteUpdateTime = localState.lastUpdateTime ?? 1; | |||
const remoteUpdateTime = remoteState.lastUpdateTime ?? 1; |
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.
}, | ||
|
||
export() { | ||
const state = getLocalAppState(); | ||
const fileName = `Backup-${new Date().toLocaleString()}.json`; | ||
downloadAs(JSON.stringify(state), fileName); | ||
const fileName = `Backup-${new Date().toLocaleString()}`; |
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.
Is this change necessary? Can we just keep downloadAs
receive string?
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.
Is this change necessary? Can we just keep
downloadAs
receive string?
that branch are outdated
a better one already implemented here:
export() {
const state = getLocalAppState();
const datePart = isApp
? `${new Date().toLocaleDateString().replace(/\//g, '_')} ${new Date().toLocaleTimeString().replace(/:/g, '_')}`
: new Date().toLocaleString();
const fileName = `Backup-${datePart}.json`;
downloadAs((state), fileName);
},
Is this PR outdated? Is there a new PR to fix the current cloud sync behavior? To be honest, the current cloud sync is quite poor. |
[+] Add support for GithubGist synchronization in useSyncStore
WebDavConfig
interface to include thefilename
property.GistConfig
interface to define the filename, gistId, and token for GitHub Gist synchronization.createPersistStore
function in theuseSyncStore
module to include thegithubGist
andupstash
properties in the initial state, with empty values for their respective properties.lastUpdateTime
andsyncing
properties to the initial state to track the last update time and synchronization status.sync
method to handle the synchronization logic for WebDAV, including merging the remote state, updating the local state, and overwriting access control settings if specified.markUpdateTime
method to update the last update time when performing synchronization.countSync
method to check if all required configuration values for the selected provider are filled.export
method to generate a backup file name based on the current date and time.import
method to handle importing JSON files split into multiple chunks.sync
method to handle merging filtered topics and updating masks.createSyncClient
function in thecloud
module accepts the required arguments for setting up the data.These changes extend the
useSyncStore
module to support synchronization with WebDAV in addition to GitHub Gist and Upstash. The module now provides methods to sync, export, import, and check synchronization state with the selected provider. The code also includes improvements for handling synchronization and merging state, as well as managing access control settings.[+] Fix locale language inconsistencies in
useSyncStore
useSyncStore
module to ensure consistent and accurate locale language usage throughout the codebase.