-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add desktop dock icon indicator in Electron #525
Merged
Merged
Changes from 21 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
df2653d
Add desktop dock icon indicator
marcaaron 772ba7a
fix newline
marcaaron b216c53
save lastReadActionIDs so we can reference them later
marcaaron 99c9b9e
not zero use sequenceNumber
marcaaron 40083b9
remove isUnread from report
marcaaron 3153f2e
Simplify the SidebarLink component
marcaaron 0e904e2
add electron events
marcaaron 50999a7
use throttle to minimize calls to the updater
marcaaron 7717b1b
add comment
marcaaron d9d1424
Move updateUnread method to its own utility
marcaaron 2ec176e
fix broken imports
marcaaron 5766871
Implement iOS
marcaaron 4499c7e
remove new line
marcaaron 515c1f4
Merge remote-tracking branch 'origin' into marcaaron-desktopbadge
marcaaron f83cfe7
create a index.desktop.js and index.website.js file
marcaaron 2ddade2
add android and ios
marcaaron f6b9958
fix comment
marcaaron a7f2d58
fix conflict
marcaaron 4608b09
eslint likes new lines
marcaaron 21a950b
fix index.website.js bundler for cross platform and fix import
roryabraham 34d66f5
remove unnecessary blacklist code
roryabraham a1532f5
fix conflicts
marcaaron dd72182
fix conflicts
marcaaron 26a6ced
Merge branch 'marcaaron-desktopbadge' of https://github.com/Expensify…
marcaaron a5792ce
use Math.max remove new line
marcaaron c640d6f
Fix bug where chat reports would not showing up as unread
marcaaron 0dbb4cf
fix conflicts
marcaaron 92bf235
woops
marcaaron 71fd6aa
remove unneeded stuff
marcaaron 2f2fb02
update names of methods and move to sign out area
marcaaron 58793f6
derp
marcaaron 30dfd18
woops snuck in old change
marcaaron 427185a
derp
marcaaron 8e5ead8
add Podfile.lock back
marcaaron 70a5b46
fix podfile
marcaaron aa1f1bd
make these constants consistent
marcaaron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const ELECTRON_EVENTS = { | ||
REQUEST_UPDATE_BADGE_COUNT: 'request-update-badge-count', | ||
REQUEST_VISIBILITY: 'request_visibility', | ||
}; | ||
|
||
module.exports = ELECTRON_EVENTS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>aps-environment</key> | ||
<string>development</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
* @format | ||
*/ | ||
|
||
|
||
module.exports = { | ||
transformer: { | ||
getTransformOptions: async () => ({ | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import _ from 'underscore'; | ||
marcaaron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import Ion from '../Ion'; | ||
import IONKEYS from '../../IONKEYS'; | ||
import updateUnread from './updateUnread'; | ||
|
||
// Stash the unread action counts for each report | ||
const unreadActionCounts = {}; | ||
|
||
/** | ||
* Updates the title and favicon of the current browser tab | ||
* and Mac OS or iOS dock icon with an unread indicator. | ||
*/ | ||
const throttledUpdatePageTitleAndUnreadCount = _.throttle(() => { | ||
const totalCount = _.reduce(unreadActionCounts, (total, reportCount) => total + reportCount, 0); | ||
updateUnread(totalCount); | ||
}, 1000, {leading: false}); | ||
|
||
let connectionID; | ||
|
||
/** | ||
* Bind to the report collection key and update | ||
* the title and unread count indicators | ||
*/ | ||
function init() { | ||
connectionID = Ion.connect({ | ||
key: IONKEYS.COLLECTION.REPORT, | ||
callback: (report) => { | ||
if (!report || !report.reportID) { | ||
return; | ||
} | ||
|
||
unreadActionCounts[report.reportID] = report.unreadActionCount || 0; | ||
throttledUpdatePageTitleAndUnreadCount(); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Remove the subscription callback when we no longer need it. | ||
*/ | ||
function destroy() { | ||
Ion.disconnect(connectionID); | ||
} | ||
|
||
export default { | ||
init, | ||
destroy, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Android does not yet implement this | ||
export default () => {}; |
16 changes: 16 additions & 0 deletions
16
src/lib/UnreadIndicatorUpdater/updateUnread/index.desktop.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import ELECTRON_EVENTS from '../../../../desktop/ELECTRON_EVENTS'; | ||
|
||
const ipcRenderer = window.require('electron').ipcRenderer; | ||
|
||
/** | ||
* Set the badge on desktop | ||
* | ||
* @param {Number} totalCount | ||
*/ | ||
function updateUnread(totalCount) { | ||
// Ask the main Electron process to update our | ||
// badge count in the Mac OS dock icon | ||
ipcRenderer.send(ELECTRON_EVENTS.REQUEST_UPDATE_BADGE_COUNT, totalCount); | ||
} | ||
|
||
export default updateUnread; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import PushNotificationIOS from '@react-native-community/push-notification-ios'; | ||
|
||
/** | ||
* Set the App Icon badge with the number of | ||
* unread messages on iOS | ||
* | ||
* @param {Number} totalCount | ||
*/ | ||
function updateUnread(totalCount) { | ||
PushNotificationIOS.setApplicationIconBadgeNumber(totalCount); | ||
} | ||
|
||
export default updateUnread; |
13 changes: 7 additions & 6 deletions
13
src/lib/PageTitleUpdater/index.js → ...atorUpdater/updateUnread/index.website.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
/** | ||
* Web browsers have a tab title and favicon which can be updated to show there are unread comments | ||
*/ | ||
import CONFIG from '../../CONFIG'; | ||
import CONFIG from '../../../CONFIG'; | ||
|
||
/** | ||
* Updates the title and favicon of the current browser tab with an unread indicator | ||
* Set the page title on web | ||
* | ||
* @param {boolean} hasUnread | ||
* @param {Number} totalCount | ||
*/ | ||
const PageTitleUpdater = (hasUnread) => { | ||
function updateUnread(totalCount) { | ||
const hasUnread = totalCount > 0; | ||
document.title = hasUnread ? `(NEW!) ${CONFIG.SITE_TITLE}` : CONFIG.SITE_TITLE; | ||
document.getElementById('favicon').href = hasUnread ? CONFIG.FAVICON.UNREAD : CONFIG.FAVICON.DEFAULT; | ||
}; | ||
} | ||
|
||
export default PageTitleUpdater; | ||
export default updateUnread; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary extra space