Skip to content

feat(frontend): Store last selected game version and platform for download modal #3284

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
57 changes: 19 additions & 38 deletions apps/frontend/src/pages/[type]/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,22 +241,7 @@
</div>
</div>
<div class="mx-auto flex w-fit flex-col gap-2">
<ButtonStyled v-if="project.game_versions.length === 1">
<div class="disabled button-like">
<GameIcon aria-hidden="true" />
{{
currentGameVersion
? `Game version: ${currentGameVersion}`
: "Error: no game versions found"
}}
<InfoIcon
v-tooltip="`${project.title} is only available for ${currentGameVersion}`"
class="ml-auto size-5"
/>
</div>
</ButtonStyled>
<Accordion
v-else
ref="gameVersionAccordion"
class="accordion-with-bg"
@on-open="
Expand Down Expand Up @@ -310,7 +295,7 @@
}"
@click="
() => {
userSelectedGameVersion = gameVersion;
setSelectedGameVersion(gameVersion);
gameVersionAccordion.close();
if (!currentPlatform && platformAccordion) {
platformAccordion.open();
Expand Down Expand Up @@ -339,26 +324,8 @@
:disabled="!!versionFilter"
/>
</Accordion>
<ButtonStyled
v-if="project.loaders.length === 1 && project.project_type !== 'resourcepack'"
>
<div class="disabled button-like">
<WrenchIcon aria-hidden="true" />
{{
currentPlatform
? `Platform: ${formatCategory(currentPlatform)}`
: "Error: no platforms found"
}}
<InfoIcon
v-tooltip="
`${project.title} is only available for ${formatCategory(currentPlatform)}`
"
class="ml-auto size-5"
/>
</div>
</ButtonStyled>
<Accordion
v-else-if="project.project_type !== 'resourcepack'"
v-if="project.project_type !== 'resourcepack'"
ref="platformAccordion"
class="accordion-with-bg"
@on-open="
Expand Down Expand Up @@ -394,7 +361,7 @@
}"
@click="
() => {
userSelectedPlatform = platform;
setSelectedPlatform(platform);

platformAccordion.close();
if (!currentGameVersion && gameVersionAccordion) {
Expand Down Expand Up @@ -843,7 +810,6 @@ import {
ImageIcon as GalleryIcon,
GameIcon,
HeartIcon,
InfoIcon,
LinkIcon as LinksIcon,
MoreVerticalIcon,
PlusIcon,
Expand Down Expand Up @@ -911,6 +877,10 @@ const overTheTopDownloadAnimation = ref();
const userSelectedGameVersion = ref(null);
const userSelectedPlatform = ref(null);
const showAllVersions = ref(false);
if (import.meta.client) {
userSelectedGameVersion.value = localStorage.getItem("selected_game_version");
userSelectedPlatform.value = localStorage.getItem("selected_platform");
}

const gameVersionFilterInput = ref();

Expand Down Expand Up @@ -1009,7 +979,18 @@ const licenseIdDisplay = computed(() => {
return id;
}
});

function setSelectedGameVersion(version) {
userSelectedGameVersion.value = version;
if (import.meta.client) {
localStorage.setItem("selected_game_version", version);
}
}
function setSelectedPlatform(platform) {
userSelectedPlatform.value = platform;
if (import.meta.client) {
localStorage.setItem("selected_platform", platform);
}
}
async function getLicenseData(event) {
modalLicense.value.show(event);

Expand Down
Loading