mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
feature-gate calls everywhere in the app
This commit is contained in:
parent
f86663fe7b
commit
22a8182266
@ -130,10 +130,12 @@ export class SessionViewModel extends ViewModel {
|
||||
|
||||
start() {
|
||||
this._sessionStatusViewModel.start();
|
||||
if (this.features.calls) {
|
||||
this._client.session.callHandler.loadCalls("m.ring");
|
||||
// TODO: only do this when opening the room
|
||||
this._client.session.callHandler.loadCalls("m.prompt");
|
||||
}
|
||||
}
|
||||
|
||||
get activeMiddleViewModel() {
|
||||
return (
|
||||
|
@ -50,6 +50,9 @@ export class RoomViewModel extends ErrorReportViewModel {
|
||||
}
|
||||
|
||||
_setupCallViewModel() {
|
||||
if (!this.features.calls) {
|
||||
return;
|
||||
}
|
||||
// pick call for this room with lowest key
|
||||
const calls = this.getOption("session").callHandler.calls;
|
||||
this._callObservable = new PickMapObservableValue(calls.filterValues(c => {
|
||||
@ -421,6 +424,10 @@ export class RoomViewModel extends ErrorReportViewModel {
|
||||
|
||||
startCall() {
|
||||
return this.logAndCatch("RoomViewModel.startCall", async log => {
|
||||
if (!this.features.calls) {
|
||||
log.set("feature_disbled", true);
|
||||
return;
|
||||
}
|
||||
log.set("roomId", this._room.id);
|
||||
let localMedia;
|
||||
try {
|
||||
|
@ -92,7 +92,7 @@ export function tileClassForEntry(entry: TimelineEntry, options: Options): TileC
|
||||
case "org.matrix.msc3401.call": {
|
||||
// if prevContent is present, it's an update to a call event, which we don't render
|
||||
// as the original event is updated through the call object which receive state event updates
|
||||
if (entry.stateKey && !entry.prevContent) {
|
||||
if (options.features.calls && entry.stateKey && !entry.prevContent) {
|
||||
return CallTile;
|
||||
}
|
||||
return undefined;
|
||||
|
@ -33,9 +33,11 @@ export class ToastCollectionViewModel extends ViewModel<SegmentType, Options> {
|
||||
constructor(options: Options) {
|
||||
super(options);
|
||||
const session = this.getOption("session");
|
||||
if (this.features.calls) {
|
||||
const callsObservableMap = session.callHandler.calls;
|
||||
this.track(callsObservableMap.subscribe(this));
|
||||
}
|
||||
}
|
||||
|
||||
async onAdd(_, call: GroupCall) {
|
||||
if (this._shouldShowNotification(call)) {
|
||||
|
@ -75,6 +75,61 @@ export class Session {
|
||||
};
|
||||
this._roomsBeingCreated = new ObservableMap();
|
||||
this._user = new User(sessionInfo.userId);
|
||||
this._roomStateHandler = new RoomStateHandlerSet();
|
||||
this._deviceMessageHandler = new DeviceMessageHandler({storage, callHandler: this._callHandler});
|
||||
this._olm = olm;
|
||||
this._olmUtil = null;
|
||||
this._e2eeAccount = null;
|
||||
this._deviceTracker = null;
|
||||
this._olmEncryption = null;
|
||||
this._keyLoader = null;
|
||||
this._megolmEncryption = null;
|
||||
this._megolmDecryption = null;
|
||||
this._getSyncToken = () => this.syncToken;
|
||||
this._olmWorker = olmWorker;
|
||||
this._keyBackup = new ObservableValue(undefined);
|
||||
this._observedRoomStatus = new Map();
|
||||
|
||||
if (olm) {
|
||||
this._olmUtil = new olm.Utility();
|
||||
this._deviceTracker = new DeviceTracker({
|
||||
storage,
|
||||
getSyncToken: this._getSyncToken,
|
||||
olmUtil: this._olmUtil,
|
||||
ownUserId: sessionInfo.userId,
|
||||
ownDeviceId: sessionInfo.deviceId,
|
||||
});
|
||||
}
|
||||
this._createRoomEncryption = this._createRoomEncryption.bind(this);
|
||||
this._forgetArchivedRoom = this._forgetArchivedRoom.bind(this);
|
||||
this.needsKeyBackup = new ObservableValue(false);
|
||||
|
||||
if (features.calls) {
|
||||
this._setupCallHandler();
|
||||
}
|
||||
}
|
||||
|
||||
get fingerprintKey() {
|
||||
return this._e2eeAccount?.identityKeys.ed25519;
|
||||
}
|
||||
|
||||
get hasSecretStorageKey() {
|
||||
return this._hasSecretStorageKey;
|
||||
}
|
||||
|
||||
get deviceId() {
|
||||
return this._sessionInfo.deviceId;
|
||||
}
|
||||
|
||||
get userId() {
|
||||
return this._sessionInfo.userId;
|
||||
}
|
||||
|
||||
get callHandler() {
|
||||
return this._callHandler;
|
||||
}
|
||||
|
||||
_setupCallHandler() {
|
||||
this._callHandler = new CallHandler({
|
||||
clock: this._platform.clock,
|
||||
random: this._platform.random,
|
||||
@ -103,55 +158,7 @@ export class Session {
|
||||
logger: this._platform.logger,
|
||||
forceTURN: false,
|
||||
});
|
||||
this._roomStateHandler = new RoomStateHandlerSet();
|
||||
this.observeRoomState(this._callHandler);
|
||||
this._deviceMessageHandler = new DeviceMessageHandler({storage, callHandler: this._callHandler});
|
||||
this._olm = olm;
|
||||
this._olmUtil = null;
|
||||
this._e2eeAccount = null;
|
||||
this._deviceTracker = null;
|
||||
this._olmEncryption = null;
|
||||
this._keyLoader = null;
|
||||
this._megolmEncryption = null;
|
||||
this._megolmDecryption = null;
|
||||
this._getSyncToken = () => this.syncToken;
|
||||
this._olmWorker = olmWorker;
|
||||
this._keyBackup = new ObservableValue(undefined);
|
||||
this._observedRoomStatus = new Map();
|
||||
|
||||
if (olm) {
|
||||
this._olmUtil = new olm.Utility();
|
||||
this._deviceTracker = new DeviceTracker({
|
||||
storage,
|
||||
getSyncToken: this._getSyncToken,
|
||||
olmUtil: this._olmUtil,
|
||||
ownUserId: sessionInfo.userId,
|
||||
ownDeviceId: sessionInfo.deviceId,
|
||||
});
|
||||
}
|
||||
this._createRoomEncryption = this._createRoomEncryption.bind(this);
|
||||
this._forgetArchivedRoom = this._forgetArchivedRoom.bind(this);
|
||||
this.needsKeyBackup = new ObservableValue(false);
|
||||
}
|
||||
|
||||
get fingerprintKey() {
|
||||
return this._e2eeAccount?.identityKeys.ed25519;
|
||||
}
|
||||
|
||||
get hasSecretStorageKey() {
|
||||
return this._hasSecretStorageKey;
|
||||
}
|
||||
|
||||
get deviceId() {
|
||||
return this._sessionInfo.deviceId;
|
||||
}
|
||||
|
||||
get userId() {
|
||||
return this._sessionInfo.userId;
|
||||
}
|
||||
|
||||
get callHandler() {
|
||||
return this._callHandler;
|
||||
}
|
||||
|
||||
// called once this._e2eeAccount is assigned
|
||||
|
@ -73,8 +73,10 @@ export class RoomView extends TemplateView {
|
||||
} else {
|
||||
const vm = this.value;
|
||||
const options = [];
|
||||
options.push(Menu.option(vm.i18n`Room details`, () => vm.openDetailsPanel()))
|
||||
options.push(Menu.option(vm.i18n`Start call`, () => vm.startCall()))
|
||||
options.push(Menu.option(vm.i18n`Room details`, () => vm.openDetailsPanel()));
|
||||
if (vm.features.calls) {
|
||||
options.push(Menu.option(vm.i18n`Start call`, () => vm.startCall()));
|
||||
}
|
||||
if (vm.canLeave) {
|
||||
options.push(Menu.option(vm.i18n`Leave room`, () => this._confirmToLeaveRoom()).setDestructive());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user