Skip to content

Commit

Permalink
perf: cache articles page
Browse files Browse the repository at this point in the history
  • Loading branch information
RitvikSardana committed Jan 17, 2025
1 parent 6bc5240 commit 897927b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion desk/src/components/knowledge-base/ArticleCard2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}}</span>
</div>
<span class="text-sm text-gray-600">{{
dayjs.tz(article.published_on).format("DD, MMM YYYY")
dayjs.tz(article.modified).fromNow()
}}</span>
</div>
</router-link>
Expand Down
15 changes: 12 additions & 3 deletions desk/src/pages/knowledge-base/Articles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,28 @@

<script setup lang="ts">
import { onMounted, computed } from "vue";
import { articles, categoryName } from "@/stores/knowledgeBase";
import { Breadcrumbs } from "frappe-ui";
import { categoryName } from "@/stores/knowledgeBase";
import { Breadcrumbs, createResource } from "frappe-ui";
import LayoutHeader from "@/components/LayoutHeader.vue";
import ArticleCard2 from "@/components/knowledge-base/ArticleCard2.vue";
const props = defineProps({
categoryId: {
required: true,
type: String,
},
});
const articles = createResource({
url: "helpdesk.api.knowledge_base.get_category_articles",
cache: ["articles", props.categoryId],
params: {
category: props.categoryId,
},
auto: true,
});
onMounted(() => {
articles.fetch({ category: props.categoryId });
categoryName.fetch({
category: props.categoryId,
});
Expand Down
10 changes: 1 addition & 9 deletions desk/src/stores/knowledgeBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,7 @@ export const categories = createResource({
cache: ["categories"],
});

export const articles = createResource({
url: "helpdesk.api.knowledge_base.get_category_articles",
cache: ["articles"],
makeParams({ category }) {
return {
category,
};
},
});


export const categoryName = createResource({
url: "helpdesk.api.knowledge_base.get_category_title",
Expand Down

0 comments on commit 897927b

Please sign in to comment.