ive-connect 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -127,17 +127,25 @@ class HandyDevice extends events_1.EventEmitter {
|
|
|
127
127
|
this._eventSource.close();
|
|
128
128
|
this._eventSource = null;
|
|
129
129
|
}
|
|
130
|
-
// Update state
|
|
130
|
+
// Update state immediately
|
|
131
131
|
this._connectionState = device_interface_1.ConnectionState.DISCONNECTED;
|
|
132
132
|
this._deviceInfo = null;
|
|
133
133
|
this._isPlaying = false;
|
|
134
134
|
// Emit events
|
|
135
135
|
this.emit("connectionStateChanged", this._connectionState);
|
|
136
136
|
this.emit("disconnected");
|
|
137
|
+
// Return true regardless of what happens with the API
|
|
137
138
|
return true;
|
|
138
139
|
}
|
|
139
140
|
catch (error) {
|
|
140
141
|
console.error("Handy: Error disconnecting device:", error);
|
|
142
|
+
// Set disconnected state even in case of error
|
|
143
|
+
this._connectionState = device_interface_1.ConnectionState.DISCONNECTED;
|
|
144
|
+
this._deviceInfo = null;
|
|
145
|
+
this._isPlaying = false;
|
|
146
|
+
// Emit events
|
|
147
|
+
this.emit("connectionStateChanged", this._connectionState);
|
|
148
|
+
this.emit("disconnected");
|
|
141
149
|
return true; // Return true anyway for better UX
|
|
142
150
|
}
|
|
143
151
|
}
|