Skip to content

Commit

Permalink
Delete empty notes
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthkp committed Dec 24, 2016
1 parent 9f60fd3 commit 5ef2037
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<sidebar>
<list></list>
<night>🌚</night>
<reload style="opacity: 0" onclick="location.reload(true)">💀</reload>
</sidebar>
<textarea autofocus placeholder="start typing"></textarea>
<script src="interface.js"></script>
Expand Down
9 changes: 5 additions & 4 deletions interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ const renderNote = (title) => {

const saveNote = () => {
let content = textarea.value
if (!content) return

let title = getTitle(content)

if (activeNote.title !== '_new note') delete notes[activeNote.title]
activeNote.title = title

notes[title] = content
/* If the note is empty, delete it */
if (content) {
activeNote.title = title
notes[title] = content
}

saveNotes()
}
Expand Down
2 changes: 1 addition & 1 deletion store.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ getNotes().then(data => {
sync(data => {
notes = data
renderSidebar(notes)

saveLocally(notes)
/* Syncs notes between devices as long as the title doesn't change */
if (notes[activeNote.title]) renderNote(activeNote.title)
})
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sidebar {
height: 100%;
margin-right: 5%;
white-space: nowrap;
overflow: hidden;
overflow-x: hidden;
color: grey;
}
sidebar div {
Expand Down

0 comments on commit 5ef2037

Please sign in to comment.