Fixes for quotes/schema upgrade, optimize media gallery load
Also: Fix for contact detail page; didn't show back button
This commit is contained in:
parent
95976b10e7
commit
db91560990
6 changed files with 109 additions and 138 deletions
|
@ -167,7 +167,7 @@
|
|||
openConversation(conversation) {
|
||||
if (conversation) {
|
||||
this.openInbox().then(() => {
|
||||
this.inboxView.openConversation(null, conversation);
|
||||
this.inboxView.openConversation(conversation);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
/* global Signal: false */
|
||||
/* global storage: false */
|
||||
/* global Whisper: false */
|
||||
/* global wrapDeferred: false */
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
(function() {
|
||||
|
@ -14,6 +15,11 @@
|
|||
|
||||
window.Whisper = window.Whisper || {};
|
||||
const { Migrations } = Signal;
|
||||
const { Message } = window.Signal.Types;
|
||||
const {
|
||||
upgradeMessageSchema,
|
||||
getAbsoluteAttachmentPath,
|
||||
} = window.Signal.Migrations;
|
||||
|
||||
Whisper.ExpiredToast = Whisper.ToastView.extend({
|
||||
render_attributes() {
|
||||
|
@ -603,13 +609,29 @@
|
|||
}
|
||||
);
|
||||
|
||||
// NOTE: Could we show grid previews from disk as well?
|
||||
const loadMessages = Signal.Components.Types.Message.loadWithObjectURL(
|
||||
Migrations.loadMessage
|
||||
);
|
||||
const media = await loadMessages(rawMedia);
|
||||
// First we upgrade these messages to ensure that they have thumbnails
|
||||
for (let max = rawMedia.length, i = 0; i < max; i += 1) {
|
||||
const message = rawMedia[i];
|
||||
const { schemaVersion } = message;
|
||||
|
||||
if (schemaVersion < Message.CURRENT_SCHEMA_VERSION) {
|
||||
// Yep, we really do want to wait for each of these
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
rawMedia[i] = await upgradeMessageSchema(message);
|
||||
const model = new Whisper.Message(rawMedia[i]);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await wrapDeferred(model.save());
|
||||
}
|
||||
}
|
||||
|
||||
const media = rawMedia.map(mediaMessage =>
|
||||
Object.assign({}, mediaMessage, {
|
||||
objectURL: getAbsoluteAttachmentPath(
|
||||
mediaMessage.attachments[0].path
|
||||
),
|
||||
})
|
||||
);
|
||||
|
||||
const { getAbsoluteAttachmentPath } = Signal.Migrations;
|
||||
const saveAttachment = async ({ message } = {}) => {
|
||||
const attachment = message.attachments[0];
|
||||
const timestamp = message.received_at;
|
||||
|
@ -629,13 +651,6 @@
|
|||
}
|
||||
|
||||
case 'media': {
|
||||
const mediaWithObjectURL = media.map(mediaMessage =>
|
||||
Object.assign({}, mediaMessage, {
|
||||
objectURL: getAbsoluteAttachmentPath(
|
||||
mediaMessage.attachments[0].path
|
||||
),
|
||||
})
|
||||
);
|
||||
const selectedIndex = media.findIndex(
|
||||
mediaMessage => mediaMessage.id === message.id
|
||||
);
|
||||
|
@ -643,7 +658,7 @@
|
|||
className: 'lightbox-wrapper',
|
||||
Component: Signal.Components.LightboxGallery,
|
||||
props: {
|
||||
messages: mediaWithObjectURL,
|
||||
messages: media,
|
||||
onSave: () => saveAttachment({ message }),
|
||||
selectedIndex,
|
||||
},
|
||||
|
@ -1055,6 +1070,7 @@
|
|||
});
|
||||
|
||||
this.listenBack(view);
|
||||
this.updateHeader();
|
||||
},
|
||||
|
||||
async openConversation(number) {
|
||||
|
|
|
@ -247,10 +247,9 @@
|
|||
}
|
||||
},
|
||||
openConversation(conversation) {
|
||||
ConversationController.markAsSelected(conversation);
|
||||
|
||||
this.searchView.hideHints();
|
||||
if (conversation) {
|
||||
ConversationController.markAsSelected(conversation);
|
||||
this.conversation_stack.open(
|
||||
ConversationController.get(conversation.id)
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue