evict cached previews when file gets deleted

This commit is contained in:
Daniel Gultsch 2020-01-20 10:54:55 +01:00
parent 66da5ffb6c
commit 843d7fe12d
3 changed files with 12 additions and 0 deletions

View file

@ -508,6 +508,8 @@ public class FileBackend {
return getFile(message, true);
}
public DownloadableFile getFileForPath(String path) {
return getFileForPath(path, MimeUtils.guessMimeTypeFromExtension(MimeUtils.extractRelevantExtension(path)));
}

View file

@ -1854,6 +1854,9 @@ public class XmppConnectionService extends Service {
for (Conversation conversation : getConversations()) {
deleted |= conversation.markAsDeleted(uuids);
}
for(final String uuid : uuids) {
evictPreview(uuid);
}
if (deleted) {
updateConversationUi();
}
@ -4575,6 +4578,12 @@ public class XmppConnectionService extends Service {
sendIqPacket(account, set, null);
}
public void evictPreview(String uuid) {
if (mBitmapCache.remove(uuid) != null) {
Log.d(Config.LOGTAG,"deleted cached preview");
}
}
public interface OnMamPreferencesFetched {
void onPreferencesFetched(Element prefs);

View file

@ -1653,6 +1653,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) {
message.setDeleted(true);
activity.xmppConnectionService.evictPreview(message.getUuid());
activity.xmppConnectionService.updateMessage(message, false);
activity.onConversationsListItemUpdated();
refresh();