Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

:bug: Fixed Staring history not updating on synced DB

Liyas Thomas92d8878c38cb
diff --git a/components/history.vue b/components/history.vue
index e186cd2ea..c769aa30c 100644
--- a/components/history.vue
+++ b/components/history.vue
@@ -21,7 +21,7 @@
<button
class="icon"
:class="{ stared: entry.star }"
- @click="toggleStar(index)"
+ @click="toggleStar(entry)"
v-tooltip="{
content: !entry.star ? $t('add_star') : $t('remove_star')
}"
@@ -508,8 +508,11 @@ export default {
toggleCollapse() {
this.showMore = !this.showMore;
},
- toggleStar(index) {
- this.history[index]["star"] = !this.history[index]["star"];
+ toggleStar(entry) {
+ if (fb.currentUser !== null) {
+ fb.toggleStar(entry, !entry.star);
+ }
+ entry.star = !entry.star;
updateOnLocalStorage("history", this.history);
}
}
diff --git a/functions/fb.js b/functions/fb.js
index ff906994e..698b9150e 100644
--- a/functions/fb.js
+++ b/functions/fb.js
@@ -97,6 +97,14 @@ export const fb = {
.then(({ docs }) => {
docs.forEach(e => fb.deleteHistory(e));
});
+ },
+ toggleStar: (entry, value) => {
+ usersCollection
+ .doc(fb.currentUser.uid)
+ .collection("history")
+ .doc(entry.id)
+ .update({ star: value })
+ .catch(e => console.error("error deleting", entry, e));
}
};