[MM-46405] Drop support for asterisk-based unreads (#2239)
This commit is contained in:
@@ -342,17 +342,12 @@ describe('main/views/MattermostView', () => {
|
|||||||
|
|
||||||
it('should parse mentions from title', () => {
|
it('should parse mentions from title', () => {
|
||||||
mattermostView.updateMentionsFromTitle('(7) Mattermost');
|
mattermostView.updateMentionsFromTitle('(7) Mattermost');
|
||||||
expect(appState.updateMentions).toHaveBeenCalledWith(mattermostView.tab.name, 7, undefined);
|
expect(appState.updateMentions).toHaveBeenCalledWith(mattermostView.tab.name, 7);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should parse unreads from title', () => {
|
it('should parse unreads from title', () => {
|
||||||
mattermostView.updateMentionsFromTitle('* Mattermost');
|
mattermostView.updateMentionsFromTitle('* Mattermost');
|
||||||
expect(appState.updateMentions).toHaveBeenCalledWith(mattermostView.tab.name, 0, true);
|
expect(appState.updateMentions).toHaveBeenCalledWith(mattermostView.tab.name, 0);
|
||||||
});
|
|
||||||
|
|
||||||
it('should not parse unreads when title is on a channel with an asterisk before it', () => {
|
|
||||||
mattermostView.updateMentionsFromTitle('*testChannel - Mattermost');
|
|
||||||
expect(appState.updateMentions).toHaveBeenCalledWith(mattermostView.tab.name, 0, false);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -39,7 +39,6 @@ export enum Status {
|
|||||||
ERROR = -1,
|
ERROR = -1,
|
||||||
}
|
}
|
||||||
|
|
||||||
const ASTERISK_GROUP = 3;
|
|
||||||
const MENTIONS_GROUP = 2;
|
const MENTIONS_GROUP = 2;
|
||||||
|
|
||||||
export class MattermostView extends EventEmitter {
|
export class MattermostView extends EventEmitter {
|
||||||
@@ -54,12 +53,6 @@ export class MattermostView extends EventEmitter {
|
|||||||
|
|
||||||
removeLoading?: number;
|
removeLoading?: number;
|
||||||
|
|
||||||
/**
|
|
||||||
* for backward compatibility when reading the title.
|
|
||||||
* null means we have yet to figure out if it uses it or not but we consider it false until proven wrong
|
|
||||||
*/
|
|
||||||
usesAsteriskForUnreads?: boolean;
|
|
||||||
|
|
||||||
currentFavicon?: string;
|
currentFavicon?: string;
|
||||||
hasBeenShown: boolean;
|
hasBeenShown: boolean;
|
||||||
contextMenu: ContextMenu;
|
contextMenu: ContextMenu;
|
||||||
@@ -391,33 +384,20 @@ export class MattermostView extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateMentionsFromTitle = (title: string) => {
|
updateMentionsFromTitle = (title: string) => {
|
||||||
//const title = this.view.webContents.getTitle();
|
|
||||||
const resultsIterator = title.matchAll(this.titleParser);
|
const resultsIterator = title.matchAll(this.titleParser);
|
||||||
const results = resultsIterator.next(); // we are only interested in the first set
|
const results = resultsIterator.next(); // we are only interested in the first set
|
||||||
|
|
||||||
// if not using asterisk (version > v5.28), it'll be marked as undefined and wont be used to check if there are unread channels
|
|
||||||
const hasAsterisk = results && results.value && results.value[ASTERISK_GROUP];
|
|
||||||
if (typeof hasAsterisk !== 'undefined') {
|
|
||||||
this.usesAsteriskForUnreads = true;
|
|
||||||
}
|
|
||||||
let unreads;
|
|
||||||
if (this.usesAsteriskForUnreads) {
|
|
||||||
unreads = Boolean(hasAsterisk);
|
|
||||||
}
|
|
||||||
const mentions = (results && results.value && parseInt(results.value[MENTIONS_GROUP], 10)) || 0;
|
const mentions = (results && results.value && parseInt(results.value[MENTIONS_GROUP], 10)) || 0;
|
||||||
|
|
||||||
appState.updateMentions(this.tab.name, mentions, unreads);
|
appState.updateMentions(this.tab.name, mentions);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFaviconUpdate = (e: Event, favicons: string[]) => {
|
handleFaviconUpdate = (e: Event, favicons: string[]) => {
|
||||||
log.silly('MattermostView.handleFaviconUpdate', {tabName: this.tab.name, favicons});
|
log.silly('MattermostView.handleFaviconUpdate', {tabName: this.tab.name, favicons});
|
||||||
|
|
||||||
if (!this.usesAsteriskForUnreads) {
|
// if unread state is stored for that favicon, retrieve value.
|
||||||
// if unread state is stored for that favicon, retrieve value.
|
// if not, get related info from preload and store it for future changes
|
||||||
// if not, get related info from preload and store it for future changes
|
this.currentFavicon = favicons[0];
|
||||||
this.currentFavicon = favicons[0];
|
this.findUnreadState(favicons[0]);
|
||||||
this.findUnreadState(favicons[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if favicon is null, it will affect appState, but won't be memoized
|
// if favicon is null, it will affect appState, but won't be memoized
|
||||||
|
Reference in New Issue
Block a user