Only preload emoji after the window is fully loaded
This commit is contained in:
parent
18d59bfa47
commit
102b93241c
3 changed files with 20 additions and 15 deletions
|
@ -37,6 +37,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
// Load these images now to ensure that they don't flicker on first use
|
// Load these images now to ensure that they don't flicker on first use
|
||||||
|
window.Signal.EmojiLib.preloadImages();
|
||||||
const images = [];
|
const images = [];
|
||||||
function preload(list) {
|
function preload(list) {
|
||||||
for (let index = 0, max = list.length; index < max; index += 1) {
|
for (let index = 0, max = list.length; index < max; index += 1) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ const Data = require('./data');
|
||||||
const Database = require('./database');
|
const Database = require('./database');
|
||||||
const Emojis = require('./emojis');
|
const Emojis = require('./emojis');
|
||||||
const Emoji = require('../../ts/util/emoji');
|
const Emoji = require('../../ts/util/emoji');
|
||||||
|
const EmojiLib = require('../../ts/components/emoji/lib');
|
||||||
const IndexedDB = require('./indexeddb');
|
const IndexedDB = require('./indexeddb');
|
||||||
const Notifications = require('../../ts/notifications');
|
const Notifications = require('../../ts/notifications');
|
||||||
const OS = require('../../ts/OS');
|
const OS = require('../../ts/OS');
|
||||||
|
@ -335,6 +336,7 @@ exports.setup = (options = {}) => {
|
||||||
Database,
|
Database,
|
||||||
Emojis,
|
Emojis,
|
||||||
Emoji,
|
Emoji,
|
||||||
|
EmojiLib,
|
||||||
IndexedDB,
|
IndexedDB,
|
||||||
LinkPreviews,
|
LinkPreviews,
|
||||||
Metadata,
|
Metadata,
|
||||||
|
|
|
@ -72,14 +72,15 @@ const makeImagePath = (src: string) => {
|
||||||
|
|
||||||
export const images = new Set();
|
export const images = new Set();
|
||||||
|
|
||||||
// Preload images
|
export const preloadImages = () => {
|
||||||
const preload = (src: string) => {
|
// Preload images
|
||||||
|
const preload = (src: string) => {
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
img.src = src;
|
img.src = src;
|
||||||
images.add(img);
|
images.add(img);
|
||||||
};
|
};
|
||||||
|
|
||||||
data.forEach(emoji => {
|
data.forEach(emoji => {
|
||||||
preload(makeImagePath(emoji.image));
|
preload(makeImagePath(emoji.image));
|
||||||
|
|
||||||
if (emoji.skin_variations) {
|
if (emoji.skin_variations) {
|
||||||
|
@ -87,7 +88,8 @@ data.forEach(emoji => {
|
||||||
preload(makeImagePath(variation.image));
|
preload(makeImagePath(variation.image));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const dataByShortName = keyBy(data, 'short_name');
|
export const dataByShortName = keyBy(data, 'short_name');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue