mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-13 10:00:36 +01:00
Add fallback if tag_map is uninitialized
This commit is contained in:
parent
bf8b6b80d7
commit
6a688cc383
@ -339,6 +339,12 @@ export function getTagKeyForEntity(entityOrKey) {
|
|||||||
x = character.avatar;
|
x = character.avatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Uninitialized character tag map
|
||||||
|
if (character && !(x in tag_map)) {
|
||||||
|
tag_map[x] = [];
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
// We should hopefully have a key now. Let's check
|
// We should hopefully have a key now. Let's check
|
||||||
if (x in tag_map) {
|
if (x in tag_map) {
|
||||||
return x;
|
return x;
|
||||||
@ -349,7 +355,7 @@ export function getTagKeyForEntity(entityOrKey) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addTagToMap(tagId, characterId = null) {
|
function addTagToMap(tagId, characterId = null) {
|
||||||
const key = getTagKey() ?? getTagKeyForEntity(characterId);
|
const key = characterId !== null && characterId !== undefined ? getTagKeyForEntity(characterId) : getTagKey();
|
||||||
|
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return;
|
return;
|
||||||
@ -365,7 +371,7 @@ function addTagToMap(tagId, characterId = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeTagFromMap(tagId, characterId = null) {
|
function removeTagFromMap(tagId, characterId = null) {
|
||||||
const key = getTagKey() ?? getTagKeyForEntity(characterId);
|
const key = characterId !== null && characterId !== undefined ? getTagKeyForEntity(characterId) : getTagKey();
|
||||||
|
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user