fix: broken list

This commit is contained in:
2025-03-17 02:26:17 +00:00
parent af4929a5b3
commit fe1a32f31b
7 changed files with 23 additions and 20 deletions

View File

@ -3,7 +3,7 @@ use derive_more::Display;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{collections::BTreeSet, path::{Path, PathBuf}}; use std::{collections::BTreeSet, path::{Path, PathBuf}};
use tokio::fs; use tokio::fs;
use enumflags2::{bitflags, BitFlags}; use enumflags2::{bitflags, make_bitflags, BitFlags};
use crate::{model::{local::{self, PackageManifest}, rainy}, util}; use crate::{model::{local::{self, PackageManifest}, rainy}, util};
// {namespace}-{name} // {namespace}-{name}
@ -36,6 +36,7 @@ pub enum Status {
#[repr(u8)] #[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum Feature { pub enum Feature {
Mod,
Hook, Hook,
GameIO, GameIO,
Aime, Aime,
@ -185,11 +186,11 @@ impl Package {
fn parse_status(mft: &PackageManifest) -> Status { fn parse_status(mft: &PackageManifest) -> Status {
if mft.installers.len() == 0 { if mft.installers.len() == 0 {
return Status::OK(BitFlags::default());//Unchecked return Status::OK(make_bitflags!(Feature::Mod));//Unchecked
} else if mft.installers.len() == 1 { } else if mft.installers.len() == 1 {
if let Some(serde_json::Value::String(id)) = &mft.installers[0].get("identifier") { if let Some(serde_json::Value::String(id)) = &mft.installers[0].get("identifier") {
if id == "rainycolor" { if id == "rainycolor" {
return Status::OK(BitFlags::default()); return Status::OK(make_bitflags!(Feature::Mod));
} else if id == "segatools" { } else if id == "segatools" {
// Multiple features in the same dll (yubideck etc.) should be supported at some point // Multiple features in the same dll (yubideck etc.) should be supported at some point
let mut flags = BitFlags::default(); let mut flags = BitFlags::default();

View File

@ -40,7 +40,7 @@ const group = () => {
}; };
const missing = computed(() => { const missing = computed(() => {
return prf.current?.mods.filter((m) => !pkgs.hasLocal(m)); return prf.current?.mods.filter((m) => !pkgs.hasLocal(m)) ?? [];
}); });
</script> </script>

View File

@ -8,7 +8,8 @@ import LinkButton from './LinkButton.vue';
import ModTitlecard from './ModTitlecard.vue'; import ModTitlecard from './ModTitlecard.vue';
import UpdateButton from './UpdateButton.vue'; import UpdateButton from './UpdateButton.vue';
import { usePkgStore, usePrfStore } from '../stores'; import { usePkgStore, usePrfStore } from '../stores';
import { Package } from '../types'; import { Feature, Package } from '../types';
import { hasFeature } from '../util';
const prf = usePrfStore(); const prf = usePrfStore();
const pkgs = usePkgStore(); const pkgs = usePkgStore();
@ -33,10 +34,10 @@ const model = computed({
<UpdateButton :pkg="pkg" /> <UpdateButton :pkg="pkg" />
<!-- @vue-expect-error Can't 'as any' because it breaks VSCode --> <!-- @vue-expect-error Can't 'as any' because it breaks VSCode -->
<ToggleSwitch <ToggleSwitch
v-if="pkg?.loc?.kind === 'Mod' || pkg?.loc?.kind === 'Unsupported'" v-if="hasFeature(pkg, Feature.Mod)"
class="scale-[1.33] shrink-0" class="scale-[1.33] shrink-0"
inputId="switch" inputId="switch"
:disabled="pkg!.loc!.kind === 'Unsupported'" :disabled="pkg!.loc!.status === 'Unsupported'"
v-model="model" v-model="model"
/> />
<InstallButton :pkg="pkg" /> <InstallButton :pkg="pkg" />

View File

@ -1,8 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import Chip from 'primevue/chip'; import Chip from 'primevue/chip';
import { convertFileSrc } from '@tauri-apps/api/core'; import { convertFileSrc } from '@tauri-apps/api/core';
import { Package } from '../types'; import { Feature, Package } from '../types';
import { needsUpdate } from '../util'; import { hasFeature, needsUpdate } from '../util';
const props = defineProps({ const props = defineProps({
pkg: Object as () => Package, pkg: Object as () => Package,
@ -52,21 +52,19 @@ const iconSrc = () => {
> >
</span> </span>
<span <span
v-if="pkg?.loc?.kind === 'Hook'" v-if="hasFeature(pkg, Feature.Hook)"
v-tooltip="'Hook'" v-tooltip="'Hook'"
class="pi pi-wrench ml-1 text-blue-400" class="pi pi-wrench ml-1 text-blue-400"
> >
</span> </span>
<span <span
v-if="pkg?.loc?.kind === 'GameIO'" v-if="hasFeature(pkg, Feature.GameIO)"
v-tooltip="'IO'" v-tooltip="'IO'"
class="pi pi-wrench ml-1 text-green-400" class="pi pi-wrench ml-1 text-green-400"
> >
</span> </span>
<span <span
v-if=" v-if="hasFeature(pkg, Feature.Aime)"
pkg?.loc?.kind === 'AMNet' || pkg?.loc?.kind === 'AimeOther'
"
v-tooltip="'Aime'" v-tooltip="'Aime'"
class="pi pi-wrench ml-1 text-purple-400" class="pi pi-wrench ml-1 text-purple-400"
> >

View File

@ -83,7 +83,7 @@ export const usePkgStore = defineStore('pkg', {
all: (state) => Object.values(state), all: (state) => Object.values(state),
allLocal: (state) => Object.values(state.pkg).filter((p) => p.loc), allLocal: (state) => Object.values(state.pkg).filter((p) => p.loc),
hasLocal: (state) => (key: string) => hasLocal: (state) => (key: string) =>
key in state.pkg && state.pkg[key].loc, state.pkg.hasOwnProperty(key) && state.pkg[key].loc,
allRemote: (state) => allRemote: (state) =>
Object.values(state.pkg).filter( Object.values(state.pkg).filter(
(p) => (p) =>

View File

@ -23,10 +23,11 @@ export interface Package {
} }
export enum Feature { export enum Feature {
Hook = 0b00001, Mod = 0b00001,
GameIO = 0b00010, Hook = 0b00010,
Aime = 0b00100, GameIO = 0b00100,
AMNet = 0b01000, Aime = 0b01000,
AMNet = 0b10000,
} }
export type Status = export type Status =

View File

@ -46,9 +46,11 @@ export const needsUpdate = (pkg: Package | undefined) => {
return l1 < r1; return l1 < r1;
}; };
export const hasFeature = (pkg: Package, feature: Feature) => { export const hasFeature = (pkg: Package | undefined, feature: Feature) => {
return ( return (
pkg !== undefined &&
pkg.loc !== null && pkg.loc !== null &&
pkg.loc !== undefined &&
typeof pkg.loc?.status !== 'string' && typeof pkg.loc?.status !== 'string' &&
pkg.loc.status.OK & feature pkg.loc.status.OK & feature
); );