Skip to content
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

Improvements #124

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
4 changes: 2 additions & 2 deletions packages/common/services/storage/BrowserStorage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isUuid } from 'uuidv4';
import { validate } from 'uuid';
import Storage from './Storage';
import { addNoteToList, addTagToList } from '../../utils';

Expand All @@ -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]);
});
}
Expand Down
5 changes: 3 additions & 2 deletions packages/common/store/page.js
Original file line number Diff line number Diff line change
@@ -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: '',
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 4 additions & 3 deletions packages/common/utils/generatePageId.js
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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);
};
1 change: 1 addition & 0 deletions packages/common/utils/uuid-namespace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'e1433c8f-bc34-431d-99b1-2a78abdd7f35';
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
8 changes: 7 additions & 1 deletion packages/extension/src/ui/containers/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ const App = () => {
}, [getPlayer, history, open, pathname]);

return (
<StyledDrawer open={open} className={open && 'panel-shadow'}>
<StyledDrawer
// fixes toggling the drawer open and closed.
// For some reason passing `open` doesn't update the component's styles
style={{ transform: open ? 'translateX(0)' : 'translateX(100%)' }}
open={open}
className={open && 'panel-shadow'}
>
<Grid container>
<Header />
<StyledViewWrapper>
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16679,7 +16679,7 @@ [email protected], 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==

[email protected]:
[email protected], 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==
Expand Down