toggle by setting date instead of bool
This commit is contained in:
parent
7844996672
commit
ee369a32d6
|
@ -14,6 +14,15 @@
|
|||
const tag = e.srcElement.dataset.tag
|
||||
dispatch('filter', tag)
|
||||
}
|
||||
|
||||
function noteTime(note) {
|
||||
console.log(note)
|
||||
if (note.done) {
|
||||
return time(note.done)
|
||||
} else if(note.created) {
|
||||
return time(note.created)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<article class="note flex" class:done={note.done} class:todo={!note.done}>
|
||||
|
@ -21,12 +30,12 @@
|
|||
{note.title}
|
||||
</div>
|
||||
|
||||
<div>{noteTime(note)}</div>
|
||||
<aside class="tags">
|
||||
{#each note.tags as tag}
|
||||
<a href={`/tag/${tag}`} data-tag={tag} on:click={filterByTag}>#{tag}</a>
|
||||
{/each}
|
||||
</aside>
|
||||
|
||||
</article>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -43,10 +43,12 @@ export function applyFilterSort(notes, filter) {
|
|||
export function toggleDoneState(notes, id) {
|
||||
return notes.map(note => {
|
||||
if (note.created === id) {
|
||||
const done = note.done ? null : Date.now()
|
||||
|
||||
// return a new object
|
||||
return {
|
||||
...note,
|
||||
done: !note.done
|
||||
done
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue