Skip to content

Commit

Permalink
Upgrade emoji-mart to v3.0.0
Browse files Browse the repository at this point in the history
Also adds migration to convert old emoji set setting to new one.
And removed old emoji sets from doc/Readme etc.
  • Loading branch information
rugk committed Mar 19, 2020
1 parent 45af80a commit 0b77bec
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 55 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ It uses up-to-date Emojis and let's you access your Emojis in different styles y
* Apple emojis
* Google emojis
* Twitter emojis ([Twemoji](https://twemoji.twitter.com/))
* EmojiOne emojis (now [JoyPixels](https://www.joypixels.com/))
* Facebook emojis
* or just what your system/browser offers (e.g. on Windows thus Windows emojis will be used)

It is based on the awesome [emoji-mart](https://missive.github.io/emoji-mart/). You can test many features there already, before installing it.
Expand Down Expand Up @@ -49,7 +49,7 @@ See:

## Features

* Display the emojis in the design of Apple, Google, Twitter, EmojiOne or just the native style your browser uses.
* Display the emojis in the design of Apple, Google, Twitter, Facebook or just the native style your browser uses.
* Quickly search for any emoji with many keywords.
* Search for emojis [directly in the address bar](https://github.com/rugk/awesome-emoji-picker/wiki/FAQ#how-to-use-the-address-bar-to-search-for-emojis).
* Supports the dark/black mode of your system automatically.
Expand Down
4 changes: 2 additions & 2 deletions assets/texts/de/amoDescription.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<li>Apple-Emojis</li>
<li>Google-Emojis</li>
<li>Twitter-Emojis (<a href="https://twemoji.twitter.com/">Twemoji</a>)</li>
<li>EmojiOne-Emojis (jetzt <a href="https://www.joypixels.com/">JoyPixels</a>)</li>
<li>Facebook-Emojis</li>
<li>oder einfach das, was das System/der Browser anbietet (auf Windows werden beispielsweise Windows Emojis genutzt)</li>
</ul>

Expand All @@ -30,7 +30,7 @@

<b>📢 Weitere Features 📢</b>
<ul>
<li>Zeige die Emojis im Design von Apple, Google, Twitter, EmojiOne oder einfach dem nativen Stil, den der Browser nutzt, an.</li>
<li>Zeige die Emojis im Design von Apple, Google, Twitter, Facebook oder einfach dem nativen Stil, den der Browser nutzt, an.</li>
<li>Suche jedes Emoji mit verschiedenen Stichwörtern.</li>
<li>Such nach Emojis <a href="https://github.com/rugk/awesome-emoji-picker/wiki/FAQ-(deutsch)#wie-kann-ich-die-adressleiste-nutzen-um-emojis-zu-suchen">direkt in der Addressleiste</a>.</li>
<li>Unterstützt automatisch den dunklen/schwarzen Modus deines Systems.</li>
Expand Down
4 changes: 2 additions & 2 deletions assets/texts/en/amoDescription.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<li>Apple emojis</li>
<li>Google emojis</li>
<li>Twitter emojis (<a href="https://twemoji.twitter.com/">Twemoji</a>)</li>
<li>EmojiOne emojis (now <a href="https://www.joypixels.com/">JoyPixels</a>)</li>
<li>Facebook emojis</li>
<li>or just what your system/browser offers (e.g. on Windows thus Windows emojis will be used)</li>
</ul>

Expand All @@ -30,7 +30,7 @@

<b>📢 More Features 📢</b>
<ul>
<li>Display the emojis in the design of Apple, Google, Twitter, EmojiOne or just the native style your browser uses.</li>
<li>Display the emojis in the design of Apple, Google, Twitter, Facebook or just the native style your browser uses.</li>
<li>Quickly search for any emoji with various keywords.</li>
<li>Search for emojis <a href="https://github.com/rugk/awesome-emoji-picker/wiki/FAQ#how-to-use-the-address-bar-to-search-for-emojis">directly in the address bar</a>.</li>
<li>Supports the dark/black mode of your system automatically.</li>
Expand Down
4 changes: 2 additions & 2 deletions assets/texts/fr/amoDescription.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<li>Emojis Apple</li>
<li>Emojis Google</li>
<li>Emojis Twitter (<a href="https://twemoji.twitter.com/">Twemoji</a>)</li>
<li>Emojis EmojiOne (maintenant <a href="https://www.joypixels.com/">JoyPixels</a>)</li>
<li>Emojis Facebook</li>
<li>ou tout simplement ce que votre OS/navigateur fournit (c.à.d. the emojis Windows seront disponible sur une plateforme Windows)</li>
</ul>

Expand All @@ -30,7 +30,7 @@

<b>📢 D'autres fonctionnalités 📢</b>
<ul>
<li>Affichage des emojis dans le style d'Apple, Google, Twitter, EmojiOne ou tout simplement ce que votre navigateur utilise.</li>
<li>Affichage des emojis dans le style d'Apple, Google, Twitter, Facebook ou tout simplement ce que votre navigateur utilise.</li>
<li>Recherche rapide d'un émoticône avec différents mots-clés.</li>
<li>Recherchez des émojis <a href="https://github.com/rugk/awesome-emoji-picker/wiki/FAQ#how-to-use-the-address-bar-to-search-for-emojis">directement dans la barre d'adresse</a>.</li>
<li>Prend en charge le thème sombre de votre système automatiquement.</li>
Expand Down
4 changes: 2 additions & 2 deletions scripts/downloadEmojiImages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
# hardcoded
USER_AGENT="awesome-emoji-picker browser add-on build script (https://github.com/rugk/awesome-emoji-picker)"
SHEET_SIZE="64" # px emojis
EMOJI_SETS="apple google twitter emojione messenger facebook"
EMOJI_SETS="apple google twitter facebook"
STORAGE_DIRECTORY="./src/popup/img/emoji-images"

# default
emojiDataSourceVersion="4.0.4"
emojiDataSourceVersion="5.0.1"
test -n "$1" && emojiDataSourceVersion="$1" && echo "Using version $emojiDataSourceVersion for emoji-datasource."

for set in $EMOJI_SETS; do
Expand Down
8 changes: 0 additions & 8 deletions src/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,6 @@
"message": "Twitter",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation."
},
"optionEmojiSetEmojiOne": {
"message": "EmojiOne",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation."
},
"optionEmojiSetMessenger": {
"message": "Facebook Messenger",
"description": "Option of the emoji set. This is a product name and should thus, usually, not translated. Only translate if it's the official product translation."
},
"optionEmojiSetFacebook": {
"message": "Facebook",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation."
Expand Down
8 changes: 0 additions & 8 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,6 @@
"message": "Twitter",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation."
},
"optionEmojiSetEmojiOne": {
"message": "EmojiOne",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation."
},
"optionEmojiSetMessenger": {
"message": "Facebook Messenger",
"description": "Option of the emoji set. This is a product name and should thus, usually, not translated. Only translate if it's the official product translation."
},
"optionEmojiSetFacebook": {
"message": "Facebook",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation."
Expand Down
8 changes: 0 additions & 8 deletions src/_locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,6 @@
"message": "Twitter",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation."
},
"optionEmojiSetEmojiOne": {
"message": "EmojiOne",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation."
},
"optionEmojiSetMessenger": {
"message": "Facebook Messenger",
"description": "Option of the emoji set. This is a product name and should thus, usually, not translated. Only translate if it's the official product translation."
},
"optionEmojiSetFacebook": {
"message": "Facebook",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation."
Expand Down
8 changes: 0 additions & 8 deletions src/_locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,6 @@
"message": "Twitter",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation."
},
"optionEmojiSetEmojiOne": {
"message": "EmojiOne",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation."
},
"optionEmojiSetMessenger": {
"message": "Messenger Facebook",
"description": "Option of the emoji set. This is a product name and should thus, usually, not translated. Only translate if it's the official product translation."
},
"optionEmojiSetFacebook": {
"message": "Facebook",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation."
Expand Down
10 changes: 0 additions & 10 deletions src/_locales/he/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,6 @@
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation.",
"hash": "3bae8ce17ed128fd3ccc45099b57e13c"
},
"optionEmojiSetEmojiOne": {
"message": "EmojiOne",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation.",
"hash": "8896cf25d4675a99c82ce26b7b7edda2"
},
"optionEmojiSetMessenger": {
"message": "Facebook Messenger",
"description": "Option of the emoji set. This is a product name and should thus, usually, not translated. Only translate if it's the official product translation.",
"hash": "52d9dc17de52e4b96ef7feede7ca8fad"
},
"optionEmojiSetFacebook": {
"message": "Facebook",
"description": "Option of the emoji set. This is a company name and should thus, usually, not translated. Only translate if it's the official company translation.",
Expand Down
2 changes: 2 additions & 0 deletions src/background/background.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<html lang="en">
<head>
<meta charset="utf-8">
<!-- async currently disabled, because of https://bugzilla.mozilla.org/show_bug.cgi?id=1506464 -->
<script src="./modules/InstallUpgrade.js" type="module" charset="utf-8"></script>
<script async src="background.js" type="module" charset="utf-8"></script>
</head>
<body>
Expand Down
75 changes: 75 additions & 0 deletions src/background/modules/InstallUpgrade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* Upgrades user data on installation of new updates.
*
* Attention: Currently you must not include this script asyncronously. See
* https://bugzilla.mozilla.org/show_bug.cgi?id=1506464 for details.
*
* @module InstallUpgrade
*/

/**
* Upgrade the emoji sets to replaced removed/deprecated ones.
*
* @private
* @param {Object} emojiPickerSettings
* @returns {Promise}
*/
async function upgradeEmojiSet(emojiPickerSettings) {
// change removed emoji sets to best existing one
switch (emojiPickerSettings.set) {
case "emojione": // removed in v3.0.0 of emoji-mart https://github.com/missive/emoji-mart/blob/master/CHANGELOG.md#v300
emojiPickerSettings.set = "twitter"; // upgrade set from EmojiOne to Twitter
emojiPickerSettings.setMigratedToTwitterFrom = "emojione"; // save old setting to be able to return to that later
break;
case "messenger": // removed in v3.0.0 of emoji-mart https://github.com/missive/emoji-mart/blob/master/CHANGELOG.md#v300
emojiPickerSettings.set = "facebook"; // upgrade set from Messenger to Facebook
emojiPickerSettings.setMigratedToFacebookFrom = "messenger"; // save old setting to be able to return to that later
break;
default: // no upgrade needed
// eslint-disable-next-line no-case-declarations
const text = "No emoji set upgrade needed.";
console.log(text);
return Promise.reject(new Error(text));
}

console.log("Doing emoji set upgrade.");
await browser.storage.sync.set({
emojiPicker: emojiPickerSettings
});

console.info("Emoji set upgrade successful.", await browser.storage.sync.get());
return Promise.resolve();
}

/**
* Checks whether an upgrade is needed.
*
* @see {@link https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onInstalled}
* @private
* @param {Object} details
* @returns {Promise}
*/
async function handleInstalled(details) {
// only trigger for usual addon updates
if (details.reason !== "update") {
return;
}

console.log(`Doing upgrade from ${details.previousVersion}.`, details);
const oldData = await browser.storage.sync.get();

// ignore returned promise, because it just carries the update status and is already logged
upgradeEmojiSet(oldData.emojiPicker).catch(() => {});
}

/**
* Inits module.
*
* @private
* @returns {void}
*/
function init() {
browser.runtime.onInstalled.addListener(handleInstalled);
}

init();
2 changes: 0 additions & 2 deletions src/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ <h1 data-i18n="__MSG_titleAppearance__">Appearance</h1>
<option data-i18n="__MSG_optionEmojiSetApple__" value="apple">Apple</option>
<option data-i18n="__MSG_optionEmojiSetGoogle__" value="google">Google</option>
<option data-i18n="__MSG_optionEmojiSetTwitter__" value="twitter">Twitter</option>
<option data-i18n="__MSG_optionEmojiSetEmojiOne__" value="emojione">EmojiOne</option>
<option data-i18n="__MSG_optionEmojiSetMessenger__" value="messenger">Facebook Messenger</option>
<option data-i18n="__MSG_optionEmojiSetFacebook__" value="facebook">Facebook</option>
</select>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/popup/module/EmojiPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const hardcodedSettings = Object.freeze({
onSelect: EmojiSelect.triggerOnSelect,
onClick: EmojiSelect.saveClickPosition,
style: { "border": "none" },
theme: "auto",
backgroundImageFn: getEmojiSheet,
title: browser.i18n.getMessage("extensionNameShort"), // show the extension name by default
emoji: "star-struck" // default emoji
Expand Down

0 comments on commit 0b77bec

Please sign in to comment.