mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Click to download avatar for unaccepted conversations
This commit is contained in:
@@ -21,7 +21,7 @@ import { getAuthorId } from './messages/helpers';
|
||||
import { maybeDeriveGroupV2Id } from './groups';
|
||||
import { assertDev, strictAssert } from './util/assert';
|
||||
import { drop } from './util/drop';
|
||||
import { isGroupV1, isGroupV2 } from './util/whatTypeOfConversation';
|
||||
import { isGroup, isGroupV1, isGroupV2 } from './util/whatTypeOfConversation';
|
||||
import type { ServiceIdString, AciString, PniString } from './types/ServiceId';
|
||||
import {
|
||||
isServiceIdString,
|
||||
@@ -39,6 +39,8 @@ import * as StorageService from './services/storage';
|
||||
import type { ConversationPropsForUnreadStats } from './util/countUnreadStats';
|
||||
import { countAllConversationsUnreadStats } from './util/countUnreadStats';
|
||||
import { isTestOrMockEnvironment } from './environment';
|
||||
import { isConversationAccepted } from './util/isConversationAccepted';
|
||||
import { areWePending } from './util/groupMembershipUtils';
|
||||
import { conversationJobQueue } from './jobs/conversationJobQueue';
|
||||
|
||||
type ConvoMatchType =
|
||||
@@ -1372,6 +1374,52 @@ export class ConversationController {
|
||||
this.get(conversationId)?.onOpenComplete(loadStart);
|
||||
}
|
||||
|
||||
migrateAvatarsForNonAcceptedConversations(): void {
|
||||
if (window.storage.get('avatarsHaveBeenMigrated')) {
|
||||
return;
|
||||
}
|
||||
const conversations = this.getAll();
|
||||
let numberOfConversationsMigrated = 0;
|
||||
for (const conversation of conversations) {
|
||||
const attrs = conversation.attributes;
|
||||
if (
|
||||
!isConversationAccepted(attrs) ||
|
||||
(isGroup(attrs) && areWePending(attrs))
|
||||
) {
|
||||
const avatarPath = attrs.avatar?.path;
|
||||
const profileAvatarPath = attrs.profileAvatar?.path;
|
||||
|
||||
if (avatarPath || profileAvatarPath) {
|
||||
drop(
|
||||
(async () => {
|
||||
const { doesAttachmentExist, deleteAttachmentData } =
|
||||
window.Signal.Migrations;
|
||||
if (avatarPath && (await doesAttachmentExist(avatarPath))) {
|
||||
await deleteAttachmentData(avatarPath);
|
||||
}
|
||||
|
||||
if (
|
||||
profileAvatarPath &&
|
||||
(await doesAttachmentExist(profileAvatarPath))
|
||||
) {
|
||||
await deleteAttachmentData(profileAvatarPath);
|
||||
}
|
||||
})()
|
||||
);
|
||||
}
|
||||
|
||||
conversation.set('avatar', undefined);
|
||||
conversation.set('profileAvatar', undefined);
|
||||
drop(updateConversation(conversation.attributes));
|
||||
numberOfConversationsMigrated += 1;
|
||||
}
|
||||
}
|
||||
log.info(
|
||||
`ConversationController: unset avatars for ${numberOfConversationsMigrated} unaccepted conversations`
|
||||
);
|
||||
drop(window.storage.put('avatarsHaveBeenMigrated', true));
|
||||
}
|
||||
|
||||
repairPinnedConversations(): void {
|
||||
const pinnedIds = window.storage.get('pinnedConversationIds', []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user