remove memoization

This commit is contained in:
=
2021-07-23 17:15:35 +02:00
parent 4e75007362
commit f5ca0f9ef5

View File

@@ -56,7 +56,6 @@ export class MattermostView extends EventEmitter {
*/ */
usesAsteriskForUnreads?: boolean; usesAsteriskForUnreads?: boolean;
faviconMemoize: Map<string, boolean>;
currentFavicon?: string; currentFavicon?: string;
isInitialized: boolean; isInitialized: boolean;
hasBeenShown: boolean; hasBeenShown: boolean;
@@ -89,7 +88,6 @@ export class MattermostView extends EventEmitter {
this.view = new BrowserView(this.options); this.view = new BrowserView(this.options);
this.resetLoadingStatus(); this.resetLoadingStatus();
this.faviconMemoize = new Map();
log.info(`BrowserView created for server ${this.tab.name}`); log.info(`BrowserView created for server ${this.tab.name}`);
this.isInitialized = false; this.isInitialized = false;
@@ -339,13 +337,9 @@ export class MattermostView extends EventEmitter {
// 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];
if (this.faviconMemoize.has(favicons[0])) {
appState.updateUnreads(this.tab.name, Boolean(this.faviconMemoize.get(favicons[0])));
} else {
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
findUnreadState = (favicon: string | null) => { findUnreadState = (favicon: string | null) => {
@@ -361,12 +355,7 @@ export class MattermostView extends EventEmitter {
// so don't memoize as we don't have the favicons and there is no rush to find out. // so don't memoize as we don't have the favicons and there is no rush to find out.
handleFaviconIsUnread = (e: Event, favicon: string, viewName: string, result: boolean) => { handleFaviconIsUnread = (e: Event, favicon: string, viewName: string, result: boolean) => {
if (this.tab && viewName === this.tab.name) { if (this.tab && viewName === this.tab.name) {
if (favicon) {
this.faviconMemoize.set(favicon, result);
}
if (!favicon || favicon === this.currentFavicon) {
appState.updateUnreads(viewName, result); appState.updateUnreads(viewName, result);
} }
} }
}
} }