Skip to content

Commit

Permalink
Merge pull request #98 from animo/refactor/auto-accept-created-invita…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
berendsliedrecht authored Mar 13, 2023
2 parents f7c33f7 + db59b41 commit 8bb3785
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
13 changes: 2 additions & 11 deletions packages/siera-ui/src/components/connections/ConnectionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => ({
Expand All @@ -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()
Expand All @@ -50,8 +48,6 @@ export const ConnectionsTable = ({ records, onDelete, onAccept, onDecline }: Con
<tbody>
{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

Expand All @@ -78,12 +74,7 @@ export const ConnectionsTable = ({ records, onDelete, onAccept, onDecline }: Con
<StatusBadge>{record.state}</StatusBadge>
</td>
<td>
<RecordActions
onAccept={isWaitingForAccept ? () => onAccept(record) : undefined}
onDecline={isWaitingForDecline ? () => onDecline(record) : undefined}
onDelete={() => onDelete(record)}
isLoading={isLoading}
/>
<RecordActions onDelete={() => onDelete(record)} isLoading={isLoading} />
</td>
</tr>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -81,8 +75,6 @@ export const ConnectionsScreen = () => {
<ConnectionsTable
records={connectionRecords}
onDelete={(connection) => agent?.connections.deleteById(connection.id)}
onAccept={(connection) => acceptRequest(connection.id)}
onDecline={(connection) => declineRequest(connection.id)}
/>
</Card>
)}
Expand Down

0 comments on commit 8bb3785

Please sign in to comment.