diff --git a/background.html b/background.html
index 40f80d749..7f8ae5237 100644
--- a/background.html
+++ b/background.html
@@ -31,15 +31,6 @@
When making changes to these templates, be sure to update test/index.html as well
-->
-
-
@@ -59,7 +50,6 @@
-
diff --git a/background_test.html b/background_test.html
index b70961c69..cf21b58a0 100644
--- a/background_test.html
+++ b/background_test.html
@@ -31,15 +31,6 @@
When making changes to these templates, be sure to update test/index.html as well
-->
-
-
@@ -60,7 +51,6 @@
-
diff --git a/js/notifications.js b/js/notifications.js
index f96f5db12..b7639bbfd 100644
--- a/js/notifications.js
+++ b/js/notifications.js
@@ -148,7 +148,6 @@
}
drawAttention();
-
this.lastNotification = new Notification(title, {
body: window.platform === 'linux' ? filter(message) : message,
icon: iconUrl,
diff --git a/js/views/identicon_svg_view.js b/js/views/identicon_svg_view.js
deleted file mode 100644
index 0acf9c83b..000000000
--- a/js/views/identicon_svg_view.js
+++ /dev/null
@@ -1,42 +0,0 @@
-/* global Whisper, loadImage */
-
-// eslint-disable-next-line func-names
-(function() {
- 'use strict';
-
- window.Whisper = window.Whisper || {};
-
- /*
- * Render an avatar identicon to an svg for use in a notification.
- */
- Whisper.IdenticonSVGView = Whisper.View.extend({
- templateName: 'identicon-svg',
- initialize(options) {
- this.render_attributes = options;
- },
- getSVGUrl() {
- const html = this.render().$el.html();
- const svg = new Blob([html], { type: 'image/svg+xml;charset=utf-8' });
- return URL.createObjectURL(svg);
- },
- getDataUrl() {
- const svgurl = this.getSVGUrl();
- return new Promise(resolve => {
- const img = document.createElement('img');
- img.onload = () => {
- const canvas = loadImage.scale(img, {
- canvas: true,
- maxWidth: 100,
- maxHeight: 100,
- });
- const ctx = canvas.getContext('2d');
- ctx.drawImage(img, 0, 0);
- URL.revokeObjectURL(svgurl);
- resolve(canvas.toDataURL('image/png'));
- };
-
- img.src = svgurl;
- });
- },
- });
-})();
diff --git a/ts/components/session/SessionClosableOverlay.tsx b/ts/components/session/SessionClosableOverlay.tsx
index ec1168465..51511bb10 100644
--- a/ts/components/session/SessionClosableOverlay.tsx
+++ b/ts/components/session/SessionClosableOverlay.tsx
@@ -48,7 +48,6 @@ export class SessionClosableOverlay extends React.Component {
this.inputRef = React.createRef();
this.onKeyUp = this.onKeyUp.bind(this);
this.onGroupNameChanged = this.onGroupNameChanged.bind(this);
-
}
public componentDidMount() {
@@ -60,7 +59,6 @@ export class SessionClosableOverlay extends React.Component {
}
public componentWillUnmount() {
window.removeEventListener('keyup', this.onKeyUp);
-
}
public getContacts() {
diff --git a/ts/components/session/usingClosedConversationDetails.tsx b/ts/components/session/usingClosedConversationDetails.tsx
index 0742fdfdd..467814a8d 100644
--- a/ts/components/session/usingClosedConversationDetails.tsx
+++ b/ts/components/session/usingClosedConversationDetails.tsx
@@ -55,7 +55,7 @@ export function usingClosedConversationDetails(WrappedComponent: any) {
const memberConvos = _.compact(members.map(m => getConversationController().get(m.key)));
const memberAvatars = memberConvos.map(m => {
return {
- avatarPath: m.getAvatar()?.url || undefined,
+ avatarPath: m.getAvatarPath() || undefined,
id: m.id,
name: m.get('name') || m.get('profileName') || m.id,
};
diff --git a/ts/hooks/useMembersAvatar.tsx b/ts/hooks/useMembersAvatar.tsx
index df1fb22ec..5821c126c 100644
--- a/ts/hooks/useMembersAvatar.tsx
+++ b/ts/hooks/useMembersAvatar.tsx
@@ -38,7 +38,7 @@ export function useMembersAvatars(conversation: ReduxConversationType | undefine
);
const memberAvatars = memberConvos.map(m => {
return {
- avatarPath: m.getAvatar()?.url || undefined,
+ avatarPath: m.getAvatarPath() || undefined,
id: m.id as string,
name: (m.get('name') || m.get('profileName') || m.id) as string,
};
diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts
index 0cebdaf04..c4b25c26f 100644
--- a/ts/models/conversation.ts
+++ b/ts/models/conversation.ts
@@ -48,6 +48,8 @@ import {
SendMessageType,
} from '../components/session/conversation/SessionCompositionBox';
import { ed25519Str } from '../session/onions/onionPath';
+import { getDecryptedMediaUrl } from '../session/crypto/DecryptedAttachmentsManager';
+import { IMAGE_JPEG } from '../types/MIME';
export enum ConversationTypeEnum {
GROUP = 'group',
@@ -1375,21 +1377,21 @@ export class ConversationModel extends Backbone.Model {
return null;
}
- public getAvatar() {
- const url = this.getAvatarPath();
-
- return { url: url || null };
- }
public async getNotificationIcon() {
- return new Promise(resolve => {
- const avatar = this.getAvatar();
- if (avatar.url) {
- resolve(avatar.url);
- } else {
- resolve(new window.Whisper.IdenticonSVGView(avatar).getDataUrl());
+ const avatarUrl = this.getAvatarPath();
+ const noIconUrl = 'images/session/session_icon_32.png';
+ if (avatarUrl) {
+ const decryptedAvatarUrl = await getDecryptedMediaUrl(avatarUrl, IMAGE_JPEG);
+
+ if (!decryptedAvatarUrl) {
+ window.log.warn('Could not decrypt avatar stored locally for getNotificationIcon..');
+ return noIconUrl;
}
- });
+ return decryptedAvatarUrl;
+ } else {
+ return noIconUrl;
+ }
}
public async notify(message: MessageModel) {
@@ -1430,7 +1432,7 @@ export class ConversationModel extends Backbone.Model {
ConversationTypeEnum.PRIVATE
);
- const iconUrl = await convo.getNotificationIcon();
+ const iconUrl = await this.getNotificationIcon();
const messageJSON = message.toJSON();
const messageSentAt = messageJSON.sent_at;