Compare commits
4 commits
master
...
rxl881/ems
Author | SHA1 | Date | |
---|---|---|---|
|
bccb775004 | ||
|
a421d2ddc7 | ||
|
8fbde16978 | ||
|
0b4797d9cf |
13 changed files with 55 additions and 46 deletions
|
@ -36,7 +36,7 @@ export class RoomMemberTile extends SimpleTile {
|
|||
if (!content.displayname) {
|
||||
return `${stateKey} removed their name (${prevContent.displayname})`;
|
||||
}
|
||||
return `${prevContent.displayname ?? stateKey} changed their name to ${content.displayname}`;
|
||||
return `${prevContent.displayname ? prevContent.displayname : stateKey} changed their name to ${content.displayname}`;
|
||||
}
|
||||
} else if (membership === "join") {
|
||||
return `${targetName} joined the room`;
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
|
||||
import {createEnum} from "../utils/enum.js";
|
||||
import {lookupHomeserver} from "./well-known.js";
|
||||
import {AbortableOperation} from "../utils/AbortableOperation";
|
||||
import {AbortableOperation} from "../utils/AbortableOperation.js";
|
||||
import {ObservableValue} from "../observable/ObservableValue.js";
|
||||
import {HomeServerApi} from "./net/HomeServerApi.js";
|
||||
import {Reconnector, ConnectionStatus} from "./net/Reconnector.js";
|
||||
|
|
|
@ -181,10 +181,10 @@ export class Sync {
|
|||
|
||||
async _syncRequest(syncToken, timeout, log) {
|
||||
let {syncFilterId} = this._session;
|
||||
if (typeof syncFilterId !== "string") {
|
||||
this._currentRequest = this._hsApi.createFilter(this._session.user.id, {room: {state: {lazy_load_members: true}}}, {log});
|
||||
syncFilterId = (await this._currentRequest.response()).filter_id;
|
||||
}
|
||||
// if (typeof syncFilterId !== "string") {
|
||||
// this._currentRequest = this._hsApi.createFilter(this._session.user.id, {room: {state: {lazy_load_members: true}}}, {log});
|
||||
// syncFilterId = (await this._currentRequest.response()).filter_id;
|
||||
// }
|
||||
const totalRequestTimeout = timeout + (80 * 1000); // same as riot-web, don't get stuck on wedged long requests
|
||||
this._currentRequest = this._hsApi.sync(syncToken, syncFilterId, timeout, {timeout: totalRequestTimeout, log});
|
||||
const response = await this._currentRequest.response();
|
||||
|
|
27
src/matrix/login/GuestLoginMethod.js
Normal file
27
src/matrix/login/GuestLoginMethod.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
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 {LoginMethod} from "./LoginMethod.js";
|
||||
|
||||
export class GuestLoginMethod extends LoginMethod {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
async login(hsApi, deviceName, log) {
|
||||
return await hsApi.guestLogin(deviceName, {log}).response();
|
||||
}
|
||||
}
|
|
@ -150,6 +150,12 @@ export class HomeServerApi {
|
|||
}, options);
|
||||
}
|
||||
|
||||
guestLogin(initialDeviceDisplayName, options = null) {
|
||||
return this._unauthedRequest("POST", this._url(`/register`), {kind: 'guest'}, {
|
||||
"initial_device_display_name": initialDeviceDisplayName
|
||||
}, options);
|
||||
}
|
||||
|
||||
tokenLogin(loginToken, txnId, initialDeviceDisplayName, options = null) {
|
||||
return this._unauthedRequest("POST", this._url("/login"), null, {
|
||||
"type": "m.login.token",
|
||||
|
|
|
@ -270,7 +270,7 @@ export class Room extends BaseRoom {
|
|||
|
||||
_getPowerLevelsEvent(roomResponse) {
|
||||
const isPowerlevelEvent = event => event.state_key === "" && event.type === POWERLEVELS_EVENT_TYPE;
|
||||
const powerLevelEvent = roomResponse.timeline?.events.find(isPowerlevelEvent) ?? roomResponse.state?.events.find(isPowerlevelEvent);
|
||||
const powerLevelEvent = roomResponse.timeline?.events.find(isPowerlevelEvent) ? roomResponse.timeline?.events.find(isPowerlevelEvent) : roomResponse.state?.events.find(isPowerlevelEvent);
|
||||
return powerLevelEvent;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,21 +18,9 @@ limitations under the License.
|
|||
import {EventKey} from "../EventKey.js";
|
||||
export const PENDING_FRAGMENT_ID = Number.MAX_SAFE_INTEGER;
|
||||
|
||||
interface FragmentIdComparer {
|
||||
compare: (a: number, b: number) => number
|
||||
}
|
||||
export class BaseEntry {
|
||||
|
||||
export abstract class BaseEntry {
|
||||
constructor(
|
||||
protected readonly _fragmentIdComparer: FragmentIdComparer
|
||||
) {
|
||||
}
|
||||
|
||||
abstract get fragmentId(): number;
|
||||
abstract get entryIndex(): number;
|
||||
abstract updateFrom(other: BaseEntry): void;
|
||||
|
||||
compare(otherEntry: BaseEntry): number {
|
||||
compare(otherEntry) {
|
||||
if (this.fragmentId === otherEntry.fragmentId) {
|
||||
return this.entryIndex - otherEntry.entryIndex;
|
||||
} else if (this.fragmentId === PENDING_FRAGMENT_ID) {
|
||||
|
@ -45,7 +33,7 @@ export abstract class BaseEntry {
|
|||
}
|
||||
}
|
||||
|
||||
asEventKey(): EventKey {
|
||||
asEventKey() {
|
||||
return new EventKey(this.fragmentId, this.entryIndex);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {BaseEntry} from "./BaseEntry";
|
||||
import {BaseEntry} from "./BaseEntry.js";
|
||||
import {REDACTION_TYPE} from "../../common.js";
|
||||
import {createAnnotation, ANNOTATION_RELATION_TYPE, getRelationFromContent} from "../relations.js";
|
||||
import {PendingAnnotation} from "../PendingAnnotation.js";
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {BaseEntry} from "./BaseEntry";
|
||||
import {BaseEntry} from "./BaseEntry.js";
|
||||
import {Direction} from "../Direction.js";
|
||||
import {isValidFragmentId} from "../common.js";
|
||||
import {KeyLimits} from "../../../storage/common.js";
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {PENDING_FRAGMENT_ID} from "./BaseEntry";
|
||||
import {PENDING_FRAGMENT_ID} from "./BaseEntry.js";
|
||||
import {BaseEventEntry} from "./BaseEventEntry.js";
|
||||
|
||||
export class PendingEventEntry extends BaseEventEntry {
|
||||
|
|
|
@ -14,17 +14,8 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
interface IAbortable {
|
||||
abort();
|
||||
}
|
||||
|
||||
type RunFn<T> = (setAbortable: (a: IAbortable) => typeof a) => T;
|
||||
|
||||
export class AbortableOperation<T> {
|
||||
public readonly result: T;
|
||||
private _abortable: IAbortable | null;
|
||||
|
||||
constructor(run: RunFn<T>) {
|
||||
export class AbortableOperation {
|
||||
constructor(run) {
|
||||
this._abortable = null;
|
||||
const setAbortable = abortable => {
|
||||
this._abortable = abortable;
|
|
@ -4,5 +4,7 @@
|
|||
"noEmit": true,
|
||||
"target": "es6"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"include": [
|
||||
"src/**/*"
|
||||
],
|
||||
}
|
||||
|
|
13
yarn.lock
13
yarn.lock
|
@ -1683,15 +1683,10 @@ callsites@^3.0.0:
|
|||
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
|
||||
integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==
|
||||
|
||||
caniuse-lite@^1.0.30001111:
|
||||
version "1.0.30001187"
|
||||
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001187.tgz"
|
||||
integrity sha512-w7/EP1JRZ9552CyrThUnay2RkZ1DXxKe/Q2swTC4+LElLh9RRYrL1Z+27LlakB8kzY0fSmHw9mc7XYDUKAKWMA==
|
||||
|
||||
caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001230:
|
||||
version "1.0.30001231"
|
||||
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001231.tgz#6c1f9b49fc27cc368b894e64b9b28b39ef80603b"
|
||||
integrity sha512-WAFFv31GgU4DiwNAy77qMo3nNyycEhH3ikcCVHvkQpPe/fO8Tb2aRYzss8kgyLQBm8mJ7OryW4X6Y4vsBCIqag==
|
||||
caniuse-lite@^1.0.30001111, caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001230:
|
||||
version "1.0.30001251"
|
||||
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001251.tgz"
|
||||
integrity sha512-HOe1r+9VkU4TFmnU70z+r7OLmtR+/chB1rdcJUeQlAinjEeb0cKL20tlAtOagNZhbrtLnCvV19B4FmF1rgzl6A==
|
||||
|
||||
caseless@~0.12.0:
|
||||
version "0.12.0"
|
||||
|
|
Reference in a new issue