Plushtoast / dsa5-foundryVTT

Das Schwarze Auge / The Dark Eye 5th Ed. System for Foundry VTT
Apache License 2.0
74 stars 29 forks source link

Error in DSA/TDE System: Replace folder.data.name with folder.name #1805

Closed mygrexit closed 1 week ago

mygrexit commented 2 weeks ago

Describe the bug

There are console errors in the DSA/TDE system for Foundry VTT related to the use of folder.data.name, which should be updated to folder.name due to updates in Foundry's API. This may cause issues with folder functionalities within the system.

I encountered this bug when I tried to initialize the module Interactive Aventuria Map version 1.0.6.

To Reproduce

Steps to reproduce the behavior:

Expected behavior

The system should initialize without console errors, and all folder operations should function correctly by using the updated property folder.name.

Screenshots

/

Versions:

Additional context

In the initializer.js file, lines 217 to 240, the code currently accesses folder.data.name, which is deprecated in newer versions of Foundry VTT. The correct property should be folder.name. Here is the code and the specific changes:

    if (foldersToCreate) {
      let head = await this.getFolderForType('JournalEntry');
      let headReplace = json.folders[0].name;
      if (head) {
        this.folders[head.data.name] = head;
        json.folders.shift();
      }
      let createdFolders = await Folder.create(foldersToCreate);
      if (!Array.isArray(createdFolders)) createdFolders = [createdFolders];
      for (let folder of createdFolders) this.folders[folder.data.name] = folder;

      const updates = [];
      for (let folder in this.folders) {
        const flag = this.folders[folder].getFlag('dsa5', 'parent');
        let parent = flag == headReplace ? game.i18n.localize(`${this.moduleScope}.name`) : flag;
        if (parent) {
          updates.push({
            _id: this.folders[folder].id,
            parent: this.folders[parent].id,
          });
        }
      }
      await Folder.updateDocuments(updates);
    }
// Current code
this.folders[head.data.name] = head;

// Should be updated to
this.folders[head.name] = head;

// Current code
for (let folder of createdFolders) this.folders[folder.data.name] = folder;

// Should be updated to
for (let folder of createdFolders) this.folders[folder.name] = folder;

I have not checked if this issue occurs in other parts of the codebase, so there may be additional instances where folder.data.name needs to be replaced with folder.name.

Could you please update the code accordingly and release a new version?

All of the above was discovered by Kristov from the League of Extraordinary FoundryVTT Developers Discord while trying to help me get the module up and running.

Arolske commented 6 days ago

Thx for the update.

When I initialize the module all journal entries are placed on the first level without subfolder. It would be nice if the journal entries are placed in a subfolder like "DSA5 Interaktive Aventurienkarte".

fehler

Plushtoast commented 6 days ago

Diese Fragen müssen an den Ersteller des Moduls gehen. Hier sind sie falsch.

Arolske commented 6 days ago

Ich dachte es wäre ein Folgefehler von oben und läge in eurer Hand. Dann geht es an den Ersteller des Moduls.