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}
</form>
<!--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] }
</label>
<!--Start Downvote-->

View File

@ -235,9 +235,7 @@ onMount( async() => {
{/if}
</div>
<!-- End Column -->
@ -254,7 +252,7 @@ onMount( async() => {
</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">
<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">

View File

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