Skip to content

Commit

Permalink
[dev] Revert back tags lang filtration (#2296)
Browse files Browse the repository at this point in the history
  • Loading branch information
Izobov authored Dec 2, 2024
1 parent 8323779 commit d495c6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
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

0 comments on commit d495c6d

Please sign in to comment.