Skip to content

Commit

Permalink
Remove notifications for completed transactions (#860)
Browse files Browse the repository at this point in the history
This PR removes notifications for completed transactions. What has been
done:

- Removed `ActivitiesList` and `ActivitiesListItem` components.
- Removed unneeded variant "process" for `Alert`.
- Removed unneeded types and utils.
- Removed unneeded code for `latestActivities`

### UI

**Before**
<img width="350" alt="Screenshot 2024-11-14 at 10 52 35"
src="https://github.com/user-attachments/assets/7b46bcf1-6675-4313-938f-5c6a53f40954">


**After**
<img width="350" alt="Screenshot 2024-11-14 at 10 53 16"
src="https://github.com/user-attachments/assets/6cdb4188-695c-43f7-8101-af3a5bb62909">
  • Loading branch information
michalinacienciala authored Nov 15, 2024
2 parents c555378 + dd8cb6b commit 92f66fd
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 319 deletions.
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

0 comments on commit 92f66fd

Please sign in to comment.