Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump to latest core & api-client for abort controller #18156

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@mediapipe/tasks-vision": "0.10.17",
"@wireapp/avs": "9.9.6",
"@wireapp/commons": "5.2.10",
"@wireapp/core": "46.4.0",
"@wireapp/core": "46.4.1",
"@wireapp/react-ui-kit": "9.23.6",
"@wireapp/store-engine-dexie": "2.1.12",
"@wireapp/webapp-events": "0.24.0",
Expand Down
64 changes: 64 additions & 0 deletions src/script/components/ConfigToolbar/ConfigToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@
import {useState, useEffect, useRef} from 'react';

import keyboardjs from 'keyboardjs';
import {container} from 'tsyringe';

import {Button, Input, Switch} from '@wireapp/react-ui-kit';

import {Config, Configuration} from 'src/script/Config';
import {ConversationState} from 'src/script/conversation/ConversationState';
import {useClickOutside} from 'src/script/hooks/useClickOutside';

import {wrapperStyles} from './ConfigToolbar.styles';

export function ConfigToolbar() {
const [showConfig, setShowConfig] = useState(false);
const [configFeaturesState, setConfigFeaturesState] = useState<Configuration['FEATURE']>(Config.getConfig().FEATURE);
const [intervalId, setIntervalId] = useState<number | null>(null); // For managing setInterval
const messageCountRef = useRef<number>(0); // For the message count
const [prefix, setPrefix] = useState('Message -'); // Prefix input
const wrapperRef = useRef(null);

// Toggle config tool on 'cmd/ctrl + shift + 2'
Expand All @@ -46,6 +51,54 @@ export function ConfigToolbar() {
};
}, []);

const startSendingMessages = () => {
if (intervalId) {
return;
}

let isRequestInProgress = false;

const id = window.setInterval(async () => {
if (isRequestInProgress) {
return;
}

const conversationState = container.resolve(ConversationState);
const activeConversation = conversationState?.activeConversation();
if (!activeConversation) {
return;
}

isRequestInProgress = true;

try {
await window.wire.app.repository.message.sendTextWithLinkPreview(
activeConversation,
`${prefix} ${messageCountRef.current}`,
[],
undefined,
);

messageCountRef.current++;
} catch (error) {
console.error('Error sending message:', error);
} finally {
isRequestInProgress = false;
}
}, 100);

setIntervalId(id);
};

// Stop sending messages and reset the counter
const stopSendingMessages = () => {
if (intervalId) {
clearInterval(intervalId);
setIntervalId(null);
messageCountRef.current = 0;
}
};

// Update the config state when form input changes
const handleChange = (path: string, value: string | boolean | string[]) => {
const updateConfig = (obj: any, keys: string[]): void => {
Expand Down Expand Up @@ -119,10 +172,21 @@ export function ConfigToolbar() {
implications of each change before proceeding. Changes may cause unexpected behavior.
</h4>
<div>{renderConfig(configFeaturesState)}</div>

<h3>Debug Functions</h3>
<Button onClick={() => window.wire?.app?.debug?.reconnectWebSocket()}>reconnectWebSocket</Button>
<Button onClick={() => window.wire?.app?.debug?.enablePushToTalk()}>enablePushToTalk</Button>
<Button onClick={() => window.wire?.app?.debug?.enablePushToTalk(null)}>disablePushToTalk</Button>

<h3>Message Automation</h3>
<Input
type="text"
value={prefix}
onChange={event => setPrefix(event.currentTarget.value)}
placeholder="Prefix for the messages"
/>
<Button onClick={startSendingMessages}>Send Incremented Messages</Button>
<Button onClick={stopSendingMessages}>Stop Sending Messages</Button>
</div>
);
}
79 changes: 49 additions & 30 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5980,12 +5980,12 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/api-client@npm:^27.6.0":
version: 27.6.0
resolution: "@wireapp/api-client@npm:27.6.0"
"@wireapp/api-client@npm:^27.6.1":
version: 27.6.1
resolution: "@wireapp/api-client@npm:27.6.1"
dependencies:
"@wireapp/commons": "npm:^5.2.10"
"@wireapp/priority-queue": "npm:^2.1.8"
"@wireapp/commons": "npm:^5.2.12"
"@wireapp/priority-queue": "npm:^2.1.10"
"@wireapp/protocol-messaging": "npm:1.50.0"
axios: "npm:1.7.7"
axios-retry: "npm:4.5.0"
Expand All @@ -5997,7 +5997,7 @@ __metadata:
tough-cookie: "npm:4.1.4"
ws: "npm:8.18.0"
zod: "npm:3.23.8"
checksum: 10/91811a1634c6bde4b6776e4be658d4168dc6abc8a295414ad8630248edb00d424883c3c646a29f728b15988662ee4b517465c6d4e785a91a9d271a4cacb6c9b5
checksum: 10/635365065a896446e07b3e94536fb54839375ebda537866d08b21d2cf07a1bad42d6d328a049f4a5f8b265908ea69ae7c14b407d39f73a795c59d8ca5267a8c2
languageName: node
linkType: hard

Expand All @@ -6015,7 +6015,7 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/commons@npm:5.2.10, @wireapp/commons@npm:^5.2.10":
"@wireapp/commons@npm:5.2.10":
version: 5.2.10
resolution: "@wireapp/commons@npm:5.2.10"
dependencies:
Expand All @@ -6027,6 +6027,18 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/commons@npm:^5.2.12":
version: 5.2.12
resolution: "@wireapp/commons@npm:5.2.12"
dependencies:
ansi-regex: "npm:5.0.1"
fs-extra: "npm:11.2.0"
logdown: "npm:3.3.1"
platform: "npm:1.3.6"
checksum: 10/c86c938a32715e07f82c983ddfbc2a6dc125b83eba2f3a0cb86f2e737838c55c96e907b09c73a5baefd1910415315df95268bd9df17e58764fc8453d131997ac
languageName: node
linkType: hard

"@wireapp/copy-config@npm:2.2.7":
version: 2.2.7
resolution: "@wireapp/copy-config@npm:2.2.7"
Expand All @@ -6051,20 +6063,20 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/core@npm:46.4.0":
version: 46.4.0
resolution: "@wireapp/core@npm:46.4.0"
"@wireapp/core@npm:46.4.1":
version: 46.4.1
resolution: "@wireapp/core@npm:46.4.1"
dependencies:
"@wireapp/api-client": "npm:^27.6.0"
"@wireapp/commons": "npm:^5.2.10"
"@wireapp/api-client": "npm:^27.6.1"
"@wireapp/commons": "npm:^5.2.12"
"@wireapp/core-crypto": "npm:1.0.2"
"@wireapp/cryptobox": "npm:12.8.0"
"@wireapp/priority-queue": "npm:^2.1.8"
"@wireapp/promise-queue": "npm:^2.3.5"
"@wireapp/priority-queue": "npm:^2.1.10"
"@wireapp/promise-queue": "npm:^2.3.7"
"@wireapp/protocol-messaging": "npm:1.50.0"
"@wireapp/store-engine": "npm:5.1.8"
"@wireapp/store-engine": "npm:5.1.10"
axios: "npm:1.7.7"
bazinga64: "npm:^6.3.8"
bazinga64: "npm:^6.3.10"
deepmerge-ts: "npm:6.0.0"
hash.js: "npm:1.1.7"
http-status-codes: "npm:2.3.0"
Expand All @@ -6073,7 +6085,7 @@ __metadata:
long: "npm:^5.2.0"
uuid: "npm:9.0.1"
zod: "npm:3.23.8"
checksum: 10/6f1d5f177c4c0af706676bdd59c2279dc1a26ed885d800563200c0532cbe85a47ebc698f94e101ec7727a7d4c32bc79f87fb5aea387b41ee00c68ef70a7b67cf
checksum: 10/c7529ff79ce7cabcf6c1a5a64eddc5c9e5a52dae59caeeab38ab5c5545ebc684e14d909bf76272bfcb9f4eb009be3a2d3685bda77737cf2bb53e22c37b752c38
languageName: node
linkType: hard

Expand Down Expand Up @@ -6149,17 +6161,17 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/priority-queue@npm:^2.1.8":
version: 2.1.8
resolution: "@wireapp/priority-queue@npm:2.1.8"
checksum: 10/538e2b1b7c085ad259b6d3e0fedcce17a4e18c93ece34a52f2d1bc0ab8e6914592042a1e48d3663f6cee6b776b2e5825c926d996c3d2581612eab581d2a6a2ed
"@wireapp/priority-queue@npm:^2.1.10":
version: 2.1.10
resolution: "@wireapp/priority-queue@npm:2.1.10"
checksum: 10/72c2b3aad88284ce775e98fcd8585b3f511fdd6e28db6c12ed3bd75fce6d6ce06003412cdf0d5979be723149f5d8195f87ee10847ac57d7fd8bc594de58de3fb
languageName: node
linkType: hard

"@wireapp/promise-queue@npm:^2.3.5":
version: 2.3.5
resolution: "@wireapp/promise-queue@npm:2.3.5"
checksum: 10/a6282eab9975203d30790821af6cab25c3ff258281fe8b3f67407bcac5ac45fada6c4ae3c6fe5d32ae5b6a7e2c85736e299ab3613fdc6ab2140eef48238ba996
"@wireapp/promise-queue@npm:^2.3.7":
version: 2.3.7
resolution: "@wireapp/promise-queue@npm:2.3.7"
checksum: 10/6f45200303b42259981b305f2b207535e13579917fd5d2360001cc0cebdd0f271468a535beb570261eefc200ed94abf1213d4f4cacc8bfa01c4af6f9c5ff9b23
languageName: node
linkType: hard

Expand Down Expand Up @@ -6228,6 +6240,13 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/store-engine@npm:5.1.10":
version: 5.1.10
resolution: "@wireapp/store-engine@npm:5.1.10"
checksum: 10/1278a432cf712a73e011e4d9e30a1d4c2513adb786639db4f6e031761837e8f3987fd5fc045aa95be22f04cd82b3089586883a4ff55ed2428435d040a76005ee
languageName: node
linkType: hard

"@wireapp/store-engine@npm:5.1.8":
version: 5.1.8
resolution: "@wireapp/store-engine@npm:5.1.8"
Expand Down Expand Up @@ -7117,10 +7136,10 @@ __metadata:
languageName: node
linkType: hard

"bazinga64@npm:^6.3.8":
version: 6.3.8
resolution: "bazinga64@npm:6.3.8"
checksum: 10/553194f1579b13b9951515199234a447f439792008269fbf1f34e0644aeba23c1334bcb20f0344a7460011716dcda8351084089298cd21f629ce36b06937f9ff
"bazinga64@npm:^6.3.10":
version: 6.3.10
resolution: "bazinga64@npm:6.3.10"
checksum: 10/beaa4b41b4f5f2605bf28b3771cd9e3f85ce2bddd6f553f15bd943feb9c1631818191a5c2639d8b10e4d3691cc7c77582ad78943b2981d5bc92e03b0e7ca6264
languageName: node
linkType: hard

Expand Down Expand Up @@ -18691,7 +18710,7 @@ __metadata:
"@wireapp/avs": "npm:9.9.6"
"@wireapp/commons": "npm:5.2.10"
"@wireapp/copy-config": "npm:2.2.7"
"@wireapp/core": "npm:46.4.0"
"@wireapp/core": "npm:46.4.1"
"@wireapp/eslint-config": "npm:3.0.7"
"@wireapp/prettier-config": "npm:0.6.4"
"@wireapp/react-ui-kit": "npm:9.23.6"
Expand Down
Loading