Skip to content

Commit d7c9011

Browse files
committed
bitbox01: remove legacy registeredChanged event
Was only used in bitbox01.jsx, and there it was actually useless since DeviceSwitch is fed the devices list already (from app.tsx using the new style event) to decide to mount/unmount the component.
1 parent 795faab commit d7c9011

File tree

2 files changed

+9
-58
lines changed

2 files changed

+9
-58
lines changed

backend/backend.go

-18
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,6 @@ const (
115115
eventNewTxs event = "new-txs"
116116
)
117117

118-
type backendEvent struct {
119-
Type string `json:"type"`
120-
Data string `json:"data"`
121-
Meta interface{} `json:"meta"`
122-
}
123-
124118
type deviceEvent struct {
125119
DeviceID string `json:"deviceID"`
126120
Type string `json:"type"`
@@ -813,15 +807,6 @@ func (backend *Backend) Register(theDevice device.Interface) error {
813807
return err
814808
}
815809

816-
// Old-school
817-
select {
818-
case backend.events <- backendEvent{
819-
Type: "devices",
820-
Data: "registeredChanged",
821-
}:
822-
default:
823-
}
824-
// New-school
825810
backend.Notify(observable.Event{
826811
Subject: "devices/registered",
827812
Action: action.Reload,
@@ -843,9 +828,6 @@ func (backend *Backend) Deregister(deviceID string) {
843828
delete(backend.devices, deviceID)
844829
backend.DeregisterKeystore()
845830

846-
// Old-school
847-
backend.events <- backendEvent{Type: "devices", Data: "registeredChanged"}
848-
// New-school
849831
backend.Notify(observable.Event{
850832
Subject: "devices/registered",
851833
Action: action.Reload,

frontends/web/src/routes/device/bitbox01/bitbox01.jsx

+9-40
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,14 @@ class Device extends Component {
5151

5252
state = {
5353
firmwareVersion: null,
54-
deviceRegistered: false,
5554
deviceStatus: '',
5655
goal: '',
5756
success: null,
5857
};
5958

6059
componentDidMount() {
61-
this.onDevicesRegisteredChanged();
6260
this.onDeviceStatusChanged();
6361
this.unsubscribe = apiWebsocket(({ type, data, deviceID }) => {
64-
if (type === 'devices' && data === 'registeredChanged') {
65-
this.onDevicesRegisteredChanged();
66-
}
6762
if (type === 'device' && data === 'statusChanged' && deviceID === this.getDeviceID()) {
6863
this.onDeviceStatusChanged();
6964
}
@@ -76,40 +71,15 @@ class Device extends Component {
7671
}
7772
}
7873

79-
componentDidUpdate(prevProps) {
80-
if (this.props.deviceID !== prevProps.deviceID) {
81-
this.onDevicesRegisteredChanged();
82-
}
83-
}
84-
85-
onDevicesRegisteredChanged = () => {
86-
apiGet('devices/registered').then(devices => {
87-
const deviceIDs = Object.keys(devices);
88-
const deviceRegistered = deviceIDs.includes(this.getDeviceID());
89-
90-
this.setState({
91-
deviceRegistered,
92-
deviceStatus: null
93-
}, () => {
94-
// only if deviceRegistered or softwarekeystore
95-
if (this.state.deviceRegistered) {
96-
this.onDeviceStatusChanged();
97-
}
98-
});
99-
});
100-
};
101-
10274
onDeviceStatusChanged = () => {
103-
if (this.state.deviceRegistered) {
104-
apiGet('devices/' + this.props.deviceID + '/status').then(deviceStatus => {
105-
if (['seeded', 'initialized'].includes(deviceStatus)) {
106-
this.context.setSidebarStatus('');
107-
} else {
108-
this.context.setSidebarStatus('forceHidden');
109-
}
110-
this.setState({ deviceStatus });
111-
});
112-
}
75+
apiGet('devices/' + this.props.deviceID + '/status').then(deviceStatus => {
76+
if (['seeded', 'initialized'].includes(deviceStatus)) {
77+
this.context.setSidebarStatus('');
78+
} else {
79+
this.context.setSidebarStatus('forceHidden');
80+
}
81+
this.setState({ deviceStatus });
82+
});
11383
};
11484

11585
getDeviceID() {
@@ -137,12 +107,11 @@ class Device extends Component {
137107
deviceID,
138108
} = this.props;
139109
const {
140-
deviceRegistered,
141110
deviceStatus,
142111
goal,
143112
success,
144113
} = this.state;
145-
if (!deviceRegistered || !deviceStatus) {
114+
if (!deviceStatus) {
146115
return null;
147116
}
148117
if (success) {

0 commit comments

Comments
 (0)