mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-22 19:14:52 +01:00
wait for attachment to be uploaded in send queue
also expose attachment from PendingEvent(Entry)
This commit is contained in:
parent
48cd4ac95d
commit
af4f3f902f
@ -15,8 +15,9 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
export class PendingEvent {
|
||||
constructor(data) {
|
||||
constructor(data, attachment) {
|
||||
this._data = data;
|
||||
this.attachment = attachment;
|
||||
}
|
||||
|
||||
get roomId() { return this._data.roomId; }
|
||||
|
@ -51,6 +51,11 @@ export class SendQueue {
|
||||
this._amountSent += 1;
|
||||
continue;
|
||||
}
|
||||
if (pendingEvent.attachment) {
|
||||
const {attachment} = pendingEvent;
|
||||
await attachment.uploaded();
|
||||
attachment.applyToContent(pendingEvent.content);
|
||||
}
|
||||
if (pendingEvent.needsEncryption) {
|
||||
const {type, content} = await this._roomEncryption.encrypt(
|
||||
pendingEvent.eventType, pendingEvent.content, this._hsApi);
|
||||
@ -116,8 +121,8 @@ export class SendQueue {
|
||||
}
|
||||
}
|
||||
|
||||
async enqueueEvent(eventType, content) {
|
||||
const pendingEvent = await this._createAndStoreEvent(eventType, content);
|
||||
async enqueueEvent(eventType, content, attachment) {
|
||||
const pendingEvent = await this._createAndStoreEvent(eventType, content, attachment);
|
||||
this._pendingEvents.set(pendingEvent);
|
||||
console.log("added to _pendingEvents set", this._pendingEvents.length);
|
||||
if (!this._isSending && !this._offline) {
|
||||
@ -150,7 +155,7 @@ export class SendQueue {
|
||||
await txn.complete();
|
||||
}
|
||||
|
||||
async _createAndStoreEvent(eventType, content) {
|
||||
async _createAndStoreEvent(eventType, content, attachment) {
|
||||
console.log("_createAndStoreEvent");
|
||||
const txn = this._storage.readWriteTxn([this._storage.storeNames.pendingEvents]);
|
||||
let pendingEvent;
|
||||
@ -167,7 +172,7 @@ export class SendQueue {
|
||||
content,
|
||||
txnId: makeTxnId(),
|
||||
needsEncryption: !!this._roomEncryption
|
||||
});
|
||||
}, attachment);
|
||||
console.log("_createAndStoreEvent: adding to pendingEventsStore");
|
||||
pendingEventsStore.add(pendingEvent.data);
|
||||
} catch (err) {
|
||||
|
@ -64,6 +64,10 @@ export class PendingEventEntry extends BaseEntry {
|
||||
return this._pendingEvent.txnId;
|
||||
}
|
||||
|
||||
get attachment() {
|
||||
return this._pendingEvent.attachment;
|
||||
}
|
||||
|
||||
notifyUpdate() {
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user