mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
Fix merge conflict
This commit is contained in:
parent
076a899b66
commit
220ddc7175
@ -16,6 +16,7 @@ limitations under the License.
|
||||
|
||||
import {AvatarSource} from "../../AvatarSource";
|
||||
import {ViewModel, Options as BaseOptions} from "../../ViewModel";
|
||||
import { SegmentType } from "../../navigation";
|
||||
import {getStreamVideoTrack, getStreamAudioTrack} from "../../../matrix/calls/common";
|
||||
import {avatarInitials, getIdentifierColorNumber, getAvatarHttpUrl} from "../../avatar";
|
||||
import {EventObservableValue} from "../../../observable/value/EventObservableValue";
|
||||
@ -34,13 +35,13 @@ type Options = BaseOptions & {
|
||||
room: Room,
|
||||
};
|
||||
|
||||
export class CallViewModel extends ViewModel<Options> {
|
||||
export class CallViewModel extends ViewModel<SegmentType, Options> {
|
||||
public readonly memberViewModels: BaseObservableList<IStreamViewModel>;
|
||||
|
||||
constructor(options: Options) {
|
||||
super(options);
|
||||
const ownMemberViewModelMap = new ObservableValueMap("self", new EventObservableValue(this.call, "change"))
|
||||
.mapValues((call, emitChange) => new OwnMemberViewModel(this.childOptions({call, emitChange})), () => {});
|
||||
.mapValues((call, emitChange) => new OwnMemberViewModel(this.childOptions({call, room: options.room, emitChange})), () => {});
|
||||
this.memberViewModels = this.call.members
|
||||
.filterValues(member => member.isConnected)
|
||||
.mapValues(member => new CallMemberViewModel(this.childOptions({member, mediaRepository: this.getOption("room").mediaRepository})))
|
||||
@ -119,7 +120,7 @@ export class CallViewModel extends ViewModel<Options> {
|
||||
}
|
||||
}
|
||||
|
||||
class OwnMemberViewModel extends ViewModel<Options> implements IStreamViewModel {
|
||||
class OwnMemberViewModel extends ViewModel<SegmentType, Options> implements IStreamViewModel {
|
||||
private memberObservable: undefined | BaseObservableValue<RoomMember>;
|
||||
|
||||
constructor(options: Options) {
|
||||
@ -190,7 +191,7 @@ type MemberOptions = BaseOptions & {
|
||||
mediaRepository: MediaRepository
|
||||
};
|
||||
|
||||
export class CallMemberViewModel extends ViewModel<MemberOptions> implements IStreamViewModel {
|
||||
export class CallMemberViewModel extends ViewModel<SegmentType, MemberOptions> implements IStreamViewModel {
|
||||
get stream(): Stream | undefined {
|
||||
return this.member.remoteMedia?.userMedia;
|
||||
}
|
||||
|
@ -548,7 +548,6 @@ import {createMockStorage} from "../../mocks/Storage";
|
||||
import {Clock as MockClock} from "../../mocks/Clock";
|
||||
import {poll} from "../../mocks/poll";
|
||||
import {Instance as NullLoggerInstance} from "../../logging/NullLogger";
|
||||
import {ConsoleLogger} from "../../logging/ConsoleLogger";
|
||||
import {HomeServer as MockHomeServer} from "../../mocks/HomeServer.js";
|
||||
|
||||
export function tests() {
|
||||
|
@ -367,7 +367,7 @@ export class HomeServerApi {
|
||||
}
|
||||
|
||||
import {Request as MockRequest} from "../../mocks/Request.js";
|
||||
import {BaseObservableValue} from "../../observable/ObservableValue";
|
||||
import {BaseObservableValue} from "../../observable/value/BaseObservableValue";
|
||||
|
||||
export function tests() {
|
||||
return {
|
||||
|
@ -14,7 +14,9 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {BaseObservableValue, ObservableValue} from "../../observable/ObservableValue";
|
||||
import {ObservableValue} from "../../observable/value/ObservableValue";
|
||||
import { BaseObservableValue } from "../../observable/value/BaseObservableValue";
|
||||
import { MappedObservableValue } from "../../observable/value/MappedObservableValue";
|
||||
import type {Clock, Timeout} from "../../platform/web/dom/Clock";
|
||||
import {OidcApi} from "./OidcApi";
|
||||
|
||||
@ -54,7 +56,7 @@ export class TokenRefresher {
|
||||
accessTokenExpiresAt,
|
||||
refreshToken,
|
||||
});
|
||||
this._accessToken = this._token.map(t => t.accessToken);
|
||||
this._accessToken = new MappedObservableValue(this._token, (t) => t.accessToken);
|
||||
|
||||
this._anticipation = anticipation;
|
||||
this._oidcApi = oidcApi;
|
||||
|
@ -36,39 +36,6 @@ export abstract class BaseObservableValue<T> extends BaseObservable<(value: T) =
|
||||
return new WaitForHandle(this, predicate);
|
||||
}
|
||||
}
|
||||
|
||||
map<C>(mapper: (value: T) => C): BaseObservableValue<C> {
|
||||
return new MappedObservableValue<T, C>(this, mapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class MappedObservableValue<P, C> extends BaseObservableValue<C> {
|
||||
private sourceSubscription?: SubscriptionHandle;
|
||||
|
||||
constructor(
|
||||
private readonly source: BaseObservableValue<P>,
|
||||
private readonly mapper: (value: P) => C
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
onUnsubscribeLast() {
|
||||
super.onUnsubscribeLast();
|
||||
this.sourceSubscription = this.sourceSubscription!();
|
||||
}
|
||||
|
||||
onSubscribeFirst() {
|
||||
super.onSubscribeFirst();
|
||||
this.sourceSubscription = this.source.subscribe(() => {
|
||||
this.emit(this.get());
|
||||
});
|
||||
}
|
||||
|
||||
get(): C {
|
||||
const sourceValue = this.source.get();
|
||||
return this.mapper(sourceValue);
|
||||
}
|
||||
}
|
||||
|
||||
interface IWaitHandle<T> {
|
||||
|
46
src/observable/value/MappedObservableValue.ts
Normal file
46
src/observable/value/MappedObservableValue.ts
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the 'License');
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an 'AS IS' BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { BaseObservableValue } from "./BaseObservableValue";
|
||||
import { SubscriptionHandle } from "../BaseObservable";
|
||||
|
||||
export class MappedObservableValue<P, C> extends BaseObservableValue<C> {
|
||||
private sourceSubscription?: SubscriptionHandle;
|
||||
|
||||
constructor(
|
||||
private readonly source: BaseObservableValue<P>,
|
||||
private readonly mapper: (value: P) => C
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
onUnsubscribeLast() {
|
||||
super.onUnsubscribeLast();
|
||||
this.sourceSubscription = this.sourceSubscription!();
|
||||
}
|
||||
|
||||
onSubscribeFirst() {
|
||||
super.onSubscribeFirst();
|
||||
this.sourceSubscription = this.source.subscribe(() => {
|
||||
this.emit(this.get());
|
||||
});
|
||||
}
|
||||
|
||||
get(): C {
|
||||
const sourceValue = this.source.get();
|
||||
return this.mapper(sourceValue);
|
||||
}
|
||||
}
|
@ -1670,17 +1670,10 @@ type-fest@^0.20.2:
|
||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
|
||||
integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==
|
||||
|
||||
<<<<<<< HEAD
|
||||
typescript@^4.4:
|
||||
version "4.6.3"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.3.tgz#eefeafa6afdd31d725584c67a0eaba80f6fc6c6c"
|
||||
integrity sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==
|
||||
=======
|
||||
typescript@^4.7.0:
|
||||
version "4.7.4"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
|
||||
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==
|
||||
>>>>>>> sandhose/oidc-login
|
||||
|
||||
typeson-registry@^1.0.0-alpha.20:
|
||||
version "1.0.0-alpha.39"
|
||||
|
Loading…
Reference in New Issue
Block a user