p4535992 / foundryvtt-pin-cushion

Adds additional functionality around Map Pins
GNU General Public License v3.0
3 stars 6 forks source link

[BUG] Imported notes without `pin-cushion` flags are invisible since v1.8.33 #73

Closed Felerius closed 1 year ago

Felerius commented 1 year ago

Module Version: v1.8.33

Describe the bug All map notes imported from an imported adventure turned invisible after the v1.8.33 update. While debugging, I found out that all of these were missing the pin-cushion key in their flags. Copying the pin-cushion flags from a working map note via the Javascript console turned the notes visible again.

To Reproduce Steps to reproduce the behavior:

  1. Go to the Javascript console and get a reference to some map note note.
  2. Run note.update({'flags.-=pin-cushion': null}) to delete the pin-cushion flags key.
  3. The note be invisible

Expected behavior The notes should be visible, either by assuming some default values or applying a migration to notes without these flags.

Browser: Chrome 113

Foundry Version: 10.291

Game System: Pathfinder 2e

p4535992 commented 1 year ago

Try to patch this on on 1.8.34 . If the issue persist uncheck the module setting "Enable Journal Anchor Links Feature". Let me know it.

Felerius commented 1 year ago

Disabling "Enable Journal Anchor Links Feature" doesn't seem to fix it unfortunately. For now, I've been using this macro to fix all notes in the current scene, which seems to work well at least for my case:

const DEFAULT_FLAGS = {
    "gmNote": "",
    "showImage": false,
    "showImageExplicitSource": "",
    "pinIsTransparent": false,
    "showOnlyToGM": false,
    "hasBackground": false,
    "ratio": 1,
    "textAlwaysVisible": false,
    "hideLabel": false,
    "doNotShowJournalPreview": true,
    "previewAsTextSnippet": false,
    "tooltipPlacement": "e",
    "tooltipColor": "",
    "tooltipForceRemove": false,
    "tooltipSmartPlacement": false
};

const notes = Array.from(canvas.scene.notes.values());
const updates = notes
    .map(note => {
        const newFlags = foundry.utils.mergeObject(
            note.flags["pin-cushion"] ?? {},
            DEFAULT_FLAGS,
            {
                insertKeys: true,
                insertValues: true,
                overwrite: false,
                recursive: true,
            }
        );
        return {
            _id: note.id,
            "flags.pin-cushion": newFlags,
        };
    });

await canvas.scene.updateEmbeddedDocuments("Note", updates);
p4535992 commented 1 year ago

k now i'm sure i really fixed on 1.8.35

Felerius commented 1 year ago

It works! Thanks a ton for the super quick response!