Skip to content

Commit

Permalink
feat(#289): Readded cardList in gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
lxgr-linux committed Apr 25, 2024
1 parent bd59add commit 7535a47
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
13 changes: 7 additions & 6 deletions src/def-composables/useGallery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const galleryFiltersFromPageQuery = (query: PageQuery) => {
galleryFilters.value.notesContains = query.notesContains;
galleryFilters.value.sortBy = query.sortBy ? query.sortBy : "Name";
galleryFilters.value.multiClass = query.multiClassOnly;
galleryFilters.value.status = query.statuses.length != 1 ? "playable" : query.statuses[0]
galleryFilters.value.status =
query.statuses.length != 1 ? "playable" : query.statuses[0];

if (
query.classes.length == 0 ||
Expand All @@ -57,11 +58,11 @@ const galleryFiltersFromPageQuery = (query: PageQuery) => {
} else {
galleryFilters.value.nature = query.classes.includes(CardClass.nature);
galleryFilters.value.technology = query.classes.includes(
CardClass.technology
CardClass.technology,
);
galleryFilters.value.culture = query.classes.includes(CardClass.culture);
galleryFilters.value.mysticism = query.classes.includes(
CardClass.mysticism
CardClass.mysticism,
);
}

Expand Down Expand Up @@ -116,7 +117,7 @@ const pageQueryFromGalleryFilters = (): PageQuery => {
notesContains: galleryFilters.value.notesContains,
sortBy: galleryFilters.value.sortBy ? galleryFilters.value.sortBy : "",
multiClassOnly: galleryFilters.value.multiClass,
} as Partial<PageQuery>);
} as Partial<QueryQCardsRequest>);
};

const loadQueryCardList = (query: PageQuery): void => {
Expand All @@ -126,11 +127,11 @@ const loadQueryCardList = (query: PageQuery): void => {
paramsSerializer: constructAssRetardetQueryParams,
}).then((res: QueryQCardsResponse) => {
cardList.value = res.cardsList;
})
});
};

watch(galleryFilters.value, () =>
loadQueryCardList(pageQueryFromGalleryFilters())
loadQueryCardList(pageQueryFromGalleryFilters()),
);

export const useGallery = () => {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export const normalizeCoins = (coins: Coin[]) => {
};

export const normalizeNumberList = (l: Array<any> | any) =>
(Array.isArray(l) ? l.map((v) => Number(v)) : [Number(l)]).filter(w => !Number.isNaN(w));
(Array.isArray(l) ? l.map((v) => Number(v)) : [Number(l)]).filter(
(w) => !Number.isNaN(w),
);
export const normalizeBoolean = (b: any) => b == "true";

export const normalizeQuery = (query: any): PageQuery => {
Expand Down
3 changes: 3 additions & 0 deletions src/views/About/CommunityPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
</template>
<script setup lang="ts">
import logo from "@/assets/figma/CCLogo.png";
import {useLoggedIn} from "@/def-composables/useLoggedIn2";
const {loggedIn} = useLoggedIn()
const names = [
"RUSLAN",
Expand Down
11 changes: 8 additions & 3 deletions src/views/GalleryPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,14 @@ const typeOptions: GalleryFilterImageChooserOptions<GalleryFilters> = [
];
onMounted(() => {
if (!R.isEmpty(route.query)) {
galleryFiltersFromPageQuery(normalizeQuery(route.query));
loadQueryCardList(pageQueryFromGalleryFilters());
const query = route.query
if (!R.isEmpty(query)) {
if ((query as {cards?: number[]}).cards) {
cardList.value = (query as {cards?: number[]}).cards!
} else {
galleryFiltersFromPageQuery(normalizeQuery(route.query));
loadQueryCardList(pageQueryFromGalleryFilters());
}
} else if (cardList.value.length == 0) {
loadQueryCardList(pageQueryFromGalleryFilters());
} else {
Expand Down
7 changes: 4 additions & 3 deletions src/views/UserView/UserView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
}}</b>
<div class="pb-6">
<p class="pb-3">
<b>{{ state.user.ownedCardSchemes.length }} {{ "Master Card"
}}{{ state.user.ownedCardSchemes.length == 1 ? "" : "s" }}</b>
<b>{{ state.user.ownedPrototypes.length }} {{ "Master Card"
}}{{ state.user.ownedPrototypes.length == 1 ? "" : "s" }}</b>
</p>
<RouterCCButton
:type="Color.YELLOW"
Expand All @@ -110,7 +110,7 @@
:type="Color.YELLOW"
:to="{
name: 'Gallery',
query: { owner: state.addr, sortBy: 'Name' },
query: { cards: state.user.cards },
}"
>
View in gallery
Expand Down Expand Up @@ -252,6 +252,7 @@ const init = () => {
getUser();
getCoins();
getMatches();
console.log(state.user)
};
onMounted(init);
Expand Down

0 comments on commit 7535a47

Please sign in to comment.