Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- added: Register SwapKit V3 as a separate exchange plugin
- changed: Manage tokens scene saves changes on explicit save instead of live toggling
- changed: Unify split wallet scene titles and add chain-specific descriptions for EVM and UTXO splits
- fixed: Security check notification not reappearing after dismissal

## 4.43.0 (2025-02-09)

Expand Down
71 changes: 28 additions & 43 deletions src/components/services/PasswordReminderService.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,36 @@
import * as React from 'react'

import { setPasswordReminder } from '../../actions/LocalSettingsActions'
import { connect } from '../../types/reactRedux'
import type { PasswordReminder } from '../../types/types'
import { useAsyncEffect } from '../../hooks/useAsyncEffect'
import {
initialState,
type PasswordReminderState
} from '../../reducers/PasswordReminderReducer'
import { useDispatch, useSelector } from '../../types/reactRedux'
import { matchJson } from '../../util/matchJson'
import { showError } from './AirshipInstance'

interface StateProps {
settingsLoaded: boolean | null
passwordReminder: PasswordReminder
}
interface DispatchProps {
setPasswordReminder: (passwordReminder: PasswordReminder) => Promise<void>
}
type Props = StateProps & DispatchProps
interface Props {}

class PasswordReminderComponent extends React.PureComponent<Props> {
componentDidUpdate(prevProps: Props) {
if (
this.props.settingsLoaded &&
!matchJson(prevProps.passwordReminder, this.props.passwordReminder)
) {
this.props
.setPasswordReminder(this.props.passwordReminder)
.catch((error: unknown) => {
showError(error)
})
}
}
export const PasswordReminderService: React.FC<Props> = props => {
const settingsLoaded =
useSelector(state => state.ui.settings.settingsLoaded) ?? false
const passwordReminder = useSelector(state => state.ui.passwordReminder)
const lastPasswordReminder = React.useRef<PasswordReminderState>(initialState)
const dispatch = useDispatch()

render() {
return null
}
}
useAsyncEffect(
async () => {
if (
settingsLoaded &&
!matchJson(passwordReminder, lastPasswordReminder.current)
) {
lastPasswordReminder.current = passwordReminder
await dispatch(setPasswordReminder(passwordReminder))
}
},
[settingsLoaded, passwordReminder],
'PasswordReminderService'
)

export const PasswordReminderService = connect<
StateProps,
DispatchProps,
unknown
>(
state => ({
settingsLoaded: state.ui.settings.settingsLoaded,
passwordReminder: state.ui.passwordReminder
}),
dispatch => ({
async setPasswordReminder(passwordReminder: PasswordReminder) {
await dispatch(setPasswordReminder(passwordReminder))
}
})
)(PasswordReminderComponent)
return null
}
Loading