mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-24 11:01:17 -08:00
fix(msc4459): don't set mxc when there is no data to associate with it
This commit is contained in:
2 files changed
+11
-9
No files matched your search
@@ -1134,11 +1134,10 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
} else {
|
||||
editor.insertNode(emoticonEl);
|
||||
}
|
||||
if (!imagePacksUsedRef.current.has(key))
|
||||
imagePacksUsedRef.current.set(
|
||||
key,
|
||||
getImagePackReferencesForMxc(key, mx, ImageUsage.Emoticon, room)
|
||||
);
|
||||
if (!imagePacksUsedRef.current.has(key)) {
|
||||
const imgPkRef = getImagePackReferencesForMxc(key, mx, ImageUsage.Emoticon, room);
|
||||
if (imgPkRef?.room_id && imgPkRef?.shortcode) imagePacksUsedRef.current.set(key, imgPkRef);
|
||||
}
|
||||
moveCursor(editor);
|
||||
handleCloseAutocomplete();
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ export function getImagePackReferencesForMxcWrappedInMap(
|
||||
if (!mxcUrl.startsWith('mxc')) return retMap;
|
||||
const result = getImagePackReferencesForMxc(mxcUrl, matrixClient, imageUsage, room);
|
||||
// if the result is undefined return the empty map, to not produce invalid entries
|
||||
if (!result?.room_id) return retMap;
|
||||
if (!result?.room_id || !result?.state_key || !result?.shortcode) return retMap;
|
||||
retMap.set(mxcUrl, result);
|
||||
return retMap;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ export function getImagePackReferencesForMxc(
|
||||
roomLookupTable.set(room.roomId, roomLookupTabRes);
|
||||
}
|
||||
// prefer room local match as they're probably often more relevant
|
||||
if (roomLocalMatch) return roomLocalMatch;
|
||||
if (roomLocalMatch?.room_id && roomLocalMatch?.shortcode) return roomLocalMatch;
|
||||
// simple caching
|
||||
if (globalLookupTable.has(mxcUrl)) return globalLookupTable.get(mxcUrl)!;
|
||||
const globalImgPacks: ImagePack[] = getGlobalImagePacks(matrixClient);
|
||||
@@ -101,7 +101,10 @@ export function getImagePackReferencesForMxc(
|
||||
imageUsage,
|
||||
false
|
||||
);
|
||||
if (globalMatch) globalLookupTable.set(mxcUrl, globalMatch);
|
||||
if (globalMatch?.room_id && globalMatch?.shortcode) {
|
||||
globalLookupTable.set(mxcUrl, globalMatch);
|
||||
return globalMatch;
|
||||
}
|
||||
|
||||
return globalMatch ?? {};
|
||||
return {};
|
||||
}
|
||||
Reference in new issue
Block a user