Add favorites UI

pull/37/head
Varun Patil 2022-09-11 19:21:20 -07:00
parent d4746abade
commit 06af7a1b27
3 changed files with 32 additions and 2 deletions

View File

@ -11,6 +11,10 @@
:title="t('folders', 'Folders')"
icon="icon-files-dark">
</NcAppNavigationItem>
<NcAppNavigationItem :to="{name: 'favorites'}"
:title="t('favorites', 'Favorites')"
icon="icon-favorite">
</NcAppNavigationItem>
</template>
<template #footer>
<NcAppNavigationSettings :title="t('memories', 'Settings')">

View File

@ -377,6 +377,23 @@ export default {
}
},
/** Get query string for API calls */
appendQuery(url) {
const query = new URLSearchParams();
// Favorites
if (this.$route.name === 'favorites') {
query.set('fav', 1);
}
// Create query string and append to URL
const queryStr = query.toString();
if (queryStr) {
url += '?' + queryStr;
}
return url;
},
/** Fetch timeline main call */
async fetchDays() {
let url = API_ROUTES.DAYS;
@ -388,7 +405,7 @@ export default {
}
const startState = this.state;
const res = await axios.get(generateUrl(url, params));
const res = await axios.get(generateUrl(this.appendQuery(url), params));
const data = res.data;
if (this.state !== startState) return;
await this.processDays(data);
@ -481,7 +498,7 @@ export default {
try {
const startState = this.state;
const res = await axios.get(generateUrl(url, params));
const res = await axios.get(generateUrl(this.appendQuery(url), params));
const data = res.data;
if (this.state !== startState) return;

View File

@ -63,5 +63,14 @@
rootTitle: t('folders', 'Folders'),
}),
},
{
path: '/favorites',
component: Timeline,
name: 'favorites',
props: route => ({
rootTitle: t('favorites', 'Favorites'),
}),
},
],
})