From 0745408bc491d4c294478194e31244b8112b48e1 Mon Sep 17 00:00:00 2001 From: marvin9257 <72580196+marvin9257@users.noreply.github.com> Date: Wed, 22 Jan 2025 10:11:33 -0600 Subject: [PATCH] fix: get rid of newItem check since it doesn't seem to do anything --- src/module/entities/TwodsixItem.ts | 1 - src/module/hooks/renderItemSheet.ts | 32 ----------------------------- 2 files changed, 33 deletions(-) delete mode 100644 src/module/hooks/renderItemSheet.ts diff --git a/src/module/entities/TwodsixItem.ts b/src/module/entities/TwodsixItem.ts index f53a79acf..8d9c4f815 100644 --- a/src/module/entities/TwodsixItem.ts +++ b/src/module/entities/TwodsixItem.ts @@ -79,7 +79,6 @@ export default class TwodsixItem extends Item { } Object.assign(updates, {"system.type": this.type}); - Object.assign(updates, {"flags.twodsix.newItem": true}); await this.updateSource(updates); } diff --git a/src/module/hooks/renderItemSheet.ts b/src/module/hooks/renderItemSheet.ts deleted file mode 100644 index 4d12e4213..000000000 --- a/src/module/hooks/renderItemSheet.ts +++ /dev/null @@ -1,32 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-nocheck This turns off *all* typechecking, make sure to remove this once foundry-vtt-types are updated to cover v10. -import TwodsixItem from "../entities/TwodsixItem"; - -Hooks.on('renderItemSheet', async (app, html) => { - const item = app.item; - - // Check if item was just created - if (item && item.getFlag('twodsix', 'newItem') && !item.uuid.includes('Compendium')) { - // Mark item as no longer being new so that it won't show up when opening the item in the future - await item.unsetFlag('twodsix', 'newItem'); - - const closeAndCreateNew = game.i18n.localize("TWODSIX.CloseAndCreateNew"); - const copyText = game.i18n.localize("TWODSIX.Copy"); - - const closeAndCreateBtn = $(` ${closeAndCreateNew}`); - - closeAndCreateBtn.on("click", async () => { - // close current item sheet - item.sheet?.close(); - - // create new item of same type and show its sheet - const newItem:TwodsixItem = await TwodsixItem.create({name: `${item.name} (${copyText})`, type: item.type}); - - newItem.sheet?.render({force: true}); - }); - - // insert the new button just before the close button - const closeButton = html.closest('.app').find('.header-button.close'); - closeAndCreateBtn.insertBefore(closeButton); - } -});