|
9 | 9 | GameWorldTimeIntegrations, |
10 | 10 | Icons, |
11 | 11 | LeapYearRules, |
| 12 | + LegacyModuleName, |
12 | 13 | ModuleName, |
13 | 14 | MoonYearResetOptions, |
14 | 15 | NoteReminderNotificationType, |
@@ -1854,13 +1855,24 @@ export default class ConfigurationApp extends FormApplication { |
1854 | 1855 | const calendarId = (newCalId || importCalendar?.id || calId).replace("_temp", ""); |
1855 | 1856 | for (let n = 0; n < data.notes[calId].length; n++) { |
1856 | 1857 | const journalEntryData = data.notes[calId][n]; |
1857 | | - const noteImportedIntoDifferentCalendar = !(journalEntryData.flags[ModuleName].noteData.calendarId === calendarId); |
1858 | | - journalEntryData.flags[ModuleName].noteData.calendarId = calendarId; |
1859 | | - journalEntryData.folder = NManager.noteDirectory?.id; |
1860 | | - if (noteImportedIntoDifferentCalendar || !(<Game>game).journal?.has(journalEntryData._id)) { |
1861 | | - await JournalEntry.create(journalEntryData, { keepId: !noteImportedIntoDifferentCalendar }); |
1862 | | - } else { |
1863 | | - (<Game>game).journal?.get(journalEntryData._id)?.update(journalEntryData); |
| 1858 | + const noteData = journalEntryData.flags[ModuleName]?.noteData || journalEntryData.flags[LegacyModuleName]?.noteData; |
| 1859 | + if (noteData) { |
| 1860 | + const noteImportedIntoDifferentCalendar = !(noteData.calendarId === calendarId); |
| 1861 | + // add logic to determine if this entry came from the original version of SC, and if so, convert it to the new format |
| 1862 | + const isConverted = !journalEntryData.flags[ModuleName]; |
| 1863 | + if (isConverted) { |
| 1864 | + journalEntryData.flags[ModuleName] = journalEntryData.flags[LegacyModuleName]; |
| 1865 | + journalEntryData.flags["core"].sheetClass = ModuleName + ".NoteSheet"; |
| 1866 | + journalEntryData.flags[LegacyModuleName] = undefined; |
| 1867 | + } else journalEntryData.flags[ModuleName].noteData = noteData; |
| 1868 | + |
| 1869 | + journalEntryData.flags[ModuleName].noteData.calendarId = calendarId; |
| 1870 | + journalEntryData.folder = NManager.noteDirectory?.id; |
| 1871 | + if (noteImportedIntoDifferentCalendar || !(<Game>game).journal?.has(journalEntryData._id) || isConverted) { |
| 1872 | + await JournalEntry.create(journalEntryData, { keepId: !noteImportedIntoDifferentCalendar }); |
| 1873 | + } else { |
| 1874 | + (<Game>game).journal?.get(journalEntryData._id)?.update(journalEntryData); |
| 1875 | + } |
1864 | 1876 | } |
1865 | 1877 | } |
1866 | 1878 | } |
|
0 commit comments