tjibbevanderlaan / chromeos-filesystem-sftp

ChromeOS app to access SFTP server
https://chrome.google.com/webstore/detail/shared-network-folder-sft/gbheifiifcfekkamhepkeogobihicgmn
BSD 3-Clause "New" or "Revised" License
80 stars 21 forks source link

Reduce the number of notifications displayed on errors #91

Closed ghost closed 8 years ago

ghost commented 9 years ago

Often when I try to open a folder I will have several errors show up saying it had some issue or another trying to open the folder even though the folder opens fine. I'm fine with being alerted to a potential problem, but I think it might be best to either reuse the same notification if the error is the same, or have a generic error pop up that has an action when clicked on to display an error log.

yoichiro commented 9 years ago

@brycethorup Hmm... It may be difficult, because all file system provider implementations only works for each firing event... If the opened folder has three files, the onGetMetadataRequested event will be fired three times independently. Of course, I want to collect many same errors as one error, but I don't know any ideas to achieve it...

Anyway, I intend to find some solutions...

ghost commented 8 years ago

The simple work around would be to give your notification an id in the first parameter of the create method. In your code, each time a notification is created you are leaving the ID blank. Here is an example from your code:

chrome.notifications.create("", {
    type: "basic",
    title: "SFTP File System",
    message: "Resuming connection failed. Unmount.",
    iconUrl: "/images/48.png"
}, function(notificationId) {
}.bind(this));

As long as the first parameter isn't an empty string the existing notification will be replaced by the new one if it uses the same id. Here is the updated code.

chrome.notifications.create("error_notification", {
    type: "basic",
    title: "SFTP File System",
    message: "Resuming connection failed. Unmount.",
    iconUrl: "/images/48.png"
}, function(notificationId) {
}.bind(this));

I created a pull request that has the modifications (#101), if you're interested.

yoichiro commented 8 years ago

@brycethorup I just released a new version 1.7.9 including the Pull Request #101. Thank you for your cooperation. I close this issue.