Skip to content

Commit

Permalink
Add support of browser notifications, WIP
Browse files Browse the repository at this point in the history
todo: translate message

references #187
  • Loading branch information
zakius committed Apr 24, 2022
1 parent 4fbcb27 commit 963fd46
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 13 deletions.
8 changes: 5 additions & 3 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
"https://code.fb.com/*",
"https://dev.opera.com/*",
"webRequest",
"webRequestBlocking"
"webRequestBlocking",
"notifications"
],
"chromium_permissions": [
"unlimitedStorage",
"contextMenus",
"alarms",
"tabs",
"<all_urls>"
"<all_urls>",
"notifications"
],
"content_security_policy": "default-src * 'self' data: 'unsafe-inline'; script-src 'self'; style-src * 'self' data: 'unsafe-inline'; img-src * 'self' data:; object-src 'self'",
"chromium_content_security_policy": "script-src 'self'; object-src 'self'",
Expand Down Expand Up @@ -74,4 +76,4 @@
"id": "[email protected]"
}
}
}
}
26 changes: 18 additions & 8 deletions src/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,13 @@ <h1>Smart RSS</h1>
</select>
</label>

<!-- <label class="web-content-select-label" title="If selected to see all articles hold alt or click on the counter">-->
<!-- <span class="selectLabel">Show only unread articles by default:</span>-->
<!-- <select id="defaultToUnreadOnly">-->
<!-- <option value="false">No</option>-->
<!-- <option value="true">Yes</option>-->
<!-- </select>-->
<!-- </label>-->
<!-- <label class="web-content-select-label" title="If selected to see all articles hold alt or click on the counter">-->
<!-- <span class="selectLabel">Show only unread articles by default:</span>-->
<!-- <select id="defaultToUnreadOnly">-->
<!-- <option value="false">No</option>-->
<!-- <option value="true">Yes</option>-->
<!-- </select>-->
<!-- </label>-->

</section>
</details>
Expand All @@ -457,7 +457,17 @@ <h1>Smart RSS</h1>
</details>

<details>
<summary class="section-header">Sound notifications</summary>
<summary class="section-header">Notifications</summary>

<label class="web-content-select-label"
title="If enabled, browser will display a notification when new articles are found.">
<span class="selectLabel">Enable system notifications:</span>
<select id="systemNotifications">
<option value="true">Yes</option>
<option value="false">No</option>
</select>
</label>

<section>
<label class="web-content-select-label"
title="If enabled, browser will make a sound when new articles are downloaded.">
Expand Down
22 changes: 20 additions & 2 deletions src/scripts/bgprocess/models/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,24 @@ define(['backbone', 'modules/RSSParser', 'modules/Animation', 'favicon', 'models
this.startDownloading();
}

handleNotifications() {
if (settings.get('soundNotifications')) {
this.playNotificationSound();
}
if (settings.get('systemNotifications')) {
this.displaySystemNotification();
}
}


displaySystemNotification() {
chrome.notifications.create({
type: 'basic',
title: 'Smart RSS',
message: 'New articles found'
});
}

playNotificationSound() {
let audio;
if (!settings.get('useSound') || settings.get('useSound') === ':user') {
Expand Down Expand Up @@ -208,8 +226,8 @@ define(['backbone', 'modules/RSSParser', 'modules/Animation', 'favicon', 'models
if (foundSome) {
info.refreshSpecialCounters();
}
if (this.itemsDownloaded && settings.get('soundNotifications')) {
this.playNotificationSound();
if (this.itemsDownloaded) {
this.handleNotifications();
}
this.maxSources = 0;
this.loaded = 0;
Expand Down

0 comments on commit 963fd46

Please sign in to comment.