diff --git a/packages/common/package.json b/packages/common/package.json index 2e0a216..9eba430 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -30,6 +30,7 @@ "marked": "^1.1.0", "md5": "^2.2.1", "page-metadata-parser": "^1.1.4", + "uuid": "^8.3.2", "uuidv4": "^6.0.0" } } diff --git a/packages/common/services/storage/BrowserStorage.js b/packages/common/services/storage/BrowserStorage.js index 2c2cf61..210b19e 100644 --- a/packages/common/services/storage/BrowserStorage.js +++ b/packages/common/services/storage/BrowserStorage.js @@ -1,4 +1,4 @@ -import { isUuid } from 'uuidv4'; +import { validate } from 'uuid'; import Storage from './Storage'; import { addNoteToList, addTagToList } from '../../utils'; @@ -11,7 +11,7 @@ export default class BrowserStorage extends Storage { _getPages() { return this.storage.get().then(pages => { return Object.keys(pages) - .filter(key => isUuid(key)) + .filter(key => validate(key)) .map(key => pages[key]); }); } diff --git a/packages/common/store/page.js b/packages/common/store/page.js index 6c87e96..bd02d98 100644 --- a/packages/common/store/page.js +++ b/packages/common/store/page.js @@ -1,8 +1,9 @@ import { action, thunk } from 'easy-peasy'; import { getMetadata } from 'page-metadata-parser'; -import { fromString } from 'uuidv4'; +import { v5 } from 'uuid'; import { storage as StorageService } from '../services'; import { generatePageId, addTagToList, addNoteToList } from '../utils'; +import uuidNamespace from '../utils/uuid-namespace'; export const defaultPage = { id: '', @@ -45,7 +46,7 @@ const pageModel = { }), saveNote: thunk(async (actions, note, { getState, getStoreState }) => { const { url } = getStoreState().app; - const id = note.id || fromString(note.content + note.timestamp); + const id = note.id || v5(note.content + note.timestamp, uuidNamespace); let { data: page } = getState(); if (!page.id) { diff --git a/packages/common/utils/generatePageId.js b/packages/common/utils/generatePageId.js index c0e8ef4..a8a47a0 100644 --- a/packages/common/utils/generatePageId.js +++ b/packages/common/utils/generatePageId.js @@ -1,7 +1,8 @@ -import { fromString } from 'uuidv4'; +import { v5 } from 'uuid'; import compose from 'compose-function'; import videoUrlParser from 'js-video-url-parser'; import { PROVIDER_YOUTUBE } from '../constants'; +import uuidNamespace from './uuid-namespace'; const getUrlWithoutHash = url => { const parsedUrl = new URL(url); @@ -20,8 +21,8 @@ export default url => { getUrlWithoutHash )(url); if (provider === PROVIDER_YOUTUBE) { - return fromString(`${provider}-${id}`); + return v5(`${provider}-${id}`, uuidNamespace); } - return fromString(urlWithoutHash); + return v5(urlWithoutHash, uuidNamespace); }; diff --git a/packages/common/utils/uuid-namespace.js b/packages/common/utils/uuid-namespace.js new file mode 100644 index 0000000..32f047f --- /dev/null +++ b/packages/common/utils/uuid-namespace.js @@ -0,0 +1 @@ +export default 'e1433c8f-bc34-431d-99b1-2a78abdd7f35'; diff --git a/packages/extension/src/options/containers/Page/Toolbar/index.js b/packages/extension/src/options/containers/Page/Toolbar/index.js index 12dc933..c3f0271 100644 --- a/packages/extension/src/options/containers/Page/Toolbar/index.js +++ b/packages/extension/src/options/containers/Page/Toolbar/index.js @@ -98,7 +98,13 @@ const Toolbar = () => { const handleExportMarkdown = () => { const data = MarkdownService.pagesToMarkdown([{ meta, notes }]); - return FileService.exportMarkdownFile(data, `yinote_${meta.title}.md`); + + // Removing notifications count and " - Youtube" at the end + const fileName = 'yinote_' + meta.title + .replace(/^\(.*\) /g, '') + .replace(/ - YouTube$/g, ''); + + return FileService.exportMarkdownFile(data, `${fileName}.md`); }; const handleOpenPage = () => { diff --git a/packages/extension/src/ui/containers/App/index.js b/packages/extension/src/ui/containers/App/index.js index 441fae7..92f44d4 100644 --- a/packages/extension/src/ui/containers/App/index.js +++ b/packages/extension/src/ui/containers/App/index.js @@ -118,7 +118,13 @@ const App = () => { }, [getPlayer, history, open, pathname]); return ( - +
diff --git a/yarn.lock b/yarn.lock index b28075e..9b2371c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16679,7 +16679,7 @@ uuid@3.4.0, uuid@^3.0.0, uuid@^3.0.1, uuid@^3.3.2, uuid@^3.4.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== -uuid@8.3.2: +uuid@8.3.2, uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==