Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

fix: cannot switch locale #275

Open
wants to merge 1 commit into
base: release/v5.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/picmo/src/createPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function initData(options: PickerOptions): Promise<DataStore> {
let pickerIndex = 0;

let emojiDataPromise;
let __lastLocale__;

function getPickerId() {
return `picmo-${Date.now()}-${pickerIndex++}`;
Expand All @@ -41,8 +42,11 @@ export function createPicker(options: Partial<PickerOptions>): EmojiPicker {
}));

const events = new AppEvents();
if (!emojiDataPromise) {

const isLocaleChange = __lastLocale__ !== finalOptions.locale
if (!emojiDataPromise || isLocaleChange) {
emojiDataPromise = initData(finalOptions);
__lastLocale__ = finalOptions.locale
}

const i18n = new Bundle(finalOptions.i18n);
Expand Down