Skip to content
Merged
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
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"easymde": "^2.8.0",
"markdown-it": "^10.0.0",
"vue": "^2.6.11",
"vue-observe-visibility": "^0.4.6",
"vue-router": "^3.1.3",
"vuex": "^3.1.2"
},
Expand Down
37 changes: 35 additions & 2 deletions src/components/NavigationList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,41 @@
@note-deleted="$emit('note-deleted')"
/>
</template>
<AppNavigationItem
v-if="notes.length != filteredNotes.length"
v-observe-visibility="onEndOfNotes"
:title="t('notes', 'Loading …')"
:loading="true"
/>
</ul>
</template>

<script>
import {
AppNavigationCaption,
AppNavigationItem,
} from '@nextcloud/vue'
import NavigationCategoriesItem from './NavigationCategoriesItem'
import NavigationNoteItem from './NavigationNoteItem'
import NotesService from '../NotesService'
import store from '../store'

import { ObserveVisibility } from 'vue-observe-visibility'

export default {
name: 'NavigationList',

components: {
AppNavigationCaption,
AppNavigationItem,
NavigationCategoriesItem,
NavigationNoteItem,
},

directives: {
'observe-visibility': ObserveVisibility,
},

props: {
filteredNotes: {
type: Array,
Expand All @@ -86,6 +100,7 @@ export default {
timeslots: [],
monthFormat: new Intl.DateTimeFormat(OC.getLanguage(), { month: 'long', year: 'numeric' }),
lastYear: new Date(new Date().getFullYear() - 1, 0),
showFirstNotesOnly: true,
}
},

Expand All @@ -94,10 +109,18 @@ export default {
return store.getters.numNotes()
},

notes() {
if (this.filteredNotes.length > 40 && this.showFirstNotesOnly) {
return this.filteredNotes.slice(0, 30)
} else {
return this.filteredNotes
}
},

// group notes by time ("All notes") or by category (if category chosen)
groupedNotes() {
if (this.category === null) {
return this.filteredNotes.reduce((g, note) => {
return this.notes.reduce((g, note) => {
const timeslot = this.getTimeslotFromNote(note)
if (g.length === 0 || g[g.length - 1].timeslot !== timeslot) {
g.push({ timeslot: timeslot, notes: [] })
Expand All @@ -106,7 +129,7 @@ export default {
return g
}, [])
} else {
return this.filteredNotes.reduce((g, note) => {
return this.notes.reduce((g, note) => {
if (g.length === 0 || g[g.length - 1].category !== note.category) {
g.push({ category: note.category, notes: [] })
}
Expand All @@ -129,6 +152,10 @@ export default {
},
},

watch: {
category: function() { this.showFirstNotesOnly = true },
},

created() {
this.updateTimeslots()
setInterval(this.updateTimeslots, 1000 * 60)
Expand Down Expand Up @@ -170,6 +197,12 @@ export default {
return new Date(t).getFullYear().toString()
}
},

onEndOfNotes(isVisible) {
if (isVisible) {
this.showFirstNotesOnly = false
}
},
},
}
</script>
Expand Down