bugfixing: switch between hot and new posts

This commit is contained in:
MuslemRahimi 2024-06-03 21:42:51 +02:00
parent dcfa7dbc30
commit 016f18809c
3 changed files with 9 additions and 13 deletions

View File

@ -284,7 +284,7 @@ $: {
{/if} {/if}
</form> </form>
<!--End Upvote--> <!--End Upvote-->
<label class="px-6 py-4 w-14 rounded-lg bg-[#202020] border border-gray-700 text-[1rem] text-bold text-white"> <label class="text-center py-4 w-14 rounded-lg bg-[#202020] border border-gray-700 text-[1rem] text-bold text-white">
{upvoteCounter[posts?.id] - downvoteCounter[posts?.id] } {upvoteCounter[posts?.id] - downvoteCounter[posts?.id] }
</label> </label>
<!--Start Downvote--> <!--Start Downvote-->

View File

@ -236,8 +236,6 @@ onMount( async() => {
</div> </div>
<!-- End Column --> <!-- End Column -->
@ -254,7 +252,7 @@ onMount( async() => {
</div> </div>
<div class="w-full max-w-3xl m-auto mb-20 flex justify-center items-center"> <div class="w-full max-w-3xl m-auto mb-20 -mt-4 flex justify-center items-center">
<a href="/community" class="px-4 py-3 text-white bg-[#202327] rounded-lg flex flex-row items-center font-medium transition duration-150 ease-in-out group"> <a href="/community" class="px-4 py-3 text-white bg-[#202327] rounded-lg flex flex-row items-center font-medium transition duration-150 ease-in-out group">
<span>Follow the Community </span> <span>Follow the Community </span>
<span class="ml-1 mt-0.5 tracking-normal group-hover:translate-x-0.5 transition-transform duration-150 ease-in-out"> <span class="ml-1 mt-0.5 tracking-normal group-hover:translate-x-0.5 transition-transform duration-150 ease-in-out">

View File

@ -56,7 +56,7 @@ async function infiniteHandler({ detail: { loaded, complete } })
{ {
// console.log("Page position:", window.pageYOffset); // console.log("Page position:", window.pageYOffset);
seenPostId = posts?.map(obj => obj.id); seenPostId = posts?.map(obj => obj?.id);
if (!postLoading && !noPostMore) { if (!postLoading && !noPostMore) {
postLoading = true; postLoading = true;
@ -244,7 +244,7 @@ onMount(async () => {
else { else {
// Use cached data if available // Use cached data if available
posts = $cachedPosts[0].posts; posts = $cachedPosts?.at(0)?.posts;
communityStats = getCache('', 'getCommunityStats'); communityStats = getCache('', 'getCommunityStats');
moderators = getCache('', 'getModerators'); moderators = getCache('', 'getModerators');
discordData = getCache('','getDiscordWidget'); discordData = getCache('','getDiscordWidget');
@ -269,22 +269,19 @@ onDestroy(async () => {
let sortingPosts = $cachedPosts?.at(0)?.sortingPosts?.length > 0 ? $cachedPosts?.at(0)?.sortingPosts : 'new'; let sortingPosts = $cachedPosts?.at(0)?.sortingPosts?.length > 0 ? $cachedPosts?.at(0)?.sortingPosts : 'hot';
async function handleCategoryOfPosts(state) { async function handleCategoryOfPosts(state) {
loading = true; loading = true;
posts = null; posts = [];
currentPage = 1; currentPage = 1;
postLoading = false; postLoading = false;
seenPostId = []; seenPostId = [];
noPostMore = false; noPostMore = false;
sortingPosts = state; sortingPosts = state;
$cachedPosts = [];
posts = await getPost(); posts = await getPost();
loading = false; loading = false;
} }
@ -346,6 +343,7 @@ $: {
</script> </script>