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

Remove notifications for completed transactions #860

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
59 changes: 0 additions & 59 deletions dapp/src/components/shared/ActivitiesList/ActivitiesList.tsx

This file was deleted.

85 changes: 0 additions & 85 deletions dapp/src/components/shared/ActivitiesList/ActivitiesListItem.tsx

This file was deleted.

1 change: 0 additions & 1 deletion dapp/src/components/shared/ActivitiesList/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion dapp/src/hooks/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ export * from "./useActionFlowPause"
export * from "./useIsSignedMessage"
export { default as useHasFetchedActivities } from "./useHasFetchedActivities"
export { default as useActivities } from "./useActivities"
export { default as useLatestCompletedActivities } from "./useLatestCompletedActivities"
6 changes: 0 additions & 6 deletions dapp/src/hooks/store/useLatestCompletedActivities.ts

This file was deleted.

2 changes: 0 additions & 2 deletions dapp/src/pages/DashboardPage/DashboardCard.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React from "react"
import { Card, CardBody, CardProps, VStack } from "@chakra-ui/react"
import { ActivitiesList } from "#/components/shared/ActivitiesList"
import TransactionHistory from "./TransactionHistory"
import PositionDetails from "./PositionDetails"

export default function DashboardCard(props: CardProps) {
return (
<Card p="dashboard_card_padding" overflow="hidden" {...props}>
<CardBody as={VStack} spacing={10}>
<ActivitiesList />
<PositionDetails />
<TransactionHistory />
</CardBody>
Expand Down
51 changes: 2 additions & 49 deletions dapp/src/store/tests/walletSlice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { beforeEach, describe, expect, it } from "vitest"
import { createActivity } from "#/tests/factories"
import { Activity } from "#/types"
import { WalletState } from "../wallet"
import reducer, {
deleteLatestActivity,
initialState,
setActivities,
} from "../wallet/walletSlice"
import reducer, { initialState, setActivities } from "../wallet/walletSlice"

const isSignedMessage = false
const hasFetchedActivities = true
Expand All @@ -16,10 +12,6 @@ const pendingActivity = createActivity({
status: "pending",
})

const latestActivities = {
[pendingActivityId]: pendingActivity,
}

const activities = [
pendingActivity,
createActivity({ id: "1" }),
Expand All @@ -34,22 +26,11 @@ describe("Wallet redux slice", () => {
state = {
...initialState,
activities,
latestActivities,
isSignedMessage,
hasFetchedActivities,
}
})

it("should delete latest activity", () => {
expect(reducer(state, deleteLatestActivity(pendingActivityId))).toEqual({
...initialState,
activities,
latestActivities: {},
isSignedMessage,
hasFetchedActivities,
})
})

it("should update activities when the status of item changes", () => {
const newActivities = [...activities]
const completedActivity: Activity = {
Expand All @@ -60,14 +41,10 @@ describe("Wallet redux slice", () => {
({ id }) => id === pendingActivityId,
)
newActivities[foundIndex] = completedActivity
const newLatestActivities = {
[pendingActivityId]: completedActivity,
}

expect(reducer(state, setActivities(newActivities))).toEqual({
...initialState,
activities: newActivities,
latestActivities: newLatestActivities,
isSignedMessage,
hasFetchedActivities,
})
Expand Down Expand Up @@ -102,12 +79,6 @@ describe("Wallet redux slice", () => {
}),
]

// A user made a new withdrawal and the dapp saved the pending activity in
// the store.
const currentLatestActivities = {
[pendingWithdrawRedemptionKey]: pendingWithdrawActivity,
}

describe("when withdrawal is still pending", () => {
// This is our pending withdrawal but with the full id with the `-<count>`
// suffix returned by backend.
Expand All @@ -122,19 +93,10 @@ describe("Wallet redux slice", () => {
pendingWithdrawActivityWithFullId,
]

// We should replace the pending activity with the activity from the
// backend that contains the full id (`<redemptionKey>-<count>`) and still
// keep it in the `latestActivities` map.
const expectedLatestActivities = {
[pendingWithdrawActivityWithFullId.id]:
pendingWithdrawActivityWithFullId,
}

beforeEach(() => {
state = {
...initialState,
activities: currentActivities,
latestActivities: currentLatestActivities,
isSignedMessage,
hasFetchedActivities,
}
Expand All @@ -144,7 +106,6 @@ describe("Wallet redux slice", () => {
expect(reducer(state, setActivities(newActivities))).toEqual({
...initialState,
activities: newActivities,
latestActivities: expectedLatestActivities,
isSignedMessage,
hasFetchedActivities,
})
Expand All @@ -164,26 +125,18 @@ describe("Wallet redux slice", () => {
// redemption key).
const newActivities = [...currentActivities, withdrawActivityCompleted]

// The dapp should update the state to `completed` and save this activity
// in the latest activity map.
const expectedLatestActivities = {
[withdrawActivityCompleted.id]: withdrawActivityCompleted,
}

beforeEach(() => {
state = {
...initialState,
activities: currentActivities,
latestActivities: currentLatestActivities,
isSignedMessage,
}
})

it("should mark the latest pending withdraw activity as completed and save as latest activity", () => {
it("should mark the latest pending withdraw activity as completed", () => {
expect(reducer(state, setActivities(newActivities))).toEqual({
...initialState,
activities: newActivities,
latestActivities: expectedLatestActivities,
isSignedMessage,
hasFetchedActivities,
})
Expand Down
13 changes: 1 addition & 12 deletions dapp/src/store/wallet/walletSelector.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSelector } from "@reduxjs/toolkit"
import { filterCompletedActivities, sortActivitiesByTimestamp } from "#/utils"
import { sortActivitiesByTimestamp } from "#/utils"
import { RootState } from ".."

export const selectEstimatedBtcBalance = (state: RootState): bigint =>
Expand All @@ -18,17 +18,6 @@ export const selectAllActivitiesCount = createSelector(
(activities) => activities.length,
)

export const selectLatestActivities = createSelector(
(state: RootState) => state.wallet.latestActivities,
(latestActivities) =>
sortActivitiesByTimestamp(Object.values(latestActivities)),
)

export const selectLatestCompletedActivities = createSelector(
selectLatestActivities,
(latestActivities) => filterCompletedActivities(latestActivities),
)

export const selectIsSignedMessage = (state: RootState): boolean =>
state.wallet.isSignedMessage

Expand Down
Loading
Loading