2021-08-10 23:35:05 +00:00
|
|
|
import { useAsync } from 'react-use';
|
|
|
|
|
|
|
|
import { onLoginLogout } from '../../account/session';
|
|
|
|
import { getDataDirectory } from '../../common/electron-helpers';
|
|
|
|
import FileSystemDriver from '../../sync/store/drivers/file-system-driver';
|
2021-08-20 15:12:36 +00:00
|
|
|
import { migrateCollectionsIntoRemoteProject } from '../../sync/vcs/migrate-collections';
|
2021-08-10 23:35:05 +00:00
|
|
|
import { VCS } from '../../sync/vcs/vcs';
|
|
|
|
|
|
|
|
const check = async () => {
|
|
|
|
const driver = FileSystemDriver.create(getDataDirectory());
|
2021-08-20 15:12:36 +00:00
|
|
|
await migrateCollectionsIntoRemoteProject(new VCS(driver));
|
2021-08-10 23:35:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Check on login / logout
|
|
|
|
onLoginLogout(isLoggedIn => {
|
|
|
|
if (isLoggedIn) {
|
|
|
|
check();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export const useSyncMigration = () => {
|
|
|
|
// Check once on mount
|
|
|
|
useAsync(check, []);
|
|
|
|
};
|