This repository was archived by the owner on Feb 21, 2020. It is now read-only.
File tree 3 files changed +27
-7
lines changed
3 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -252,7 +252,8 @@ export default class App extends Component {
252
252
fileName : fileName ,
253
253
content : content === '' ? 'Tap here and write something!' : content . split ( / \r \n | \r | \n / ) [ 0 ] ,
254
254
createdAt : filteredSettingFile . createdAt ,
255
- isStarred : filteredSettingFile . isStarred
255
+ isStarred : filteredSettingFile . isStarred ,
256
+ updatedAt : filteredSettingFile . updatedAt ,
256
257
} )
257
258
}
258
259
fileList . sort ( ( a , b ) => {
@@ -301,7 +302,6 @@ export default class App extends Component {
301
302
'updatedAt' : date
302
303
}
303
304
contentObject . note . push ( thisNote )
304
- console . table ( contentObject . note )
305
305
fs . writeFile ( `${ dirs . DocumentDir } /Boostnote/boostnote.json` , JSON . stringify ( contentObject ) , 'utf8' )
306
306
. catch ( err => console . log ( err ) )
307
307
AwsMobileAnalyticsConfig . recordDynamicCustomEvent ( 'CREATE_NOTE' )
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ const styles = {
65
65
flexDirection : 'row' ,
66
66
justifyContent : 'flex-start' ,
67
67
alignItems : 'center' ,
68
- flex : 2
68
+ flex : 3
69
69
} ,
70
70
noteItemSectionRight : {
71
71
flex : 1 ,
@@ -98,16 +98,16 @@ class NoteListItem extends Component {
98
98
99
99
render ( ) {
100
100
const { note } = this . props || { }
101
- const { content, createdAt, isStarred } = note || { }
101
+ const { content, createdAt, isStarred, updatedAt } = note || { }
102
102
return (
103
103
< TouchableOpacity
104
104
style = { styles . noteList }
105
105
onPress = { this . onNotePress } >
106
106
< View style = { styles . noteItemSectionLeft } >
107
- < Text style = { content !== 'Tap here and write something!' ? styles . noteListText : styles . noteListTextNone } > { removeMd ( content ) } </ Text >
107
+ < Text numberOfLines = { 2 } ellipsizeMode = "tail" style = { content !== 'Tap here and write something!' ? styles . noteListText : styles . noteListTextNone } > { removeMd ( content ) } </ Text >
108
108
</ View >
109
109
< View style = { styles . noteItemSectionRight } >
110
- < Text style = { styles . noteListDate } > { moment ( createdAt ) . format ( 'MMM D' ) } </ Text >
110
+ < Text style = { styles . noteListDate } > { moment ( updatedAt ) . format ( 'MMM D' ) + '\n' + moment ( createdAt ) . format ( 'MMM D' ) } </ Text >
111
111
< TouchableOpacity onPress = { this . onStarPress } >
112
112
< Icon name = { isStarred ? 'md-star' : 'md-star-outline' } style = { styles . noteStarIcon } />
113
113
</ TouchableOpacity >
Original file line number Diff line number Diff line change @@ -52,12 +52,32 @@ export default class NoteModal extends React.Component {
52
52
} )
53
53
}
54
54
55
- onChangeText ( text ) {
55
+ async onChangeText ( text ) {
56
+ // set note state
56
57
this . setState ( {
57
58
text : text
58
59
} )
60
+
61
+ // save to file
59
62
const dirs = RNFetchBlob . fs . dirs
60
63
fs . writeFile ( `${ dirs . DocumentDir } /Boostnote/${ this . state . fileName } ` , text , 'utf8' )
64
+
65
+ // update note list data
66
+ const settingJsonFile = await fs . readFile ( `${ dirs . DocumentDir } /Boostnote/boostnote.json` , 'utf8' )
67
+ const parsedSetting = JSON . parse ( settingJsonFile ) ;
68
+ let filteredSettingFile = parsedSetting . note . filter ( setting => {
69
+ return setting . name === this . state . fileName
70
+ } ) [ 0 ]
71
+ filteredSettingFile . updatedAt = new Date ( )
72
+ let newJsonFile = parsedSetting . note
73
+ . filter ( setting => {
74
+ return setting . name !== this . state . fileName
75
+ } )
76
+ newJsonFile . push ( filteredSettingFile )
77
+ parsedSetting . note = newJsonFile
78
+
79
+ fs . writeFile ( `${ dirs . DocumentDir } /Boostnote/boostnote.json` , JSON . stringify ( parsedSetting ) , 'utf8' )
80
+ . catch ( err => console . log ( err ) )
61
81
}
62
82
63
83
componentWillMount ( ) {
You can’t perform that action at this time.
0 commit comments