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

Remove any-types and Mod class #1204

Merged
merged 2 commits into from
Feb 15, 2024
Merged

Remove any-types and Mod class #1204

merged 2 commits into from
Feb 15, 2024

Conversation

anttimaki
Copy link
Collaborator

No description provided.

@@ -142,8 +141,7 @@ import SearchAndSort from './LocalModList/SearchAndSort.vue';
}
}

getMissingDependencies(vueMod: any): string[] {
const mod: Mod = new Mod().fromReactive(vueMod);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any issues from having dropped the fromReactive call?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My next performance improvement branch is based on this branch, so I've been monkey testing it quite lot, and so far I've not seen any problems in (dev) building the project, errors logged in the console, or weird behaviour in the UI itself. But work on that continues so I still have more changes to observe these changes as well.

However, I'm not entirely sure in what situations should we expect the objects to get serialized and cause problems in the first place?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's related to loading the profile from the mods.yml file. ManifestV2 is serialized whenever ProfileModList is called to save, and is deserialized whenever we load the contents again

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably good to double check, and if it does prove to still be a potential issue, in my opinion the proper deserialization should simply be moved to be a part of the loading process.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this should not be an issue, the source of the data seems to all trace back to ProfileModList.getModList which also instantiates a proper object for it rather than just passing in the values. This change just simply adds the proper type annotation here and in doing so makes it apparent that the Mod class is not actually needed anymore.

It is possible that the vuex state somehow ends up containing something other than it's annotated to do without our current TS configuration catching it (or e.g. due to type casting that should not be done somewhere), but I couldn't find any such code at least (as mentioned, most seems to originate from ProfileModList.getModList, or alternatively some of the mutation operations in the same module)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright so the main difference here is that the Mod.fromReactive implementation uses the actual package manifest.json for populating the values, whereas the ProfileModList.getModList uses whatever happens to be populated in the mods.yml. In a sense the Mod.fromReactive implementation behaves more "correctly" in this case as it's actually using the data provided by the package itself rather than a state cache file.

In practice I'm not sure if it matters, but I do think the correct way to load mod metadata is to read it from said mod's own manifest file. I suppose the changes in this PR are still an improvement because it's better to have the metadata parsing be consistent and predictable, which is being achieved by removing the rarely used alternative metadata parsing.

Copy link
Collaborator

@MythicManiac MythicManiac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Base automatically changed from mod-list-sort to develop February 15, 2024 10:27
In practice all mod arguments are of ManifestV2 type. Refer to this
type consistently as "mod", and use "tsMod" for the few occurances of
ThunderstoreMod types.
The class was no longer used directly, only by ThunderstoreVersion
which extends it. Relevant attributes and getters/setters were moved
to ThunderstoreVersion definition. Mod.fromManifest was dropped since
it's not used and did return a Mod object anyway.
@anttimaki anttimaki merged commit a2a11b1 into develop Feb 15, 2024
7 checks passed
@anttimaki anttimaki deleted the mod-typing branch February 15, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants