Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/tag-filter/draft/0 #2296

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import SelectButton from "$lib/components/ui/SelectButton.svelte";
import sessionStore from "$lib/store/session.js";
import userBetarenaSettings from "$lib/store/user-settings.js";
import { createEventDispatcher } from "svelte";
import { createEventDispatcher, onMount } from "svelte";
import ArrowDown from "./assets/arrow-down.svelte";
import type {
IPageAuthorTagData,
Expand All @@ -27,6 +27,7 @@
import { subscribeTagFollowersListen } from "$lib/graphql/graphql.common.js";
import { fade } from "svelte/transition";
import { browser } from "$app/environment";
import userSettings from "$lib/store/user-settings.js";

// ╭────────────────────────────────────────────────────────────────────────╮
// │ NOTE: │
Expand Down Expand Up @@ -61,7 +62,7 @@
export let mobile = false;
export let tablet = false;
export let totalArticlesCount = 0;
let filterValue = "all";
let filterValue = "en";
let buttonsWidth: number;
let tagStore: Writable<IPageAuthorTagData>;
let titleHeight;
Expand All @@ -75,7 +76,6 @@
*/ // eslint-disable-next-line no-unused-vars
CNAME: string = "<author⮕w⮕tags-content⮕header";
$: options = [
{ id: "all", label: translations.all },
...$page.data.B_NAV_T.langArray
.map((lang) => ({
id: lang,
Expand Down Expand Up @@ -174,6 +174,10 @@
});
}
// #endregion ➤ 🛠️ METHODS

onMount(() => {
filterValue = userSettings.extract("lang") || "en";
})
</script>

<!--
Expand Down Expand Up @@ -224,7 +228,7 @@
</div>
</div>
<div class="action-buttons" bind:clientWidth={buttonsWidth}>
<!-- {#if !mobile}
{#if !mobile}
<SelectButton bind:value={filterValue} {options} let:currentValue>
<div>
<span>
Expand All @@ -241,7 +245,7 @@
/>
</div>
</SelectButton>
{/if} -->
{/if}

<Button type={isFollowed ? "outline" : "primary"} on:click={follow}>
<span>
Expand Down Expand Up @@ -271,7 +275,7 @@

{#if mobile}
<div class="mobile-selection">
<!-- <SelectButton bind:value={filterValue} {options} let:currentValue>
<SelectButton bind:value={filterValue} {options} let:currentValue>
<div>
<span>
<TranslationText
Expand All @@ -286,7 +290,7 @@
fallback={currentValue?.label}
/>
</div>
</SelectButton> -->
</SelectButton>
</div>
{/if}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
* 📣 selected language in dropdown to
* filter articles by language
* */
let selectedLang: string | null = "all";
let selectedLang: string | null = "en";
/**
* @description
* 📣 array of articles that will be rendered
Expand Down Expand Up @@ -185,7 +185,7 @@
tags = new Map(data.mapTag);
authors = new Map(data.mapAuthor);
articles = prepareArticles(data.mapArticle, tags, authors);
currentTag = tags.get(data.tagId) as IPageAuthorTagData || {};
currentTag = (tags.get(data.tagId) as IPageAuthorTagData) || {};
pageNumber = 1;
}
async function loadArticles() {
Expand All @@ -195,8 +195,14 @@
const res = await fetchArticles({
permalink: currentTag?.permalink,
page: pageNumber,
lang: sessionStore.extract("lang"),
prevData: {...widgetData, mapArticle: articles.map(a => ([a.id, a])) as [number, IPageAuthorArticleData][]},
lang: selectedLang,
prevData: {
...widgetData,
mapArticle: articles.map((a) => [a.id, a]) as [
number,
IPageAuthorArticleData
][],
},
});
articles = [...articles, ...res.articles];
pendingArticles = false;
Expand All @@ -214,7 +220,7 @@
selectedLang ? `&lang=${selectedLang}` : ""
}`
)) as IPageAuthorTagDataFinal;
if (!res) return pendingArticles = false;
if (!res) return (pendingArticles = false);
widgetData = {
...widgetData,
...res,
Expand All @@ -232,8 +238,6 @@
`/api/data/author/tags?translation=${lang}`
)) as IPageAuthorTranslationDataFinal;
translations = { ...res };
const ev = new CustomEvent("translations", { detail: lang });
filter(ev);
}

function scrollHandler() {
Expand Down
Loading