@repzo/widget-react-native 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +36 -2
- package/lib/commonjs/api/client.js +29 -5
- package/lib/commonjs/api/client.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/state/user-update-queue.js +168 -0
- package/lib/commonjs/state/user-update-queue.js.map +1 -0
- package/lib/commonjs/state/widget-store.js +27 -4
- package/lib/commonjs/state/widget-store.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/ui/screens/chat/ChatView.js +14 -1
- package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -1
- package/lib/module/api/client.js +27 -4
- package/lib/module/api/client.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/state/user-update-queue.js +163 -0
- package/lib/module/state/user-update-queue.js.map +1 -0
- package/lib/module/state/widget-store.js +27 -4
- package/lib/module/state/widget-store.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/ui/screens/chat/ChatView.js +14 -1
- package/lib/module/ui/screens/chat/ChatView.js.map +1 -1
- package/lib/typescript/commonjs/api/client.d.ts +8 -2
- package/lib/typescript/commonjs/api/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +5 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/state/user-update-queue.d.ts +62 -0
- package/lib/typescript/commonjs/state/user-update-queue.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/widget-store.d.ts +4 -0
- package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +12 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -1
- package/lib/typescript/module/api/client.d.ts +8 -2
- package/lib/typescript/module/api/client.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +5 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/state/user-update-queue.d.ts +62 -0
- package/lib/typescript/module/state/user-update-queue.d.ts.map +1 -0
- package/lib/typescript/module/state/widget-store.d.ts +4 -0
- package/lib/typescript/module/state/widget-store.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +12 -0
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api/client.ts +33 -4
- package/src/index.tsx +5 -0
- package/src/state/user-update-queue.ts +178 -0
- package/src/state/widget-store.ts +25 -2
- package/src/types.ts +12 -0
- package/src/ui/screens/chat/ChatView.tsx +14 -1
package/src/types.ts
CHANGED
|
@@ -300,6 +300,18 @@ export interface BootOptions {
|
|
|
300
300
|
* @since 1.4.0
|
|
301
301
|
*/
|
|
302
302
|
youPrefix?: boolean;
|
|
303
|
+
/**
|
|
304
|
+
* Pace `updateUser()` so an app that calls it on a timer or on every
|
|
305
|
+
* location fix can't flood Workstation (default true). Values Workstation
|
|
306
|
+
* already has aren't sent again; up to 20 updates go out at once, then one
|
|
307
|
+
* every 90 seconds (20 per 30 minutes). Calls in between are merged, newest
|
|
308
|
+
* value per key, and sent on the next allowed update, so nothing is lost and
|
|
309
|
+
* `updateUser()` resolves right away for them. A rate-limit answer from
|
|
310
|
+
* Workstation is waited out and retried the same way. False sends every
|
|
311
|
+
* call straight away, as before 1.5.0.
|
|
312
|
+
* @since 1.5.0
|
|
313
|
+
*/
|
|
314
|
+
throttleUpdateUser?: boolean;
|
|
303
315
|
}
|
|
304
316
|
|
|
305
317
|
/** An option in the composer's attach menu. */
|
|
@@ -211,6 +211,18 @@ export function ChatView({
|
|
|
211
211
|
// it. Scrolled up, scrolling first let the list hold its place as the new
|
|
212
212
|
// row arrived, which could cut the scroll short.
|
|
213
213
|
const followSend = useRef(false);
|
|
214
|
+
// Set by a tap on Send until the composer re-renders. Taps that pile up
|
|
215
|
+
// while the JS thread is busy (a slow phone, the host app at work) are all
|
|
216
|
+
// handled before React re-renders, so each still sees the typed text and
|
|
217
|
+
// would send it again. A ref changes at once: only the first goes out.
|
|
218
|
+
const sendTapped = useRef(false);
|
|
219
|
+
|
|
220
|
+
// After every render, and after the send button has taken this render's
|
|
221
|
+
// handler (its own effect runs first): from here a tap sees the composer as
|
|
222
|
+
// the last send left it.
|
|
223
|
+
useEffect(() => {
|
|
224
|
+
sendTapped.current = false;
|
|
225
|
+
});
|
|
214
226
|
|
|
215
227
|
useEffect(() => {
|
|
216
228
|
if (prefillText) setInput(prefillText);
|
|
@@ -361,7 +373,8 @@ export function ChatView({
|
|
|
361
373
|
|
|
362
374
|
const handleSend = () => {
|
|
363
375
|
const trimmed = input.trim();
|
|
364
|
-
if (!canSend) return;
|
|
376
|
+
if (!canSend || sendTapped.current) return;
|
|
377
|
+
sendTapped.current = true;
|
|
365
378
|
setInput('');
|
|
366
379
|
if (typingStopTimer.current) clearTimeout(typingStopTimer.current);
|
|
367
380
|
onTyping(false);
|