forked from mystiq/hydrogen-web
Merge pull request #468 from vector-im/bwindels/fixlint
Cleanup: fix lint and remove dead code
This commit is contained in:
commit
25d0cbe9a2
18 changed files with 17 additions and 426 deletions
|
@ -1 +0,0 @@
|
||||||
src/matrix/storage/memory
|
|
|
@ -17,7 +17,6 @@ module.exports = {
|
||||||
'**/scripts/**',
|
'**/scripts/**',
|
||||||
'**/target/**',
|
'**/target/**',
|
||||||
'**/prototypes/**',
|
'**/prototypes/**',
|
||||||
'**/src/matrix/storage/memory/**',
|
|
||||||
'**/src/platform/web/legacy-polyfill.js',
|
'**/src/platform/web/legacy-polyfill.js',
|
||||||
'**/src/platform/web/worker/polyfill.js'
|
'**/src/platform/web/worker/polyfill.js'
|
||||||
],
|
],
|
||||||
|
|
|
@ -219,7 +219,7 @@ export class TilesCollection extends BaseObservableList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMove(fromIdx, toIdx, value) {
|
onMove(/*fromIdx, toIdx, value*/) {
|
||||||
// this ... cannot happen in the timeline?
|
// this ... cannot happen in the timeline?
|
||||||
// perhaps we can use this event to support a local echo (in a different fragment)
|
// perhaps we can use this event to support a local echo (in a different fragment)
|
||||||
// to be moved to the key of the remote echo, so we don't loose state ... ?
|
// to be moved to the key of the remote echo, so we don't loose state ... ?
|
||||||
|
|
|
@ -59,7 +59,7 @@ export class TimelineViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadAtTop(tileAmount) {
|
unloadAtTop(/*tileAmount*/) {
|
||||||
// get lowerSortKey for tile at index tileAmount - 1
|
// get lowerSortKey for tile at index tileAmount - 1
|
||||||
// tell timeline to unload till there (included given key)
|
// tell timeline to unload till there (included given key)
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ export class TimelineViewModel extends ViewModel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadAtBottom(tileAmount) {
|
unloadAtBottom(/*tileAmount*/) {
|
||||||
// get upperSortKey for tile at index tiles.length - tileAmount
|
// get upperSortKey for tile at index tiles.length - tileAmount
|
||||||
// tell timeline to unload till there (included given key)
|
// tell timeline to unload till there (included given key)
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ export class SimpleTile extends ViewModel {
|
||||||
|
|
||||||
// return whether the tile should be removed
|
// return whether the tile should be removed
|
||||||
// as SimpleTile only has one entry, the tile should be removed
|
// as SimpleTile only has one entry, the tile should be removed
|
||||||
removeEntry(entry) {
|
removeEntry(/*entry*/) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,12 +110,12 @@ export class SimpleTile extends ViewModel {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// let item know it has a new sibling
|
// let item know it has a new sibling
|
||||||
updatePreviousSibling(prev) {
|
updatePreviousSibling(/*prev*/) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// let item know it has a new sibling
|
// let item know it has a new sibling
|
||||||
updateNextSibling(next) {
|
updateNextSibling(/*next*/) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ export class RelationWriter {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_aggregateAnnotation(annotationEvent, targetStorageEntry, log) {
|
_aggregateAnnotation(annotationEvent, targetStorageEntry/*, log*/) {
|
||||||
// TODO: do we want to verify it is a m.reaction event somehow?
|
// TODO: do we want to verify it is a m.reaction event somehow?
|
||||||
const relation = getRelation(annotationEvent);
|
const relation = getRelation(annotationEvent);
|
||||||
if (!relation) {
|
if (!relation) {
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2020 Bruno Windels <bruno@windels.cloud>
|
|
||||||
|
|
||||||
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 {Transaction} from "./Transaction.js";
|
|
||||||
import { STORE_MAP, STORE_NAMES } from "../common.js";
|
|
||||||
|
|
||||||
export class Storage {
|
|
||||||
constructor(initialStoreValues = {}) {
|
|
||||||
this._validateStoreNames(Object.keys(initialStoreValues));
|
|
||||||
this.storeNames = STORE_MAP;
|
|
||||||
this._storeValues = STORE_NAMES.reduce((values, name) => {
|
|
||||||
values[name] = initialStoreValues[name] || null;
|
|
||||||
}, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
_validateStoreNames(storeNames) {
|
|
||||||
const idx = storeNames.findIndex(name => !STORE_MAP.hasOwnProperty(name));
|
|
||||||
if (idx !== -1) {
|
|
||||||
throw new Error(`Invalid store name ${storeNames[idx]}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_createTxn(storeNames, writable) {
|
|
||||||
this._validateStoreNames(storeNames);
|
|
||||||
const storeValues = storeNames.reduce((values, name) => {
|
|
||||||
return values[name] = this._storeValues[name];
|
|
||||||
}, {});
|
|
||||||
return Promise.resolve(new Transaction(storeValues, writable));
|
|
||||||
}
|
|
||||||
|
|
||||||
readTxn(storeNames) {
|
|
||||||
// TODO: avoid concurrency
|
|
||||||
return this._createTxn(storeNames, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
readWriteTxn(storeNames) {
|
|
||||||
// TODO: avoid concurrency
|
|
||||||
return this._createTxn(storeNames, true);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2020 Bruno Windels <bruno@windels.cloud>
|
|
||||||
|
|
||||||
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 {RoomTimelineStore} from "./stores/RoomTimelineStore.js";
|
|
||||||
|
|
||||||
export class Transaction {
|
|
||||||
constructor(storeValues, writable) {
|
|
||||||
this._storeValues = storeValues;
|
|
||||||
this._txnStoreValues = {};
|
|
||||||
this._writable = writable;
|
|
||||||
}
|
|
||||||
|
|
||||||
_store(name, mapper) {
|
|
||||||
if (!this._txnStoreValues.hasOwnProperty(name)) {
|
|
||||||
if (!this._storeValues.hasOwnProperty(name)) {
|
|
||||||
throw new Error(`Transaction wasn't opened for store ${name}`);
|
|
||||||
}
|
|
||||||
const store = mapper(this._storeValues[name]);
|
|
||||||
const clone = store.cloneStoreValue();
|
|
||||||
// extra prevention for writing
|
|
||||||
if (!this._writable) {
|
|
||||||
Object.freeze(clone);
|
|
||||||
}
|
|
||||||
this._txnStoreValues[name] = clone;
|
|
||||||
}
|
|
||||||
return mapper(this._txnStoreValues[name]);
|
|
||||||
}
|
|
||||||
|
|
||||||
get session() {
|
|
||||||
throw new Error("not yet implemented");
|
|
||||||
// return this._store("session", storeValue => new SessionStore(storeValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
get roomSummary() {
|
|
||||||
throw new Error("not yet implemented");
|
|
||||||
// return this._store("roomSummary", storeValue => new RoomSummaryStore(storeValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
get roomTimeline() {
|
|
||||||
return this._store("roomTimeline", storeValue => new RoomTimelineStore(storeValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
get roomState() {
|
|
||||||
throw new Error("not yet implemented");
|
|
||||||
// return this._store("roomState", storeValue => new RoomStateStore(storeValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
complete() {
|
|
||||||
for(let name of Object.keys(this._txnStoreValues)) {
|
|
||||||
this._storeValues[name] = this._txnStoreValues[name];
|
|
||||||
}
|
|
||||||
this._txnStoreValues = null;
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
abort() {
|
|
||||||
this._txnStoreValues = null;
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,237 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2020 Bruno Windels <bruno@windels.cloud>
|
|
||||||
|
|
||||||
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 {SortKey} from "../../room/timeline/SortKey.js";
|
|
||||||
import {sortedIndex} from "../../../utils/sortedIndex.js";
|
|
||||||
import {Store} from "./Store.js";
|
|
||||||
|
|
||||||
function compareKeys(key, entry) {
|
|
||||||
if (key.roomId === entry.roomId) {
|
|
||||||
return key.sortKey.compare(entry.sortKey);
|
|
||||||
} else {
|
|
||||||
return key.roomId < entry.roomId ? -1 : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Range {
|
|
||||||
constructor(timeline, lower, upper, lowerOpen, upperOpen) {
|
|
||||||
this._timeline = timeline;
|
|
||||||
this._lower = lower;
|
|
||||||
this._upper = upper;
|
|
||||||
this._lowerOpen = lowerOpen;
|
|
||||||
this._upperOpen = upperOpen;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** projects the range onto the timeline array */
|
|
||||||
project(roomId, maxCount = Number.MAX_SAFE_INTEGER) {
|
|
||||||
// determine lowest and highest allowed index.
|
|
||||||
// Important not to bleed into other roomIds here.
|
|
||||||
const lowerKey = {roomId, sortKey: this._lower || SortKey.minKey };
|
|
||||||
// apply lower key being open (excludes given key)
|
|
||||||
let minIndex = sortedIndex(this._timeline, lowerKey, compareKeys);
|
|
||||||
if (this._lowerOpen && minIndex < this._timeline.length && compareKeys(lowerKey, this._timeline[minIndex]) === 0) {
|
|
||||||
minIndex += 1;
|
|
||||||
}
|
|
||||||
const upperKey = {roomId, sortKey: this._upper || SortKey.maxKey };
|
|
||||||
// apply upper key being open (excludes given key)
|
|
||||||
let maxIndex = sortedIndex(this._timeline, upperKey, compareKeys);
|
|
||||||
if (this._upperOpen && maxIndex < this._timeline.length && compareKeys(upperKey, this._timeline[maxIndex]) === 0) {
|
|
||||||
maxIndex -= 1;
|
|
||||||
}
|
|
||||||
// find out from which edge we should grow
|
|
||||||
// if upper or lower bound
|
|
||||||
// again, important not to go below minIndex or above maxIndex
|
|
||||||
// to avoid bleeding into other rooms
|
|
||||||
let startIndex, endIndex;
|
|
||||||
if (!this._lower && this._upper) {
|
|
||||||
startIndex = Math.max(minIndex, maxIndex - maxCount);
|
|
||||||
endIndex = maxIndex;
|
|
||||||
} else if (this._lower && !this._upper) {
|
|
||||||
startIndex = minIndex;
|
|
||||||
endIndex = Math.min(maxIndex, minIndex + maxCount);
|
|
||||||
} else {
|
|
||||||
startIndex = minIndex;
|
|
||||||
endIndex = maxIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if startIndex is out of range, make range empty
|
|
||||||
if (startIndex === this._timeline.length) {
|
|
||||||
startIndex = endIndex = 0;
|
|
||||||
}
|
|
||||||
const count = endIndex - startIndex;
|
|
||||||
return {startIndex, count};
|
|
||||||
}
|
|
||||||
|
|
||||||
select(roomId, maxCount) {
|
|
||||||
const {startIndex, count} = this.project(roomId, this._timeline, maxCount);
|
|
||||||
return this._timeline.slice(startIndex, startIndex + count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class RoomTimelineStore extends Store {
|
|
||||||
constructor(timeline, writable) {
|
|
||||||
super(timeline || [], writable);
|
|
||||||
}
|
|
||||||
|
|
||||||
get _timeline() {
|
|
||||||
return this._storeValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Creates a range that only includes the given key
|
|
||||||
* @param {SortKey} sortKey the key
|
|
||||||
* @return {Range} the created range
|
|
||||||
*/
|
|
||||||
onlyRange(sortKey) {
|
|
||||||
return new Range(this._timeline, sortKey, sortKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Creates a range that includes all keys before sortKey, and optionally also the key itself.
|
|
||||||
* @param {SortKey} sortKey the key
|
|
||||||
* @param {boolean} [open=false] whether the key is included (false) or excluded (true) from the range at the upper end.
|
|
||||||
* @return {Range} the created range
|
|
||||||
*/
|
|
||||||
upperBoundRange(sortKey, open=false) {
|
|
||||||
return new Range(this._timeline, undefined, sortKey, undefined, open);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Creates a range that includes all keys after sortKey, and optionally also the key itself.
|
|
||||||
* @param {SortKey} sortKey the key
|
|
||||||
* @param {boolean} [open=false] whether the key is included (false) or excluded (true) from the range at the lower end.
|
|
||||||
* @return {Range} the created range
|
|
||||||
*/
|
|
||||||
lowerBoundRange(sortKey, open=false) {
|
|
||||||
return new Range(this._timeline, sortKey, undefined, open);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Creates a range that includes all keys between `lower` and `upper`, and optionally the given keys as well.
|
|
||||||
* @param {SortKey} lower the lower key
|
|
||||||
* @param {SortKey} upper the upper key
|
|
||||||
* @param {boolean} [lowerOpen=false] whether the lower key is included (false) or excluded (true) from the range.
|
|
||||||
* @param {boolean} [upperOpen=false] whether the upper key is included (false) or excluded (true) from the range.
|
|
||||||
* @return {Range} the created range
|
|
||||||
*/
|
|
||||||
boundRange(lower, upper, lowerOpen=false, upperOpen=false) {
|
|
||||||
return new Range(this._timeline, lower, upper, lowerOpen, upperOpen);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Looks up the last `amount` entries in the timeline for `roomId`.
|
|
||||||
* @param {string} roomId
|
|
||||||
* @param {number} amount
|
|
||||||
* @return {Promise<Entry[]>} a promise resolving to an array with 0 or more entries, in ascending order.
|
|
||||||
*/
|
|
||||||
lastEvents(roomId, amount) {
|
|
||||||
return this.eventsBefore(roomId, SortKey.maxKey, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Looks up the first `amount` entries in the timeline for `roomId`.
|
|
||||||
* @param {string} roomId
|
|
||||||
* @param {number} amount
|
|
||||||
* @return {Promise<Entry[]>} a promise resolving to an array with 0 or more entries, in ascending order.
|
|
||||||
*/
|
|
||||||
firstEvents(roomId, amount) {
|
|
||||||
return this.eventsAfter(roomId, SortKey.minKey, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Looks up `amount` entries after `sortKey` in the timeline for `roomId`.
|
|
||||||
* The entry for `sortKey` is not included.
|
|
||||||
* @param {string} roomId
|
|
||||||
* @param {SortKey} sortKey
|
|
||||||
* @param {number} amount
|
|
||||||
* @return {Promise<Entry[]>} a promise resolving to an array with 0 or more entries, in ascending order.
|
|
||||||
*/
|
|
||||||
eventsAfter(roomId, sortKey, amount) {
|
|
||||||
const events = this.lowerBoundRange(sortKey, true).select(roomId, amount);
|
|
||||||
return Promise.resolve(events);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Looks up `amount` entries before `sortKey` in the timeline for `roomId`.
|
|
||||||
* The entry for `sortKey` is not included.
|
|
||||||
* @param {string} roomId
|
|
||||||
* @param {SortKey} sortKey
|
|
||||||
* @param {number} amount
|
|
||||||
* @return {Promise<Entry[]>} a promise resolving to an array with 0 or more entries, in ascending order.
|
|
||||||
*/
|
|
||||||
eventsBefore(roomId, sortKey, amount) {
|
|
||||||
const events = this.upperBoundRange(sortKey, true).select(roomId, amount);
|
|
||||||
return Promise.resolve(events);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Looks up the first, if any, event entry (so excluding gap entries) after `sortKey`.
|
|
||||||
* @param {string} roomId
|
|
||||||
* @param {SortKey} sortKey
|
|
||||||
* @return {Promise<(?Entry)>} a promise resolving to entry, if any.
|
|
||||||
*/
|
|
||||||
nextEvent(roomId, sortKey) {
|
|
||||||
const searchSpace = this.lowerBoundRange(sortKey, true).select(roomId);
|
|
||||||
const event = searchSpace.find(entry => !!entry.event);
|
|
||||||
return Promise.resolve(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Looks up the first, if any, event entry (so excluding gap entries) before `sortKey`.
|
|
||||||
* @param {string} roomId
|
|
||||||
* @param {SortKey} sortKey
|
|
||||||
* @return {Promise<(?Entry)>} a promise resolving to entry, if any.
|
|
||||||
*/
|
|
||||||
previousEvent(roomId, sortKey) {
|
|
||||||
const searchSpace = this.upperBoundRange(sortKey, true).select(roomId);
|
|
||||||
const event = searchSpace.reverse().find(entry => !!entry.event);
|
|
||||||
return Promise.resolve(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Inserts a new entry into the store. The combination of roomId and sortKey should not exist yet, or an error is thrown.
|
|
||||||
* @param {Entry} entry the entry to insert
|
|
||||||
* @return {Promise<>} a promise resolving to undefined if the operation was successful, or a StorageError if not.
|
|
||||||
* @throws {StorageError} ...
|
|
||||||
*/
|
|
||||||
insert(entry) {
|
|
||||||
this.assertWritable();
|
|
||||||
const insertIndex = sortedIndex(this._timeline, entry, compareKeys);
|
|
||||||
if (insertIndex < this._timeline.length) {
|
|
||||||
const existingEntry = this._timeline[insertIndex];
|
|
||||||
if (compareKeys(entry, existingEntry) === 0) {
|
|
||||||
return Promise.reject(new Error("entry already exists"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._timeline.splice(insertIndex, 0, entry);
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Updates the entry into the store with the given [roomId, sortKey] combination.
|
|
||||||
* If not yet present, will insert. Might be slower than add.
|
|
||||||
* @param {Entry} entry the entry to update.
|
|
||||||
* @return {Promise<>} a promise resolving to undefined if the operation was successful, or a StorageError if not.
|
|
||||||
*/
|
|
||||||
update(entry) {
|
|
||||||
this.assertWritable();
|
|
||||||
let update = false;
|
|
||||||
const updateIndex = sortedIndex(this._timeline, entry, compareKeys);
|
|
||||||
if (updateIndex < this._timeline.length) {
|
|
||||||
const existingEntry = this._timeline[updateIndex];
|
|
||||||
if (compareKeys(entry, existingEntry) === 0) {
|
|
||||||
update = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._timeline.splice(updateIndex, update ? 1 : 0, entry);
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
get(roomId, sortKey) {
|
|
||||||
const range = this.onlyRange(sortKey);
|
|
||||||
const {startIndex, count} = range.project(roomId);
|
|
||||||
const event = count ? this._timeline[startIndex] : undefined;
|
|
||||||
return Promise.resolve(event);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2020 Bruno Windels <bruno@windels.cloud>
|
|
||||||
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export class Store {
|
|
||||||
constructor(storeValue, writable) {
|
|
||||||
this._storeValue = storeValue;
|
|
||||||
this._writable = writable;
|
|
||||||
}
|
|
||||||
|
|
||||||
// makes a copy deep enough that any modifications in the store
|
|
||||||
// won't affect the original
|
|
||||||
// used for transactions
|
|
||||||
cloneStoreValue() {
|
|
||||||
// assumes 1 level deep is enough, and that values will be replaced
|
|
||||||
// rather than updated.
|
|
||||||
if (Array.isArray(this._storeValue)) {
|
|
||||||
return this._storeValue.slice();
|
|
||||||
} else if (typeof this._storeValue === "object") {
|
|
||||||
return Object.assign({}, this._storeValue);
|
|
||||||
} else {
|
|
||||||
return this._storeValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assertWritable() {
|
|
||||||
if (!this._writable) {
|
|
||||||
throw new Error("Tried to write in read-only transaction");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -42,7 +42,7 @@ export class MappedMap extends BaseObservableMap {
|
||||||
this.emitAdd(key, mappedValue);
|
this.emitAdd(key, mappedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemove(key, _value) {
|
onRemove(key/*, _value*/) {
|
||||||
const mappedValue = this._mappedValues.get(key);
|
const mappedValue = this._mappedValues.get(key);
|
||||||
if (this._mappedValues.delete(key)) {
|
if (this._mappedValues.delete(key)) {
|
||||||
this.emitRemove(key, mappedValue);
|
this.emitRemove(key, mappedValue);
|
||||||
|
|
|
@ -156,7 +156,7 @@ export function tests() {
|
||||||
assert.equal(key, 1);
|
assert.equal(key, 1);
|
||||||
assert.deepEqual(value, {value: 5});
|
assert.deepEqual(value, {value: 5});
|
||||||
},
|
},
|
||||||
onUpdate(key, value, params) {
|
onUpdate(key, value/*, params*/) {
|
||||||
update_fired += 1;
|
update_fired += 1;
|
||||||
assert.equal(key, 1);
|
assert.equal(key, 1);
|
||||||
assert.deepEqual(value, {value: 7});
|
assert.deepEqual(value, {value: 7});
|
||||||
|
|
|
@ -221,7 +221,7 @@ export class Platform {
|
||||||
if (mimeType) {
|
if (mimeType) {
|
||||||
input.setAttribute("accept", mimeType);
|
input.setAttribute("accept", mimeType);
|
||||||
}
|
}
|
||||||
const promise = new Promise((resolve, reject) => {
|
const promise = new Promise(resolve => {
|
||||||
const checkFile = () => {
|
const checkFile = () => {
|
||||||
input.removeEventListener("change", checkFile, true);
|
input.removeEventListener("change", checkFile, true);
|
||||||
const file = input.files[0];
|
const file = input.files[0];
|
||||||
|
|
|
@ -121,7 +121,7 @@ export class ListView {
|
||||||
this.onListChanged();
|
this.onListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemove(idx, _value) {
|
onRemove(idx/*, _value*/) {
|
||||||
this.onBeforeListChanged();
|
this.onBeforeListChanged();
|
||||||
const [child] = this._childInstances.splice(idx, 1);
|
const [child] = this._childInstances.splice(idx, 1);
|
||||||
child.root().remove();
|
child.root().remove();
|
||||||
|
@ -129,7 +129,7 @@ export class ListView {
|
||||||
this.onListChanged();
|
this.onListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
onMove(fromIdx, toIdx, value) {
|
onMove(fromIdx, toIdx/*, value*/) {
|
||||||
this.onBeforeListChanged();
|
this.onBeforeListChanged();
|
||||||
const [child] = this._childInstances.splice(fromIdx, 1);
|
const [child] = this._childInstances.splice(fromIdx, 1);
|
||||||
this._childInstances.splice(toIdx, 0, child);
|
this._childInstances.splice(toIdx, 0, child);
|
||||||
|
|
|
@ -17,7 +17,6 @@ limitations under the License.
|
||||||
import {TemplateView} from "../../general/TemplateView.js";
|
import {TemplateView} from "../../general/TemplateView.js";
|
||||||
import {Popup} from "../../general/Popup.js";
|
import {Popup} from "../../general/Popup.js";
|
||||||
import {Menu} from "../../general/Menu.js";
|
import {Menu} from "../../general/Menu.js";
|
||||||
import {TextMessageView} from "./timeline/TextMessageView.js";
|
|
||||||
import {viewClassForEntry} from "./TimelineList.js"
|
import {viewClassForEntry} from "./TimelineList.js"
|
||||||
|
|
||||||
export class MessageComposer extends TemplateView {
|
export class MessageComposer extends TemplateView {
|
||||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
import {TemplateView} from "../../general/TemplateView.js";
|
import {TemplateView} from "../../general/TemplateView.js";
|
||||||
|
|
||||||
export class RoomArchivedView extends TemplateView {
|
export class RoomArchivedView extends TemplateView {
|
||||||
render(t, vm) {
|
render(t) {
|
||||||
return t.div({className: "RoomArchivedView"}, t.h3(vm => vm.description));
|
return t.div({className: "RoomArchivedView"}, t.h3(vm => vm.description));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -97,7 +97,7 @@ const formatFunction = {
|
||||||
link: linkPart => tag.a({href: linkPart.url, className: "link", target: "_blank", rel: "noopener" }, renderParts(linkPart.inlines)),
|
link: linkPart => tag.a({href: linkPart.url, className: "link", target: "_blank", rel: "noopener" }, renderParts(linkPart.inlines)),
|
||||||
pill: renderPill,
|
pill: renderPill,
|
||||||
format: formatPart => tag[formatPart.format](renderParts(formatPart.children)),
|
format: formatPart => tag[formatPart.format](renderParts(formatPart.children)),
|
||||||
rule: rulePart => tag.hr(),
|
rule: () => tag.hr(),
|
||||||
list: renderList,
|
list: renderList,
|
||||||
image: renderImage,
|
image: renderImage,
|
||||||
newline: () => tag.br()
|
newline: () => tag.br()
|
||||||
|
|
|
@ -55,9 +55,9 @@ export class EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onFirstSubscriptionAdded(name) {}
|
onFirstSubscriptionAdded(/* name */) {}
|
||||||
|
|
||||||
onLastSubscriptionRemoved(name) {}
|
onLastSubscriptionRemoved(/* name */) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function tests() {
|
export function tests() {
|
||||||
|
|
Loading…
Reference in a new issue