From a076586dcf0c21fcf385b388b4cebe7f1dc7a287 Mon Sep 17 00:00:00 2001 From: Shuo Wu Date: Fri, 10 Jul 2020 19:09:20 -0400 Subject: [PATCH] fix: import data for version above 1.0.0 fixes #49 --- package-lock.json | 5 +++++ packages/extension/package.json | 3 ++- .../src/options/containers/Settings/ExportAndImport/index.js | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index a6041a7..8f17e79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15786,6 +15786,11 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" }, + "semver-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=" + }, "semver-diff": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-3.1.1.tgz", diff --git a/packages/extension/package.json b/packages/extension/package.json index 73cf977..5c6b448 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -36,13 +36,14 @@ "js-logger": "^1.6.0", "js-video-url-parser": "^0.4.0", "markerjs": "^1.8.1", + "prop-types": "^15.7.2", "react": "^16.13.1", "react-dom": "^16.13.1", "react-highlighter": "^0.4.3", "react-i18next": "^11.2.6", "react-recipes": "^1.0.0", "react-router-dom": "^5.1.2", - "prop-types": "^15.7.2", + "semver-compare": "^1.0.0", "styled-components": "^5.0.0-rc.2", "throttle-debounce": "^2.1.0", "uuidv4": "^6.0.0" diff --git a/packages/extension/src/options/containers/Settings/ExportAndImport/index.js b/packages/extension/src/options/containers/Settings/ExportAndImport/index.js index b4bfedd..58f93fe 100644 --- a/packages/extension/src/options/containers/Settings/ExportAndImport/index.js +++ b/packages/extension/src/options/containers/Settings/ExportAndImport/index.js @@ -2,6 +2,7 @@ import React from 'react'; import styled from 'styled-components'; import { useStoreActions } from 'easy-peasy'; import { useTranslation } from 'react-i18next'; +import cmp from 'semver-compare'; import { Grid, Typography, Button, Divider } from '@material-ui/core'; import { storage as StorageService, @@ -31,7 +32,7 @@ const ExportAndImport = () => { const handleImportFile = e => { FileService.readAsJson(e.target.files[0]) .then(({ version, data }) => { - if (version !== '1.0.0') { + if (cmp(version, '1.0.0') === -1) { throw new Error(t('settings.import.version.error')); } return importData(data);