Skip to content

Make data store overridable again (for saving frequently used emojis and skin) + maybe make it asycronous? #987

@rugk

Description

@rugk

Old functionality

In the old pre-rewrite/pre-5.0 way, you could override the data store,

/**
 * Sets the emoji-mart data storage.
 *
 * @private
 * @returns {Promise<void>}
 * @see https://github.com/missive/emoji-mart#storage
 */
export async function initEmojiMartStorage() {
    // get saved values
    emojiMartStorage = await AddonSettings.get("emojiMart");

    globalThis.emojiMart.setDataStore({
        getter: (key) => {
            return emojiMartStorage[key];
        },

        setter: (key, value) => {
            emojiMartStorage[key] = value;

            // and actually save the new value
            // and return promise so async things are noticed
            return AddonSettings.set("emojiMart", emojiMartStorage);
        }
    });
}

taken from here.

See https://github.com/missive/emoji-mart/tree/v2.10.0?tab=readme-ov-file#storage for the old documentation. It said:

By default EmojiMart will store user chosen skin and frequently used emojis in localStorage.

New v5 implementation

Now looking for the same functionality in v5 I am a little lost but searching through the code I can see at least the skin is still read from it:

skin: Store.get('skin') || props.skin,

And frequently used, too, so hmm. But I am unsure and there is no doc on how to overwrite the storage method. I doubt this is really possible at all, especially in the compiled versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions