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

Fixed: Duplicated bluetooth devices #17

Merged
merged 6 commits into from
Jun 17, 2017
Merged

Conversation

Philip-Scott
Copy link
Member

Fixes: #10 Makes sure to only add and send the signal that a device has been added once, also prevents all devices from being deleted if you unpair a device

Copy link
Collaborator

@donadigo donadigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks much better! Thanks. Two things in the diff comments.

private void add_device (BluetoothIndicator.Services.Device device, string path) {
lock (devices) {
if (!devices.has_key (path)) {
devices.set (path, device);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use this:
devices[path] = device

if (child is Bluetooth.Widgets.Device) {
((Bluetooth.Widgets.Device) child).destroy ();
var device_child = child as Bluetooth.Widgets.Device;
if (device_child != null && device_child.device.modalias == device.modalias) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, could we have a compare method inside the Device class like that?

public bool compare (Device device) {
    return modalias == device.modalias;
}

It would just make this easier to compare devices in the future.

Copy link
Collaborator

@donadigo donadigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks! (code)

@danirabbit danirabbit merged commit a9916fa into master Jun 17, 2017
@danirabbit danirabbit deleted the fix-duplicated-devices branch June 17, 2017 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants