From fe65fd3eaac70024f57a67bacc77315876df3206 Mon Sep 17 00:00:00 2001 From: Ken Powers Date: Thu, 19 Dec 2019 18:27:02 -0500 Subject: [PATCH] Sticker creator updates: new 200 sticker max, WebP supported --- _locales/en/messages.json | 17 ++++++++++++++- js/modules/web_api.js | 22 +++++++++++--------- package.json | 15 ++++++++++---- sticker-creator/app/stages/AppStage.scss | 6 ++++++ sticker-creator/app/stages/AppStage.tsx | 9 ++++++++ sticker-creator/app/stages/DropStage.tsx | 21 ++++++++++++++++++- sticker-creator/app/stages/MetaStage.tsx | 10 ++++++--- sticker-creator/components/StickerGrid.tsx | 2 +- sticker-creator/elements/DropZone.tsx | 2 +- sticker-creator/elements/Typography.scss | 10 +++++++++ sticker-creator/elements/Typography.tsx | 11 +++++++++- sticker-creator/preload.js | 16 +++++++++++---- sticker-creator/store/ducks/stickers.ts | 24 +++++++++++++++++++--- sticker-creator/util/preload.ts | 3 +++ yarn.lock | 11 ++++++++-- 15 files changed, 148 insertions(+), 31 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index e520ce83a..ee1eeea28 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -2212,7 +2212,7 @@ }, "StickerCreator--DropStage--help": { "message": - "Stickers must be in PNG format with a transparent background and 512x512 pixels. Recommended margin is 16px.", + "Stickers must be in PNG or WebP format with a transparent background and 512x512 pixels. Recommended margin is 16px.", "description": "Help text for the drop stage of the sticker creator" }, "StickerCreator--DropStage--showMargins": { @@ -2220,6 +2220,16 @@ "description": "Text for the show margins toggle on the drop stage of the sticker creator" }, + "StickerCreator--DropStage--addMore": { + "message": "Add $count$ or more", + "description": "Text to show user how many more stickers they must add", + "placeholders": { + "hashtag": { + "content": "$1", + "example": "4" + } + } + }, "StickerCreator--EmojiStage--title": { "message": "Add an emoji to each sticker", "description": "Title for the drop stage of the sticker creator" @@ -2340,6 +2350,11 @@ } } }, + "StickerCreator--Toasts--animated": { + "message": "Animated stickers are not currently supported", + "description": + "Text for the toast when an image that is animated was dropped" + }, "StickerCreator--Toasts--tooLarge": { "message": "Dropped image is too large", "description": diff --git a/js/modules/web_api.js b/js/modules/web_api.js index 425689131..419f99390 100644 --- a/js/modules/web_api.js +++ b/js/modules/web_api.js @@ -6,7 +6,7 @@ const { Agent } = require('https'); const is = require('@sindresorhus/is'); const { redactPackId } = require('./stickers'); -/* global Signal, Buffer, setTimeout, log, _, getGuid */ +/* global Signal, Buffer, setTimeout, log, _, getGuid, PQueue */ /* eslint-disable more/no-then, no-bitwise, no-nested-ternary */ @@ -936,7 +936,6 @@ function initialize({ // This is going to the CDN, not the service, so we use _outerAjax await _outerAjax(`${cdnUrl}/`, { ...manifestParams, - key: 'stickers/asdfasdf/manifest.proto', certificateAuthority, proxyUrl, timeout: 0, @@ -945,17 +944,20 @@ function initialize({ }); // Upload stickers + const queue = new PQueue({ concurrency: 3 }); await Promise.all( stickers.map(async (s, id) => { const stickerParams = makePutParams(s, encryptedStickers[id]); - await _outerAjax(`${cdnUrl}/`, { - ...stickerParams, - certificateAuthority, - proxyUrl, - timeout: 0, - type: 'POST', - processData: false, - }); + await queue.add(async () => + _outerAjax(`${cdnUrl}/`, { + ...stickerParams, + certificateAuthority, + proxyUrl, + timeout: 0, + type: 'POST', + processData: false, + }) + ); if (onProgress) { onProgress(); } diff --git a/package.json b/package.json index b5255d851..75e48c889 100644 --- a/package.json +++ b/package.json @@ -131,7 +131,7 @@ "testcheck": "1.0.0-rc.2", "tmp": "0.0.33", "to-arraybuffer": "1.0.1", - "typeface-inter": "^3.10.0", + "typeface-inter": "3.10.0", "underscore": "1.9.0", "uuid": "3.3.2", "websocket": "1.0.28" @@ -141,7 +141,7 @@ }, "devDependencies": { "@babel/core": "7.5.5", - "@babel/plugin-proposal-class-properties": "^7.7.4", + "@babel/plugin-proposal-class-properties": "7.7.4", "@babel/preset-react": "7.0.0", "@babel/preset-typescript": "7.3.3", "@storybook/addon-actions": "5.1.11", @@ -177,6 +177,7 @@ "@types/redux-logger": "3.0.7", "@types/rimraf": "2.0.2", "@types/semver": "5.5.0", + "@types/sharp": "0.23.1", "@types/sinon": "4.3.1", "@types/storybook__addon-actions": "3.4.3", "@types/storybook__addon-knobs": "5.0.3", @@ -265,7 +266,10 @@ "bundleVersion": "1" }, "win": { - "asarUnpack": ["node_modules/spellchecker/vendor/hunspell_dictionaries", "node_modules/sharp"], + "asarUnpack": [ + "node_modules/spellchecker/vendor/hunspell_dictionaries", + "node_modules/sharp" + ], "artifactName": "${name}-win-${version}.${ext}", "certificateSubjectName": "Signal", "publisherName": "Signal (Quiet Riddle Ventures, LLC)", @@ -298,7 +302,10 @@ "desktop": { "StartupWMClass": "Signal" }, - "asarUnpack": ["node_modules/spellchecker/vendor/hunspell_dictionaries", "node_modules/sharp"], + "asarUnpack": [ + "node_modules/spellchecker/vendor/hunspell_dictionaries", + "node_modules/sharp" + ], "target": [ "deb" ], diff --git a/sticker-creator/app/stages/AppStage.scss b/sticker-creator/app/stages/AppStage.scss index b5884166e..8e814586e 100644 --- a/sticker-creator/app/stages/AppStage.scss +++ b/sticker-creator/app/stages/AppStage.scss @@ -29,6 +29,12 @@ align-items: center; } +.footer-right { + display: flex; + flex-direction: row; + align-items: center; +} + .button { margin-left: 12px; } diff --git a/sticker-creator/app/stages/AppStage.tsx b/sticker-creator/app/stages/AppStage.tsx index 34d1749b8..0f22b5d89 100644 --- a/sticker-creator/app/stages/AppStage.tsx +++ b/sticker-creator/app/stages/AppStage.tsx @@ -3,6 +3,8 @@ import * as styles from './AppStage.scss'; import { history } from '../../util/history'; import { Button } from '../../elements/Button'; import { useI18n } from '../../util/i18n'; +import { Text } from '../../elements/Typography'; +import { stickersDuck } from '../../store'; export type Props = { readonly children: React.ReactNode; @@ -56,6 +58,8 @@ export const AppStage = (props: Props) => { [prev] ); + const addMoreCount = stickersDuck.useAddMoreCount(); + return ( <>
{children}
@@ -65,6 +69,11 @@ export const AppStage = (props: Props) => { {prevText || i18n('StickerCreator--AppStage--prev')} ) : null} + {addMoreCount > 0 ? ( + + {i18n('StickerCreator--DropStage--addMore', [addMoreCount])} + + ) : null} {next || onNext ? (