Skip to content

fix: ship the Space emoji list with the app so the picker works offline - #2193

Draft
Douglasymlai wants to merge 1 commit into
mainfrom
fix/bundled-emoji-data
Draft

Douglasymlai wants to merge 1 commit into
mainfrom
fix/bundled-emoji-data

Conversation

@Douglasymlai

Copy link
Copy Markdown
Contributor

Problem

The Space emoji picker downloads its emoji list from a CDN the first time it opens. Offline, or on a network that cannot reach that CDN, the picker shows "Couldn't load emoji" and no emoji can be chosen.

Cause

The picker was pointed at cdn.jsdelivr.net for its data and the app carried no copy of its own.

Fix

The app now ships the list.

  • emojibase-data is a dev dependency, pinned to 18.0.0 (MIT). A small Vite plugin copies the list and its labels for the picker's ten languages next to index.html on build (about 8 MB), and serves the same files from the dev server. It is used by both the desktop and the web config.
  • The picker reads that copy. Only if it cannot be read does it ask the CDN, pinned to the same version, and it logs a console warning when it does.
  • A build stops with a clear message if the lists are missing, so a release cannot ship without them. The dev server only warns.

No visual change.

Test fixture: buildConfig.test.ts builds from a copy of the Vite config, so it now copies the two modules the config imports. It also copies one source file the fixture was missing, which made two of its tests fail on main.

Testing

  • vitest run test/unit/shared/emojiData.test.ts test/unit/components/Home test/unit/electron/buildConfig.test.ts: 16 files, 112 tests passed.
    • The build test runs a real vite build on a fixture and checks that dist/emojibase/en/data.json and dist/emojibase/zh-hant/messages.json exist.
    • The picker tests check that the bundled list is read first, that the CDN is asked only after that fails, that a read the picker stopped does not reach the CDN, and that the CDN version matches package.json.
  • npm run type-check and ESLint on the changed files pass.

Not verified: the picker has not been opened in a packaged app. To check, open a Space's emoji picker with the network off; the emoji should appear and the console should not show Could not read the bundled emoji list.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant