diff --git a/app/profile_images.js b/app/profile_images.js deleted file mode 100644 index b2752215c..000000000 --- a/app/profile_images.js +++ /dev/null @@ -1,44 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -const { app } = require('electron').remote; - -const userDataPath = app.getPath('userData'); -const PATH = path.join(userDataPath, 'profileImages'); -fs.mkdirSync(PATH, { recursive: true }); - -const hasImage = pubKey => fs.existsSync(getImagePath(pubKey)); - -const getImagePath = pubKey => `${PATH}/${pubKey}.png`; - -const removeImage = pubKey => { - if (hasImage(pubKey)) { - fs.unlinkSync(getImagePath(pubKey)); - } -}; - -const removeImagesNotInArray = pubKeyArray => { - fs.readdirSync(PATH) - // Get all files that end with png - .filter(file => file.includes('.png')) - // Strip the extension - .map(i => path.basename(i, '.png')) - // Get any file that is not in the pubKeyArray - .filter(i => !pubKeyArray.includes(i)) - // Remove them - .forEach(i => removeImage(i)); -}; - -const writePNGImage = (base64String, pubKey) => { - const imagePath = getImagePath(pubKey); - fs.writeFileSync(imagePath, base64String, 'base64'); - return imagePath; -}; - -module.exports = { - writePNGImage, - getImagePath, - hasImage, - removeImage, - removeImagesNotInArray, -}; diff --git a/app/sql.js b/app/sql.js index afbc31105..47a8ad6ad 100644 --- a/app/sql.js +++ b/app/sql.js @@ -1858,6 +1858,9 @@ function searchConversations(query, { limit } = {}) { const orderByMessageCoalesceClause = `ORDER BY COALESCE(${MESSAGES_TABLE}.serverTimestamp, ${MESSAGES_TABLE}.sent_at, ${MESSAGES_TABLE}.received_at) DESC`; function searchMessages(query, limit) { + if (!limit) { + throw new Error('searchMessages limit must be set'); + } const rows = globalInstance .prepare( `SELECT @@ -1872,7 +1875,7 @@ function searchMessages(query, limit) { ) .all({ query, - limit: limit || 100, + limit, }); return map(rows, row => ({ diff --git a/preload.js b/preload.js index 88e2efaeb..81e7d40ec 100644 --- a/preload.js +++ b/preload.js @@ -221,7 +221,6 @@ setInterval(() => { window.loadImage = require('blueimp-load-image'); window.filesize = require('filesize'); -window.profileImages = require('./app/profile_images'); window.React = require('react'); window.ReactDOM = require('react-dom'); diff --git a/ts/components/dialog/UpdateGroupMembersDialog.tsx b/ts/components/dialog/UpdateGroupMembersDialog.tsx index 2f08706df..b99fda4b9 100644 --- a/ts/components/dialog/UpdateGroupMembersDialog.tsx +++ b/ts/components/dialog/UpdateGroupMembersDialog.tsx @@ -103,13 +103,6 @@ const ZombiesList = ({ convoId }: { convoId: string }) => { ); }; -// // Return members that would comprise the group given the -// // current state in `users` -// private getWouldBeMembers(users: Array) { -// return users.filter(d => { -// return (d.existingMember && !d.checkmarked) || (!d.existingMember && d.checkmarked); -// }); -// } // tslint:disable-next-line: max-func-body-length async function onSubmit(convoId: string, membersAfterUpdate: Array) { diff --git a/ts/components/leftpane/conversation-list-item/ConversationListItem.tsx b/ts/components/leftpane/conversation-list-item/ConversationListItem.tsx index 9f592d01a..791318bd2 100644 --- a/ts/components/leftpane/conversation-list-item/ConversationListItem.tsx +++ b/ts/components/leftpane/conversation-list-item/ConversationListItem.tsx @@ -25,7 +25,7 @@ import _ from 'lodash'; // tslint:disable-next-line: no-empty-interface export type ConversationListItemProps = Pick< ReduxConversationType, - 'unreadCount' | 'id' | 'isSelected' | 'isBlocked' | 'mentionedUs' | 'unreadCount' | 'profileName' + 'id' | 'isSelected' | 'isBlocked' | 'mentionedUs' | 'unreadCount' | 'profileName' >; /** diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 32dec6c91..1c46cb867 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -292,19 +292,6 @@ export class ConversationModel extends Backbone.Model { public async cleanup() { await deleteExternalFilesOfConversation(this.attributes); - window.profileImages.removeImage(this.id); - } - - public async updateProfileAvatar() { - if (this.isPublic()) { - return; - } - - // Remove old identicons - if (window.profileImages.hasImage(this.id)) { - window.profileImages.removeImage(this.id); - await this.setProfileAvatar(null); - } } public async onExpired(_message: MessageModel) { @@ -1147,13 +1134,6 @@ export class ConversationModel extends Backbone.Model { } } - public async setGroupName(name: string) { - const profileName = this.get('name'); - if (profileName !== name) { - this.set({ name }); - await this.commit(); - } - } public async setSubscriberCount(count: number) { if (this.get('subscriberCount') !== count) { this.set({ subscriberCount: count }); diff --git a/ts/session/conversations/ConversationController.ts b/ts/session/conversations/ConversationController.ts index e35ce9f96..25863d665 100644 --- a/ts/session/conversations/ConversationController.ts +++ b/ts/session/conversations/ConversationController.ts @@ -110,7 +110,7 @@ export class ConversationController { }; conversation.initialPromise = create(); - conversation.initialPromise.then(async () => { + conversation.initialPromise.then(() => { if (window?.inboxStore) { window.inboxStore?.dispatch( conversationActions.conversationAdded({ @@ -120,11 +120,9 @@ export class ConversationController { ); } if (!conversation.isPublic()) { - await Promise.all([ - conversation.updateProfileAvatar(), - // NOTE: we request snodes updating the cache, but ignore the result - void getSwarmFor(id), - ]); + // NOTE: we request snodes updating the cache, but ignore the result + + void getSwarmFor(id); } }); @@ -274,13 +272,10 @@ export class ConversationController { promises.push(conversation.updateLastMessage()); } - promises.concat([conversation.updateProfileName(), conversation.updateProfileAvatar()]); + promises.concat([conversation.updateProfileName()]); }); await Promise.all(promises); - - // Remove any unused images - window.profileImages.removeImagesNotInArray(this.conversations.map((c: any) => c.id)); window?.log?.info('ConversationController: done with initial fetch'); } catch (error) { window?.log?.error( diff --git a/ts/test/session/unit/swarm_polling/SwarmPolling_test.ts b/ts/test/session/unit/swarm_polling/SwarmPolling_test.ts index 3b12d11c8..28fcfb5fe 100644 --- a/ts/test/session/unit/swarm_polling/SwarmPolling_test.ts +++ b/ts/test/session/unit/swarm_polling/SwarmPolling_test.ts @@ -18,7 +18,6 @@ import { ConversationTypeEnum, } from '../../../../models/conversation'; import { PubKey } from '../../../../session/types'; -import { noop } from 'lodash'; import { generateFakeSnodes } from '../../../test-utils/utils'; // tslint:disable: chai-vague-errors @@ -52,7 +51,6 @@ describe('SwarmPolling', () => { sandbox.stub(SnodePool, 'getSwarmFor').resolves(generateFakeSnodes(5)); sandbox.stub(SNodeAPI, 'retrieveNextMessages').resolves([]); - TestUtils.stubWindow('profileImages', { removeImagesNotInArray: noop, hasImage: noop }); TestUtils.stubWindow('inboxStore', undefined); TestUtils.stubWindow('getGlobalOnlineStatus', () => true); TestUtils.stubWindowLog(); diff --git a/ts/window.d.ts b/ts/window.d.ts index 505c9b3b3..a89d6ecc1 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -60,7 +60,6 @@ declare global { userConfig: any; versionInfo: any; getConversations: () => ConversationCollection; - profileImages: any; MediaRecorder: any; contextMenuShown: boolean;