chore: final cleanup

This commit is contained in:
Subarashimo
2025-12-05 18:10:21 +01:00
parent 38328de1bf
commit 7e47dbfd7c
29 changed files with 338 additions and 2168 deletions
-4
View File
@@ -14,9 +14,7 @@ import { getThumbnailUrl } from '../../../../../../script.js';
* @returns {string|null} Thumbnail URL or null if unavailable/error
*/
export function getSafeThumbnailUrl(type, filename) {
// Return null if no filename provided
if (!filename || filename === 'none') {
// console.log(`[RPG Companion] No valid filename provided for ${type} thumbnail`);
return null;
}
@@ -24,13 +22,11 @@ export function getSafeThumbnailUrl(type, filename) {
// Attempt to get thumbnail URL from SillyTavern API
const url = getThumbnailUrl(type, filename);
// Validate that we got a string back
if (typeof url !== 'string' || url.trim() === '') {
console.warn(`[RPG Companion] getThumbnailUrl returned invalid result for ${type}:`, filename);
return null;
}
// console.log(`[RPG Companion] Successfully generated ${type} thumbnail URL for: ${filename}`);
return url;
} catch (error) {
// Log detailed error information for debugging
-9
View File
@@ -27,9 +27,7 @@ const DEFAULT_INVENTORY_V2 = {
* @returns {MigrationResult} Migration result with v2 inventory and metadata
*/
export function migrateInventory(inventory) {
// Case 1: Already v2 format (has version property and is an object)
if (inventory && typeof inventory === 'object' && inventory.version === 2) {
// console.log('[RPG Companion Migration] Inventory already v2, no migration needed');
return {
inventory: inventory,
migrated: false,
@@ -37,9 +35,7 @@ export function migrateInventory(inventory) {
};
}
// Case 2: null or undefined → use defaults
if (inventory === null || inventory === undefined) {
// console.log('[RPG Companion Migration] Inventory is null/undefined, using defaults');
return {
inventory: { ...DEFAULT_INVENTORY_V2 },
migrated: true,
@@ -47,12 +43,9 @@ export function migrateInventory(inventory) {
};
}
// Case 3: v1 string format → migrate to v2
if (typeof inventory === 'string') {
// Check if it's an empty/default string
const trimmed = inventory.trim();
if (trimmed === '' || trimmed.toLowerCase() === 'none') {
// console.log('[RPG Companion Migration] Inventory is empty/None, using defaults');
return {
inventory: { ...DEFAULT_INVENTORY_V2 },
migrated: true,
@@ -60,8 +53,6 @@ export function migrateInventory(inventory) {
};
}
// Non-empty v1 string → migrate to v2.onPerson
// console.log('[RPG Companion Migration] Migrating v1 string to v2.onPerson:', inventory);
return {
inventory: {
version: 2,