Skip to content
This repository was archived by the owner on Oct 9, 2024. It is now read-only.

Commit 44c65d3

Browse files
committed
fix(pinia): 🐛 fix votes update
1 parent 2cfbfa2 commit 44c65d3

File tree

4 files changed

+3
-27
lines changed

4 files changed

+3
-27
lines changed

pages/plugins/[id].vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ const pluginsStore = usePluginsStore();
6363
// https://github.com/vuejs/pinia/issues/1080
6464
await pluginsStore.nuxtServerInit();
6565
66-
// update votes on mounted
67-
onMounted(() => {
68-
pluginsStore.updatePluginVotes();
69-
});
70-
7166
// check if plugin exists
7267
if (!pluginsStore.exists(id)) {
7368
showError({

pages/plugins/index.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ const pluginsStore = usePluginsStore();
135135
// https://github.com/vuejs/pinia/issues/1080
136136
await pluginsStore.nuxtServerInit();
137137
138-
// update votes on mounted
139-
onMounted(() => {
140-
pluginsStore.updatePluginVotes();
141-
});
142-
143138
// ----------------------------------------------------------------------------
144139
// infinite scroll
145140
// ----------------------------------------------------------------------------

server/api/pluginsVotes.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import {PluginVotesSummary} from "~/types/plugins";
22
import {useBackend} from "~/composables/useBackend";
33

4-
export default defineCachedEventHandler(
5-
async (): Promise<PluginVotesSummary> => await useBackend().fetchVotes(),
6-
{
7-
name: "pluginsVotes",
8-
maxAge: 60,
9-
}
4+
export default defineEventHandler(
5+
async (): Promise<PluginVotesSummary> => await useBackend().fetchVotes()
106
);

stores/usePluginsStore.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,8 @@ export const usePluginsStore = defineStore("plugins", {
120120
$fetch("/api/pluginsBrief"),
121121
$fetch("/api/pluginsVotes"),
122122
]);
123-
},
124-
125-
/**
126-
* Update plugins votes.
127-
*/
128-
async updatePluginVotes() {
129-
if (this.pluginVotesSummary !== undefined) {
130-
return;
131-
}
132-
133-
this.pluginVotesSummary = await useBackend().fetchVotes();
134123

124+
// update votes in brief
135125
for (const id in this.pluginDataBriefSummary) {
136126
this.pluginDataBriefSummary[id].votes = this.pluginVotesSummary[id] ?? 0;
137127
}

0 commit comments

Comments
 (0)