mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +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() {
|
start() {
|
||||||
this._sessionStatusViewModel.start();
|
this._sessionStatusViewModel.start();
|
||||||
|
if (this.features.calls) {
|
||||||
this._client.session.callHandler.loadCalls("m.ring");
|
this._client.session.callHandler.loadCalls("m.ring");
|
||||||
// TODO: only do this when opening the room
|
// TODO: only do this when opening the room
|
||||||
this._client.session.callHandler.loadCalls("m.prompt");
|
this._client.session.callHandler.loadCalls("m.prompt");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get activeMiddleViewModel() {
|
get activeMiddleViewModel() {
|
||||||
return (
|
return (
|
||||||
|
@ -50,6 +50,9 @@ export class RoomViewModel extends ErrorReportViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_setupCallViewModel() {
|
_setupCallViewModel() {
|
||||||
|
if (!this.features.calls) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// pick call for this room with lowest key
|
// pick call for this room with lowest key
|
||||||
const calls = this.getOption("session").callHandler.calls;
|
const calls = this.getOption("session").callHandler.calls;
|
||||||
this._callObservable = new PickMapObservableValue(calls.filterValues(c => {
|
this._callObservable = new PickMapObservableValue(calls.filterValues(c => {
|
||||||
@ -421,6 +424,10 @@ export class RoomViewModel extends ErrorReportViewModel {
|
|||||||
|
|
||||||
startCall() {
|
startCall() {
|
||||||
return this.logAndCatch("RoomViewModel.startCall", async log => {
|
return this.logAndCatch("RoomViewModel.startCall", async log => {
|
||||||
|
if (!this.features.calls) {
|
||||||
|
log.set("feature_disbled", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
log.set("roomId", this._room.id);
|
log.set("roomId", this._room.id);
|
||||||
let localMedia;
|
let localMedia;
|
||||||
try {
|
try {
|
||||||
|
@ -92,7 +92,7 @@ export function tileClassForEntry(entry: TimelineEntry, options: Options): TileC
|
|||||||
case "org.matrix.msc3401.call": {
|
case "org.matrix.msc3401.call": {
|
||||||
// if prevContent is present, it's an update to a call event, which we don't render
|
// 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
|
// 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 CallTile;
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -33,9 +33,11 @@ export class ToastCollectionViewModel extends ViewModel<SegmentType, Options> {
|
|||||||
constructor(options: Options) {
|
constructor(options: Options) {
|
||||||
super(options);
|
super(options);
|
||||||
const session = this.getOption("session");
|
const session = this.getOption("session");
|
||||||
|
if (this.features.calls) {
|
||||||
const callsObservableMap = session.callHandler.calls;
|
const callsObservableMap = session.callHandler.calls;
|
||||||
this.track(callsObservableMap.subscribe(this));
|
this.track(callsObservableMap.subscribe(this));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async onAdd(_, call: GroupCall) {
|
async onAdd(_, call: GroupCall) {
|
||||||
if (this._shouldShowNotification(call)) {
|
if (this._shouldShowNotification(call)) {
|
||||||
|
@ -75,6 +75,61 @@ export class Session {
|
|||||||
};
|
};
|
||||||
this._roomsBeingCreated = new ObservableMap();
|
this._roomsBeingCreated = new ObservableMap();
|
||||||
this._user = new User(sessionInfo.userId);
|
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({
|
this._callHandler = new CallHandler({
|
||||||
clock: this._platform.clock,
|
clock: this._platform.clock,
|
||||||
random: this._platform.random,
|
random: this._platform.random,
|
||||||
@ -103,55 +158,7 @@ export class Session {
|
|||||||
logger: this._platform.logger,
|
logger: this._platform.logger,
|
||||||
forceTURN: false,
|
forceTURN: false,
|
||||||
});
|
});
|
||||||
this._roomStateHandler = new RoomStateHandlerSet();
|
|
||||||
this.observeRoomState(this._callHandler);
|
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
|
// called once this._e2eeAccount is assigned
|
||||||
|
@ -73,8 +73,10 @@ export class RoomView extends TemplateView {
|
|||||||
} else {
|
} else {
|
||||||
const vm = this.value;
|
const vm = this.value;
|
||||||
const options = [];
|
const options = [];
|
||||||
options.push(Menu.option(vm.i18n`Room details`, () => vm.openDetailsPanel()))
|
options.push(Menu.option(vm.i18n`Room details`, () => vm.openDetailsPanel()));
|
||||||
options.push(Menu.option(vm.i18n`Start call`, () => vm.startCall()))
|
if (vm.features.calls) {
|
||||||
|
options.push(Menu.option(vm.i18n`Start call`, () => vm.startCall()));
|
||||||
|
}
|
||||||
if (vm.canLeave) {
|
if (vm.canLeave) {
|
||||||
options.push(Menu.option(vm.i18n`Leave room`, () => this._confirmToLeaveRoom()).setDestructive());
|
options.push(Menu.option(vm.i18n`Leave room`, () => this._confirmToLeaveRoom()).setDestructive());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user