diff --git a/_locales/en/messages.json b/_locales/en/messages.json index a58162586..b01a94281 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1835,6 +1835,25 @@ "message": "Sticker Pack", "description": "The title that appears in the sticker pack preview modal." }, + "EmojiPicker--empty": { + "message": "No emoji found", + "description": "Shown in the emoji picker when a search yields 0 results." + }, + "EmojiPicker--search-placeholder": { + "message": "Search Emoji", + "description": + "Shown as a placeholder inside the emoji picker search field." + }, + "EmojiPicker--skin-tone": { + "message": "Skin tone $tone$", + "placeholders": { + "status": { + "content": "$1", + "example": "2" + } + }, + "description": "Shown as a tooltip over the emoji tone buttons." + }, "confirmation-dialog--Cancel": { "message": "Cancel", "description": "Appears on the cancel button in confirmation dialogs." diff --git a/app/sql.js b/app/sql.js index 2197d32fb..3df186023 100644 --- a/app/sql.js +++ b/app/sql.js @@ -123,6 +123,9 @@ module.exports = { getAllStickers, getRecentStickers, + updateEmojiUsage, + getRecentEmojis, + removeAll, removeAllConfiguration, @@ -735,6 +738,29 @@ async function updateToSchemaVersion13(currentVersion, instance) { console.log('updateToSchemaVersion13: success!'); } +async function updateToSchemaVersion14(currentVersion, instance) { + if (currentVersion >= 14) { + return; + } + + console.log('updateToSchemaVersion14: starting...'); + await instance.run('BEGIN TRANSACTION;'); + + await instance.run(`CREATE TABLE emojis( + shortName STRING PRIMARY KEY, + lastUsage INTEGER + );`); + + await instance.run(`CREATE INDEX emojis_lastUsage + ON emojis ( + lastUsage + );`); + + await instance.run('PRAGMA schema_version = 14;'); + await instance.run('COMMIT TRANSACTION;'); + console.log('updateToSchemaVersion14: success!'); +} + const SCHEMA_VERSIONS = [ updateToSchemaVersion1, updateToSchemaVersion2, @@ -749,6 +775,7 @@ const SCHEMA_VERSIONS = [ updateToSchemaVersion11, updateToSchemaVersion12, updateToSchemaVersion13, + updateToSchemaVersion14, ]; async function updateSchema(instance) { @@ -2182,6 +2209,43 @@ async function getRecentStickers({ limit } = {}) { return rows || []; } +// Emojis +async function updateEmojiUsage(shortName, timeUsed = Date.now()) { + await db.run('BEGIN TRANSACTION;'); + + const rows = await db.get( + 'SELECT * FROM emojis WHERE shortName = $shortName;', + { + $shortName: shortName, + } + ); + + if (rows) { + await db.run( + 'UPDATE emojis SET lastUsage = $timeUsed WHERE shortName = $shortName;', + { $shortName: shortName, $timeUsed: timeUsed } + ); + } else { + await db.run( + 'INSERT INTO emojis(shortName, lastUsage) VALUES ($shortName, $timeUsed);', + { $shortName: shortName, $timeUsed: timeUsed } + ); + } + + await db.run('COMMIT TRANSACTION;'); +} + +async function getRecentEmojis(limit = 32) { + const rows = await db.all( + 'SELECT * FROM emojis ORDER BY lastUsage DESC LIMIT $limit;', + { + $limit: limit, + } + ); + + return rows || []; +} + // All data in database async function removeAll() { let promise; diff --git a/background.html b/background.html index ced91eeb6..d36ab91d8 100644 --- a/background.html +++ b/background.html @@ -112,12 +112,11 @@