From de85a80e06129dfd0f86eb5fce1473c023ebbc4b Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Mon, 13 Mar 2023 21:02:17 +0100 Subject: [PATCH] refactor: auto accept created invitation Signed-off-by: Timo Glastra --- .../components/connections/ConnectionsTable.tsx | 13 ++----------- .../pages/agent/connections/ConnectionsScreen.tsx | 14 +++----------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/packages/siera-ui/src/components/connections/ConnectionsTable.tsx b/packages/siera-ui/src/components/connections/ConnectionsTable.tsx index ba3deef..fd33067 100644 --- a/packages/siera-ui/src/components/connections/ConnectionsTable.tsx +++ b/packages/siera-ui/src/components/connections/ConnectionsTable.tsx @@ -14,8 +14,6 @@ import { TableHead } from '../generic/table/TableHeader' interface ConnectionsTableProps { records: ConnectionRecord[] onDelete: (connection: ConnectionRecord) => void - onAccept: (connection: ConnectionRecord) => void - onDecline: (connection: ConnectionRecord) => void } const useStyles = createStyles(() => ({ @@ -26,7 +24,7 @@ const useStyles = createStyles(() => ({ }, })) -export const ConnectionsTable = ({ records, onDelete, onAccept, onDecline }: ConnectionsTableProps) => { +export const ConnectionsTable = ({ records, onDelete }: ConnectionsTableProps) => { const { classes: tableStyle, cx } = useGenericTableStyle() const { classes } = useStyles() const navigation = useNavigation() @@ -50,8 +48,6 @@ export const ConnectionsTable = ({ records, onDelete, onAccept, onDecline }: Con {records.map((record: ConnectionRecord) => { const isLoading = ConnectionsUtil.isConnectionWaitingForResponse(record) - const isWaitingForAccept = ConnectionsUtil.isConnectionWaitingForAcceptInput(record) - const isWaitingForDecline = ConnectionsUtil.isConnectionWaitingForDeclineInput(record) const lastUpdated = record.updatedAt ?? record.createdAt @@ -78,12 +74,7 @@ export const ConnectionsTable = ({ records, onDelete, onAccept, onDecline }: Con {record.state} - onAccept(record) : undefined} - onDecline={isWaitingForDecline ? () => onDecline(record) : undefined} - onDelete={() => onDelete(record)} - isLoading={isLoading} - /> + onDelete(record)} isLoading={isLoading} /> ) diff --git a/packages/siera-ui/src/pages/agent/connections/ConnectionsScreen.tsx b/packages/siera-ui/src/pages/agent/connections/ConnectionsScreen.tsx index d21c5eb..45c4e72 100644 --- a/packages/siera-ui/src/pages/agent/connections/ConnectionsScreen.tsx +++ b/packages/siera-ui/src/pages/agent/connections/ConnectionsScreen.tsx @@ -25,16 +25,10 @@ export const ConnectionsScreen = () => { await agent?.oob.receiveInvitationFromUrl(url) } - const acceptRequest = async (connectionId: string) => { - await agent?.connections.acceptRequest(connectionId) - } - - const declineRequest = async (connectionId: string) => { - await agent?.connections.deleteById(connectionId) - } - const createInvite = async () => { - const invite = await agent?.oob.createLegacyInvitation() + const invite = await agent?.oob.createLegacyInvitation({ + autoAcceptConnection: true, + }) if (!invite) { showNotification({ @@ -81,8 +75,6 @@ export const ConnectionsScreen = () => { agent?.connections.deleteById(connection.id)} - onAccept={(connection) => acceptRequest(connection.id)} - onDecline={(connection) => declineRequest(connection.id)} /> )}