mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
hook it up
This commit is contained in:
parent
c6ff4c2517
commit
44a2febce9
@ -169,6 +169,7 @@ class ComposerViewModel extends ViewModel {
|
|||||||
super();
|
super();
|
||||||
this._roomVM = roomVM;
|
this._roomVM = roomVM;
|
||||||
this._isEmpty = true;
|
this._isEmpty = true;
|
||||||
|
this._ensureKeyPromise = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isEncrypted() {
|
get isEncrypted() {
|
||||||
@ -188,8 +189,16 @@ class ComposerViewModel extends ViewModel {
|
|||||||
return !this._isEmpty;
|
return !this._isEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
setInput(text) {
|
async setInput(text) {
|
||||||
|
const wasEmpty = this._isEmpty;
|
||||||
this._isEmpty = text.length === 0;
|
this._isEmpty = text.length === 0;
|
||||||
this.emitChange("canSend");
|
if (wasEmpty && !this._isEmpty && !this._ensureKeyPromise) {
|
||||||
|
this._ensureKeyPromise = this._roomVM._room.ensureMessageKeyIsShared().then(() => {
|
||||||
|
this._ensureKeyPromise = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (wasEmpty !== this._isEmpty) {
|
||||||
|
this.emitChange("canSend");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,9 +247,10 @@ export class RoomEncryption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** shares the encryption key for the next message if needed */
|
/** shares the encryption key for the next message if needed */
|
||||||
async ensureNextMessageKeyIsShared(hsApi) {
|
async ensureMessageKeyIsShared(hsApi) {
|
||||||
const roomKeyMessage = await this._megolmEncryption.ensureOutboundSession(this._room.id, this._encryptionParams);
|
const roomKeyMessage = await this._megolmEncryption.ensureOutboundSession(this._room.id, this._encryptionParams);
|
||||||
if (roomKeyMessage) {
|
if (roomKeyMessage) {
|
||||||
|
await this._deviceTracker.trackRoom(this._room);
|
||||||
await this._shareNewRoomKey(roomKeyMessage, hsApi);
|
await this._shareNewRoomKey(roomKeyMessage, hsApi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,6 +354,10 @@ export class Room extends EventEmitter {
|
|||||||
return this._sendQueue.enqueueEvent(eventType, content);
|
return this._sendQueue.enqueueEvent(eventType, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async ensureMessageKeyIsShared() {
|
||||||
|
return this._roomEncryption?.ensureMessageKeyIsShared(this._hsApi);
|
||||||
|
}
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
async loadMemberList() {
|
async loadMemberList() {
|
||||||
if (this._memberList) {
|
if (this._memberList) {
|
||||||
|
Loading…
Reference in New Issue
Block a user