mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
25 lines
715 B
TypeScript
25 lines
715 B
TypeScript
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';
|
|
import { migrateCollectionsIntoRemoteProject } from '../../sync/vcs/migrate-collections';
|
|
import { VCS } from '../../sync/vcs/vcs';
|
|
|
|
const check = async () => {
|
|
const driver = FileSystemDriver.create(getDataDirectory());
|
|
await migrateCollectionsIntoRemoteProject(new VCS(driver));
|
|
};
|
|
|
|
// Check on login / logout
|
|
onLoginLogout(isLoggedIn => {
|
|
if (isLoggedIn) {
|
|
check();
|
|
}
|
|
});
|
|
|
|
export const useSyncMigration = () => {
|
|
// Check once on mount
|
|
useAsync(check, []);
|
|
};
|