flamewave000 / dragonflagon-fvtt

DragonFlagon FoundryVTT Modules
BSD 3-Clause "New" or "Revised" License
64 stars 62 forks source link

DF Chat Archive - Unable to access Archive. #416

Open Lukasrygh23 opened 2 years ago

Lukasrygh23 commented 2 years ago

Module DF Chat Enhancements 4.1.0 - Archive feature

Describe the Issue Hi! This module is really useful, but the chat archive feature doesn't seem to work for me.

What steps did you take before experiencing the problem? Steps to reproduce the behavior:

  1. Click on "Archive Chat log" in the chat window
  2. Create a chatlog (any amount of chat selected)
  3. Go to "Manage Chat Archives" in settings
  4. Click any archive in there, including the one just created.

What did you expect to happen? A chatlog to appear that I could access through Foundry.

What happened instead? I recieved an "Unexpected character" error and several other errors, all reproduced below.

Screenshots The Error I got when attempting to open the chatlog originally. The current error. Error with all modules except DF chat disabled. Unsure if this is related but dumping it anyway.

Foundry Versions

What other modules did you have active when experiencing this issue (include both names and versions)? Full list of active modules as of most recent test. Without all modules I get a slightly different error.

Additional context I've tested this on a fresh foundry install and it seems to function, so I'm not quite sure what's causing the incompatability or if it's something in my old chat archives. Full list of active modules as of most recent test.

I used ViNo in V9 but have since disabled and uninstalled it.

I've tested by posting several messages in the recent chat and ONLY archiving those, and it seems to display fine. I can provide the JSON archives creating the errors but would rather not upload publicly, as they contain NSFW content and I don't quite know what github's policy is.

darloth commented 2 years ago

I am experiencing this on a new install with foundry v10, although my error messages are different.

image

The archive in question is a single chat message, although I do have a lot of other modules enabled.

After some further testing, I've determined that it does NOT like spaces in the chat archive name. Perhaps making these into -s instead of %20s would be a good solution here?

darloth commented 2 years ago

Followup comment, mostly to @Lukasrygh23 - if you make a chat archive with no spaces in the name, you can rename it in foundry to something with spaces, using the chat archive rename feature even, and the file on disk will still have no spaces and load fine.

Lukasrygh23 commented 2 years ago

I can create new logs without spaces and they work fine, but I couldn't salvage the old ones even by renaming them to space-less names. Thanks, Darloth!

MrVauxs commented 2 years ago

This seems to be the main issue, given that the first JSON error only appears once.

image

MrVauxs commented 2 years ago

As a note, you can do the following in the console. game.settings.get("df-chat-enhance", "logs") gets you all of the archives data in the module. You can then modify this array of archive objects, and use await game.settings.set("df-chat-enhance", "logs") to apply it. Done properly, it can fix your archives. Will investigate further.

MrVauxs commented 2 years ago

Please note I am not responsible if this breaks your archives. A step by step solution to making your archives work:

  1. Copy paste this into the console.
    let originalSettings = game.settings.get("df-chat-enhance", "logs")
    console.log("These are the original settings", originalSettings)
    originalSettings.map(x => { x.filepath = x.filepath.replaceAll("%20", "%2520").replaceAll("%25%25", "%25"); return x})
    console.log("Modifying the settings to...", originalSettings)
    await game.settings.set("df-chat-enhance", "logs", originalSettings)
  2. Open your archives!

NOTE THAT THIS APPLIES TO ALL ARCHIVES, WORKING OR NOT. WHILE IT SHOULD NOT BREAK ANY ALREADY-WORKING ARCHIVES, IF YOU WANT TO ONLY FIX A SPECIFIC ARCHIVE, YOU NEED TO MODIFY ONLY THAT ARCHIVES originalSettings

You can also use this method to change other attributes, such as names or visibility options, just edit originalSettings and to apply the changes, await game.settings.set("df-chat-enhance", "logs", originalSettings)

guldelox commented 1 year ago

This issue is still occurring... Also happens with newly created archives. At the very least, the ability to name a new archive using spaces should be disabled or prevented in some way so that new archives can't be created like this.

MrVauxs commented 1 year ago

The modules are unmaintained for a while now, and the fix is already made. It's just a matter of updating the module unfortunately.

Geektasticdad commented 1 year ago

Please note I am not responsible if this breaks your archives. A step by step solution to making your archives work:

1. Copy paste this into the console.
let originalSettings = game.settings.get("df-chat-enhance", "logs")
console.log("These are the original settings", originalSettings)
originalSettings.map(x => { x.filepath = x.filepath.replaceAll("%20", "%2520").replaceAll("%25%25", "%25"); return x})
console.log("Modifying the settings to...", originalSettings)
await game.settings.set("df-chat-enhance", "logs", originalSettings)
2. Open your archives!

NOTE THAT THIS APPLIES TO ALL ARCHIVES, WORKING OR NOT. WHILE IT SHOULD NOT BREAK ANY ALREADY-WORKING ARCHIVES, IF YOU WANT TO ONLY FIX A SPECIFIC ARCHIVE, YOU NEED TO MODIFY ONLY THAT ARCHIVES originalSettings

You can also use this method to change other attributes, such as names or visibility options, just edit originalSettings and to apply the changes, await game.settings.set("df-chat-enhance", "logs", originalSettings)

Unfortunately none of these seemed to work in Foundry VTT v11.307 which is unfortunate because this looks like a great module.

LukasPrism commented 10 months ago

Please note I am not responsible if this breaks your archives. A step by step solution to making your archives work:

  1. Copy paste this into the console.
let originalSettings = game.settings.get("df-chat-enhance", "logs")
console.log("These are the original settings", originalSettings)
originalSettings.map(x => { x.filepath = x.filepath.replaceAll("%20", "%2520").replaceAll("%25%25", "%25"); return x})
console.log("Modifying the settings to...", originalSettings)
await game.settings.set("df-chat-enhance", "logs", originalSettings)
  1. Open your archives!

NOTE THAT THIS APPLIES TO ALL ARCHIVES, WORKING OR NOT. WHILE IT SHOULD NOT BREAK ANY ALREADY-WORKING ARCHIVES, IF YOU WANT TO ONLY FIX A SPECIFIC ARCHIVE, YOU NEED TO MODIFY ONLY THAT ARCHIVES originalSettings

You can also use this method to change other attributes, such as names or visibility options, just edit originalSettings and to apply the changes, await game.settings.set("df-chat-enhance", "logs", originalSettings)

Thanks so much for this! I had a mild panic attack last night when I did a fresh archive/delete and didn't know not to use spaces. I can now get into the archive 😅❤️

LukasPrism commented 10 months ago

@MrVauxs sorry to disturb but you're probably the only one able to answer this. I have some old chat archives that are in the archive folder but aren't showing up in the UI. Is there a way I can 'relink' them so they show up in the UI? This is an old world that's been through some migrations, not sure at what point they disappeared.

Thanks again for the above btw.

MrVauxs commented 10 months ago

Yes. You'd have to update the settings to include a new entry linking to the filepath of the archive, or modify an existing one to instead link to that file.

LukasPrism commented 10 months ago

Thanks! Makes sense. The JS to do so is beyond me... but I might try making new archives with the same name and then doing a ninja swap of the archive file.

(Update: that worked!)