[MM-35666] Re-ordered the priority of badge sources to leave session expired to last (#1955)
* Fixing some annoying things/stuff I broke * [MM-35666] Re-ordered the priority of badge sources to leave session expired to last * Fix tests
This commit is contained in:
parent
c43dfe6002
commit
6803310217
|
@ -202,11 +202,13 @@ describe('main/app/initialize', () => {
|
|||
});
|
||||
|
||||
describe('initializeAfterAppReady', () => {
|
||||
it('should set spell checker URL if applicable', async () => {
|
||||
Config.spellCheckerURL = 'http://server-1.com';
|
||||
await initialize();
|
||||
expect(session.defaultSession.setSpellCheckerDictionaryDownloadURL).toHaveBeenCalledWith('http://server-1.com/');
|
||||
});
|
||||
if (process.platform !== 'darwin') {
|
||||
it('should set spell checker URL if applicable', async () => {
|
||||
Config.spellCheckerURL = 'http://server-1.com';
|
||||
await initialize();
|
||||
expect(session.defaultSession.setSpellCheckerDictionaryDownloadURL).toHaveBeenCalledWith('http://server-1.com/');
|
||||
});
|
||||
}
|
||||
|
||||
it('should clear app cache if last version opened was older', async () => {
|
||||
wasUpdated.mockReturnValue(true);
|
||||
|
|
|
@ -27,17 +27,17 @@ jest.mock('./windows/windowManager', () => ({
|
|||
describe('main/badge', () => {
|
||||
describe('showBadgeWindows', () => {
|
||||
it('should show dot when session expired', () => {
|
||||
Badge.showBadgeWindows(true, 7, false);
|
||||
Badge.showBadgeWindows(true, 0, false);
|
||||
expect(WindowManager.setOverlayIcon).toBeCalledWith('•', expect.any(String), expect.any(Boolean));
|
||||
});
|
||||
|
||||
it('should show mention count when has mention count', () => {
|
||||
Badge.showBadgeWindows(false, 50, false);
|
||||
Badge.showBadgeWindows(true, 50, false);
|
||||
expect(WindowManager.setOverlayIcon).toBeCalledWith('50', expect.any(String), false);
|
||||
});
|
||||
|
||||
it('should show 99+ when has mention count over 99', () => {
|
||||
Badge.showBadgeWindows(false, 200, false);
|
||||
Badge.showBadgeWindows(true, 200, false);
|
||||
expect(WindowManager.setOverlayIcon).toBeCalledWith('99+', expect.any(String), true);
|
||||
});
|
||||
|
||||
|
@ -56,12 +56,12 @@ describe('main/badge', () => {
|
|||
|
||||
describe('showBadgeOSX', () => {
|
||||
it('should show dot when session expired', () => {
|
||||
Badge.showBadgeOSX(true, 7, false);
|
||||
Badge.showBadgeOSX(true, 0, false);
|
||||
expect(app.dock.setBadge).toBeCalledWith('•');
|
||||
});
|
||||
|
||||
it('should show mention count when has mention count', () => {
|
||||
Badge.showBadgeOSX(false, 50, false);
|
||||
Badge.showBadgeOSX(true, 50, false);
|
||||
expect(app.dock.setBadge).toBeCalledWith('50');
|
||||
});
|
||||
|
||||
|
|
|
@ -16,27 +16,27 @@ let showUnreadBadgeSetting: boolean;
|
|||
export function showBadgeWindows(sessionExpired: boolean, mentionCount: number, showUnreadBadge: boolean) {
|
||||
let description = 'You have no unread messages';
|
||||
let text;
|
||||
if (sessionExpired) {
|
||||
text = '•';
|
||||
description = 'Session Expired: Please sign in to continue receiving notifications.';
|
||||
} else if (mentionCount > 0) {
|
||||
if (mentionCount > 0) {
|
||||
text = (mentionCount > MAX_WIN_COUNT) ? `${MAX_WIN_COUNT}+` : mentionCount.toString();
|
||||
description = `You have unread mentions (${mentionCount})`;
|
||||
} else if (showUnreadBadge && showUnreadBadgeSetting) {
|
||||
text = '•';
|
||||
description = 'You have unread channels';
|
||||
} else if (sessionExpired) {
|
||||
text = '•';
|
||||
description = 'Session Expired: Please sign in to continue receiving notifications.';
|
||||
}
|
||||
WindowManager.setOverlayIcon(text, description, mentionCount > 99);
|
||||
}
|
||||
|
||||
export function showBadgeOSX(sessionExpired: boolean, mentionCount: number, showUnreadBadge: boolean) {
|
||||
let badge = '';
|
||||
if (sessionExpired) {
|
||||
badge = '•';
|
||||
} else if (mentionCount > 0) {
|
||||
if (mentionCount > 0) {
|
||||
badge = mentionCount.toString();
|
||||
} else if (showUnreadBadge && showUnreadBadgeSetting) {
|
||||
badge = '•';
|
||||
} else if (sessionExpired) {
|
||||
badge = '•';
|
||||
}
|
||||
app.dock.setBadge(badge);
|
||||
}
|
||||
|
|
|
@ -149,13 +149,6 @@ window.addEventListener('message', ({origin, data = {}} = {}) => {
|
|||
ipcRenderer.send(BROWSER_HISTORY_BUTTON, viewName);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (typeof type === 'undefined') {
|
||||
console.log('ignoring message of undefined type:');
|
||||
console.log(data);
|
||||
} else {
|
||||
console.log(`ignored message of type: ${type}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -93,12 +93,12 @@ export function setupTray(icontheme: string) {
|
|||
});
|
||||
|
||||
AppState.on(UPDATE_TRAY, (anyExpired, anyMentions, anyUnreads) => {
|
||||
if (anyExpired) {
|
||||
setTray('mention', 'Session Expired: Please sign in to continue receiving notifications.');
|
||||
} else if (anyMentions) {
|
||||
if (anyMentions) {
|
||||
setTray('mention', 'You have been mentioned');
|
||||
} else if (anyUnreads) {
|
||||
setTray('unread', 'You have unread channels');
|
||||
} else if (anyExpired) {
|
||||
setTray('mention', 'Session Expired: Please sign in to continue receiving notifications.');
|
||||
} else {
|
||||
setTray('normal', app.name);
|
||||
}
|
||||
|
|
|
@ -310,7 +310,7 @@ describe('main/views/MattermostView', () => {
|
|||
});
|
||||
|
||||
describe('updateMentionsFromTitle', () => {
|
||||
const mattermostView = new MattermostView(tabView, {remoteInfo: {serverVersion: '5.28.0'}}, {}, {});
|
||||
const mattermostView = new MattermostView(tabView, {}, {}, {});
|
||||
|
||||
it('should parse mentions from title', () => {
|
||||
mattermostView.updateMentionsFromTitle('(7) Mattermost');
|
||||
|
|
|
@ -335,10 +335,6 @@ export class MattermostView extends EventEmitter {
|
|||
}
|
||||
|
||||
updateMentionsFromTitle = (title: string) => {
|
||||
if (this.serverInfo.remoteInfo.serverVersion && Util.isVersionGreaterThanOrEqualTo(this.serverInfo.remoteInfo.serverVersion, '5.29.0')) {
|
||||
return;
|
||||
}
|
||||
|
||||
//const title = this.view.webContents.getTitle();
|
||||
const resultsIterator = title.matchAll(this.titleParser);
|
||||
const results = resultsIterator.next(); // we are only interested in the first set
|
||||
|
|
Loading…
Reference in a new issue