Skip to content

Commit d75dd87

Browse files
committed
create note with selected tags
1 parent 71ae420 commit d75dd87

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

browser/lib/newNote.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ import dataApi from 'browser/main/lib/dataApi'
33
import ee from 'browser/main/lib/eventEmitter'
44
import AwsMobileAnalyticsConfig from 'browser/main/lib/AwsMobileAnalyticsConfig'
55

6-
export function createMarkdownNote (storage, folder, dispatch, location) {
6+
export function createMarkdownNote (storage, folder, dispatch, location, params) {
77
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_MARKDOWN')
88
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
9+
10+
const tags = location.pathname.match(/\/tags/) ? params.tagname.split(' ') : []
11+
912
return dataApi
1013
.createNote(storage, {
1114
type: 'MARKDOWN_NOTE',
1215
folder: folder,
1316
title: '',
17+
tags,
1418
content: ''
1519
})
1620
.then(note => {
@@ -29,14 +33,18 @@ export function createMarkdownNote (storage, folder, dispatch, location) {
2933
})
3034
}
3135

32-
export function createSnippetNote (storage, folder, dispatch, location, config) {
36+
export function createSnippetNote (storage, folder, dispatch, location, params, config) {
3337
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_SNIPPET')
3438
AwsMobileAnalyticsConfig.recordDynamicCustomEvent('ADD_ALLNOTE')
39+
40+
const tags = location.pathname.match(/\/tags/) ? params.tagname.split(' ') : []
41+
3542
return dataApi
3643
.createNote(storage, {
3744
type: 'SNIPPET_NOTE',
3845
folder: folder,
3946
title: '',
47+
tags,
4048
description: '',
4149
snippets: [
4250
{

browser/main/NewNoteButton/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,20 @@ class NewNoteButton extends React.Component {
3535
}
3636

3737
handleNewNoteButtonClick (e) {
38-
const { location, dispatch, config } = this.props
38+
const { location, params, dispatch, config } = this.props
3939
const { storage, folder } = this.resolveTargetFolder()
4040

4141
if (config.ui.defaultNote === 'MARKDOWN_NOTE') {
42-
createMarkdownNote(storage.key, folder.key, dispatch, location)
42+
createMarkdownNote(storage.key, folder.key, dispatch, location, params)
4343
} else if (config.ui.defaultNote === 'SNIPPET_NOTE') {
44-
createSnippetNote(storage.key, folder.key, dispatch, location, config)
44+
createSnippetNote(storage.key, folder.key, dispatch, location, params, config)
4545
} else {
4646
modal.open(NewNoteModal, {
4747
storage: storage.key,
4848
folder: folder.key,
4949
dispatch,
5050
location,
51+
params,
5152
config
5253
})
5354
}

browser/main/modals/NewNoteModal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class NewNoteModal extends React.Component {
2121
}
2222

2323
handleMarkdownNoteButtonClick (e) {
24-
const { storage, folder, dispatch, location } = this.props
25-
createMarkdownNote(storage, folder, dispatch, location).then(() => {
24+
const { storage, folder, dispatch, location, params } = this.props
25+
createMarkdownNote(storage, folder, dispatch, location, params).then(() => {
2626
setTimeout(this.props.close, 200)
2727
})
2828
}
@@ -35,8 +35,8 @@ class NewNoteModal extends React.Component {
3535
}
3636

3737
handleSnippetNoteButtonClick (e) {
38-
const { storage, folder, dispatch, location, config } = this.props
39-
createSnippetNote(storage, folder, dispatch, location, config).then(() => {
38+
const { storage, folder, dispatch, location, params, config } = this.props
39+
createSnippetNote(storage, folder, dispatch, location, params, config).then(() => {
4040
setTimeout(this.props.close, 200)
4141
})
4242
}

0 commit comments

Comments
 (0)