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

Chore: rip out v9 compatibility and other chore commits #262

Merged
merged 23 commits into from
Dec 10, 2022

Conversation

anthonyronda
Copy link
Member

Tests: 395/395 passing

  • The input delay on tests is now 120ms due to some dev machines not completing tests under the 100ms delay
  • V9 compatibility code has been removed due to abandoning support for V9 in releases moving forward
  • Some remaining references to the data object on documents have been removed
  • Removed some errant console logging that accidentally got committed to the system
  • returned the dependency caching to the CI workflow
    I placed the --ignore-scripts flag on the npm ci command after verifying locally that current dependencies do not have required postinstall scripts for npm run build to function properly

Copy link
Collaborator

@wyrmisis wyrmisis left a comment

Choose a reason for hiding this comment

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

Great set of changes. I have a bunch of conceptual questions and "while we're in there" fixes to suggest.

@@ -122,7 +122,7 @@ export class OseActorSheet extends ActorSheet {
*/
_useConsumable(event, decrement) {
const item = this._getItemFromActor(event);
const itemData = item?.system || item?.data?.data; //v9-compatibility
const itemData = item?.system;

if (decrement) {
item.update({ "data.quantity.value": itemData.quantity.value - 1 });
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should replace these data.[...] updates with system.[...].

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, thanks for the catch. If I haven't caught every remaining data reference, I've at least taken care of the ones in document update methods in today's first commit

@@ -187,7 +187,7 @@ export class OseActorSheet extends ActorSheet {
let element = event.currentTarget;
let attack = element.parentElement.parentElement.dataset.attack;
const rollData = {
actor: isNewerVersion(game.version, "10.264") ? this : this.data, //v9-compatibility
actor: this,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't this the OseActorSheet (or subclass) here?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is OseActorSheetCharacter. _rollAttack() is only used for "improvised melee" and "improvised ranged" (by clicking on the MEL and MIS headers of the melee and missile bonus boxes).

Because it appeared targetAttack() will take either one for the roll data without complaint, I looked into the reason...it's completely ignored

removed rollData as irrelevant in my third commit today

@@ -187,7 +187,7 @@ export class OseActorSheet extends ActorSheet {
let element = event.currentTarget;
let attack = element.parentElement.parentElement.dataset.attack;
const rollData = {
actor: isNewerVersion(game.version, "10.264") ? this : this.data, //v9-compatibility
actor: this,
roll: {},
};
actorObject.targetAttack(rollData, attack, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thoughts on setting rolldata on the actor instead of the actor sheet? Do we need to give rollData the actor sheet?

Copy link
Member Author

Choose a reason for hiding this comment

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

rollData has been removed from the function (see last comment)

@@ -204,7 +204,7 @@ export class OseActorSheet extends ActorSheet {
const dropTarget = event.target.closest("[data-item-id]");
const targetId = dropTarget ? dropTarget.dataset.itemId : null;
const target = siblings.find((s) => s.data._id === targetId);
const targetData = target?.system || target?.data?.data; //v9-compatibility
const targetData = target?.system;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we bail if there's no target?

Copy link
Member Author

@anthonyronda anthonyronda Nov 30, 2022

Choose a reason for hiding this comment

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

I think there will be a merge conflict with your item data model code here
For now, I did decide to throw an error which might be a good idea in other places where we can think of a useful error to write for debugging

@@ -72,11 +72,11 @@ export class OseItemSheet extends ItemSheet {
this.object.popManualTag(value);
});
html.find("a.melee-toggle").click(() => {
this.object.update({ data: { melee: !this.object.data.data.melee } });
this.object.update({ data: { melee: !this.object.system.melee } });
Copy link
Collaborator

Choose a reason for hiding this comment

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

this.object.update({ 'system.melee': !this.object.system.melee })

@@ -15,7 +15,7 @@ export async function createOseMacro(data, slot) {
return ui.notifications.warn(
game.i18.localize("OSE.warn.macrosOnlyForOwnedItems")
);
const item = data.data;
const item = data;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just rename the param above to item?

Copy link
Member Author

Choose a reason for hiding this comment

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

oops, turns out this is not an Item document object after all! So this code change breaks the (probably not often used) ability to drag an item from your sheet to your macro bar to create a roll macro (or if there is no roll for the item, a "view item" macro)

Copy link
Member Author

Choose a reason for hiding this comment

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

This change has been undone. I'd like to refactor this as part of a different PR

act.data.flags[systemName] &&
act.data.flags[systemName].party === true);
console.log(characters)
const systemName = game.system.id == "ose" ? game.system.id : "ose-dev";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this come from CONFIG.OSE?

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed in third commit today named "fix: one-use keys..."

(act) =>
act.type === "character" &&
act.flags[systemName] &&
act.flags[systemName].party === true
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this prop intentionally be a truthy value that isn't true

Copy link
Member Author

Choose a reason for hiding this comment

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

I did a cursory check of setFlag in the repo and only found "party" only ever getting set to true or false

{{localize 'OSE.dialog.xp.label'}}
</button>
{{/if}}
</div>
<div class="body party-members">
{{#if user.isGM}}
{{#if (eq partyActors.length 0)}}
{{#if user.isGM}} {{#if (eq partyActors.length 0)}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than nesting ifs, could we add a prop to the backing JS file for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hope you'll accept this solution to eliminate nesting ifs
The and helper is from foundry.js

@anthonyronda anthonyronda mentioned this pull request Nov 23, 2022
@anthonyronda
Copy link
Member Author

still working on this PR

There's a problem with drag and drop I'm starting to diagnose and I don't know where they got introduced

@anthonyronda anthonyronda mentioned this pull request Dec 1, 2022
5 tasks
@anthonyronda anthonyronda requested a review from wyrmisis December 1, 2022 01:45
itemIds.push(itemData.id);
const item = this.actor.items.get(itemData[0]._id);
await item.update({ system: { containerId: container.id } });
await container.update({ system: { itemIds: itemIds } });
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are some places where we return promises, and others where we await promises in place at the end of a function. I don't think we have to standardize it for this PR, especially if we're not sure how long this sheet is going to stick around, but it might be good to hammer out the pattern we want to use.

@@ -456,11 +402,11 @@ export class OseActorSheet extends ActorSheet {

if (event.target.dataset.field === "value") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could probably DRY up blocks like this so we only call item.update in one spot, like so:

() => {
  const {field} = event.target.dataset;

  if (field !== 'value' && field !== 'max')
    throw new Error('Malformed update call when updating item quantity');
  
  return item.update({
    [`system.quantity.${field}]: parseInt(event.target.value)
  });
}

Not worth holding the PR up for, just a thought

Copy link
Collaborator

@wyrmisis wyrmisis 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

@anthonyronda anthonyronda merged commit f7dbbdd into vttred:main Dec 10, 2022
@anthonyronda anthonyronda deleted the chore-rip-out-v9-compatibility branch December 10, 2022 15:39
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.

2 participants