AiursoftWeb / Kahla.App

Kahla is a cross-platform business messaging app.
https://www.kahla.app
MIT License
415 stars 85 forks source link

Disable notification feature. #836

Closed Anduin2017 closed 4 years ago

Anduin2017 commented 4 years ago

Describe the solution you'd like

When I logged in my Kahla account on multiple browsers, like both edge and chrome, when a new notification arrives, I will be notified twice. That is pretty annoying.

So I wish that I can disable one of the notifications.

Describe alternatives you've considered

Currently, I have to disable it here.

image

Additional context

I wish there is a setting named Show push notification.

image

By default, it is true.

If I disable this switch, My device will not be registered to the server so I won't receive any notification on this device.

This setting will not be synced to other devices.

hv0905 commented 4 years ago

I think we should find a way to make the server not to push notification since if the service worker doesn't do anything when receive a push, an notification reads This website is updating at the background will be shown.

Anduin2017 commented 4 years ago

OK. I will try to find a solution. Please wait.

hv0905 commented 4 years ago

Maybe I have found some other way to disable it, I will try it tomorrow.

Anduin2017 commented 4 years ago

I have developed a new API dropDevice.

Path: /devices/dropdevice/{deviceId} Method: HTTP POST

To get if current device enabled push notification

IsElectron || serverReturnedDevices.Any(currentDeviceId)

To disable push notification

Call drop device API and save the bool to local storage.

To enable push notification

Cal add device API and save the bool to local storage.

When app starts

if (!electron) {
    var connected = serverReturnedDevices.Any(currentDeviceId);
    if (localstorage["EnablePush"] == true && !connected ) {
        AddCurrentDevice();
    }
    else if (localstorage["EnablePush"] == false && connected )) {
        DropCurrentDevice();
    }
}

EnablePush Shall be true by default.

@hv0905 how about this?

Anduin2017 commented 4 years ago

Nice fix! @hv0905