- {(!isMediaReady || (isVideo && !canDisplayVideo)) && (
-

- )}
- {!isLottie && !isVideo && (
-

- )}
- {isVideo && canDisplayVideo && isMediaReady && (
-
- )}
- {isLottie && isMediaLoaded && (
-
- )}
- {hasEffect && shouldLoad && isPlayingEffect && (
+
+
+ {hasEffect && canLoad && isPlayingEffect && (
id !== stickerSetId);
}
- const customEmojiById = isCustomEmoji && currentStickerSet.stickers
- && buildCollectionByKey(currentStickerSet.stickers, 'id');
+ const customEmojiById = isCustomEmoji && update.stickers && buildCollectionByKey(update.stickers, 'id');
return {
...global,
diff --git a/src/hooks/useEnsureCustomEmoji.ts b/src/hooks/useEnsureCustomEmoji.ts
index 16b30b93e..de3ffb145 100644
--- a/src/hooks/useEnsureCustomEmoji.ts
+++ b/src/hooks/useEnsureCustomEmoji.ts
@@ -21,13 +21,18 @@ const updateLastRendered = throttle(() => {
RENDER_HISTORY.clear();
}, THROTTLE, false);
-export default function useEnsureCustomEmoji(id: string) {
- RENDER_HISTORY.add(id);
+export function notifyCustomEmojiRender(emojiId: string) {
+ RENDER_HISTORY.add(emojiId);
updateLastRendered();
+}
+
+export default function useEnsureCustomEmoji(id: string) {
+ notifyCustomEmojiRender(id);
if (getGlobal().customEmojis.byId[id]) {
return;
}
+
LOAD_QUEUE.add(id);
loadFromQueue();
}
diff --git a/src/util/customEmojiManager.ts b/src/util/customEmojiManager.ts
index 2d4512669..5b962724f 100644
--- a/src/util/customEmojiManager.ts
+++ b/src/util/customEmojiManager.ts
@@ -1,18 +1,23 @@
import { ApiMediaFormat } from '../api/types';
import { getStickerPreviewHash } from '../global/helpers';
+import { notifyCustomEmojiRender } from '../hooks/useEnsureCustomEmoji';
import * as mediaLoader from './mediaLoader';
import { throttle } from './schedulers';
const DOM_PROCESS_THROTTLE = 500;
function processDomForCustomEmoji() {
- const emojis = document.querySelectorAll('img[data-document-id]:not([src])');
+ const emojis = document.querySelectorAll('.custom-emoji.placeholder');
emojis.forEach((emoji) => {
- const mediaHash = getStickerPreviewHash(emoji.dataset.documentId!);
+ const emojiId = emoji.dataset.documentId!;
+ const mediaHash = getStickerPreviewHash(emojiId);
const mediaData = mediaLoader.getFromMemory(mediaHash);
if (mediaData) {
emoji.src = mediaData;
+ emoji.classList.remove('placeholder');
+
+ notifyCustomEmojiRender(emojiId);
}
});
}
@@ -23,6 +28,7 @@ export function getCustomEmojiPreviewMediaData(emojiId: string) {
const mediaHash = getStickerPreviewHash(emojiId);
const data = mediaLoader.getFromMemory(mediaHash);
if (data) {
+ notifyCustomEmojiRender(emojiId);
return data;
}