fix frontend bugs
This commit is contained in:
+10
-4
@@ -64,8 +64,8 @@
|
||||
<select v-model="sortBy"
|
||||
class="bg-white dark:bg-gray-900 border dark:border-gray-800 rounded-l-lg px-3 py-2 text-xs font-bold uppercase outline-none focus:ring-1 focus:ring-blue-500 cursor-pointer border-r-0">
|
||||
<option value="date">Date</option>
|
||||
<option value="votes">Rating</option>
|
||||
<option value="comments">Comments</option>
|
||||
<option value="rating">Rating</option>
|
||||
<option value="comment">Comments</option>
|
||||
</select>
|
||||
<button
|
||||
class="bg-white dark:bg-gray-900 border dark:border-gray-800 rounded-r-lg px-3 py-2 text-xs font-bold hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"
|
||||
@@ -387,6 +387,7 @@ const fetchTags = async () => {
|
||||
subscribedTags.value = myTags.map(t => t.id);
|
||||
} catch (err) {
|
||||
console.error("Error fetching tags:", err);
|
||||
notifications.error("Failed to subscribe to tag");
|
||||
}
|
||||
|
||||
};
|
||||
@@ -413,6 +414,7 @@ const toggleTagSubscription = async (tag) => {
|
||||
else subscribedTags.value.push(tag.id);
|
||||
|
||||
console.error("Sync failed:", err);
|
||||
notifications.error("Failed to subscribe to tag");
|
||||
}
|
||||
|
||||
};
|
||||
@@ -451,6 +453,7 @@ const loadPosts = async () => {
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to fetch posts:", err);
|
||||
notifications.error("Failed to load publications");
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -465,6 +468,7 @@ const fetchPostDetail = async (id) => {
|
||||
selectedPost.value = postDetail;
|
||||
} catch (err) {
|
||||
console.error("Failed to fetch post detail:", err);
|
||||
notifications.error("Failed to fetch details");
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -497,6 +501,8 @@ const votePost = async (targetPost, direction) => {
|
||||
selectedPost.value.my_vote = response.my_vote;
|
||||
}
|
||||
|
||||
notifications.success("Voted with success");
|
||||
|
||||
} catch (error) {
|
||||
console.error("Vote failed", error);
|
||||
notifications.error("Failed to submit vote.");
|
||||
@@ -514,9 +520,9 @@ const filteredPosts = computed(() => {
|
||||
return result.sort((a, b) => {
|
||||
const modifier = sortDesc.value ? 1 : -1;
|
||||
|
||||
if (sortBy.value === 'votes') {
|
||||
if (sortBy.value === 'rating') {
|
||||
return (b.rating - a.rating) * modifier;
|
||||
} else if (sortBy.value === 'comments') {
|
||||
} else if (sortBy.value === 'comment') {
|
||||
return (b.commentCount - a.commentCount) * modifier;
|
||||
} else {
|
||||
return (new Date(b.publicationDate).getTime() - new Date(a.publicationDate).getTime()) * modifier;
|
||||
|
||||
Reference in New Issue
Block a user