mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-22 19:14:52 +01:00
rename Gap/SyncPersistence to Writer, in line with TimelineReader
This commit is contained in:
parent
784588440c
commit
fa4efe0132
@ -1,6 +1,6 @@
|
||||
import EventEmitter from "../../EventEmitter.js";
|
||||
import RoomSummary from "./summary.js";
|
||||
import SyncPersister from "./timeline/persistence/SyncPersister.js";
|
||||
import SyncWriter from "./timeline/persistence/SyncWriter.js";
|
||||
import Timeline from "./timeline/Timeline.js";
|
||||
import FragmentIdComparer from "./timeline/FragmentIdComparer.js";
|
||||
|
||||
@ -12,14 +12,14 @@ export default class Room extends EventEmitter {
|
||||
this._hsApi = hsApi;
|
||||
this._summary = new RoomSummary(roomId);
|
||||
this._fragmentIdComparer = new FragmentIdComparer([]);
|
||||
this._syncPersister = new SyncPersister({roomId, storage, fragmentIdComparer: this._fragmentIdComparer});
|
||||
this._syncWriter = new SyncWriter({roomId, storage, fragmentIdComparer: this._fragmentIdComparer});
|
||||
this._emitCollectionChange = emitCollectionChange;
|
||||
this._timeline = null;
|
||||
}
|
||||
|
||||
persistSync(roomResponse, membership, txn) {
|
||||
const summaryChanged = this._summary.applySync(roomResponse, membership, txn);
|
||||
const newTimelineEntries = this._syncPersister.persistSync(roomResponse, txn);
|
||||
const newTimelineEntries = this._syncWriter.writeSync(roomResponse, txn);
|
||||
return {summaryChanged, newTimelineEntries};
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ export default class Room extends EventEmitter {
|
||||
|
||||
load(summary, txn) {
|
||||
this._summary.load(summary);
|
||||
return this._syncPersister.load(txn);
|
||||
return this._syncWriter.load(txn);
|
||||
}
|
||||
|
||||
get name() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ObservableArray } from "../../../observable/index.js";
|
||||
import sortedIndex from "../../../utils/sortedIndex.js";
|
||||
import GapPersister from "./persistence/GapPersister.js";
|
||||
import GapWriter from "./persistence/GapWriter.js";
|
||||
import TimelineReader from "./persistence/TimelineReader.js";
|
||||
|
||||
export default class Timeline {
|
||||
@ -41,12 +41,12 @@ export default class Timeline {
|
||||
limit: amount
|
||||
});
|
||||
|
||||
const gapPersister = new GapPersister({
|
||||
const gapWriter = new GapWriter({
|
||||
roomId: this._roomId,
|
||||
storage: this._storage,
|
||||
fragmentIdComparer: this._fragmentIdComparer
|
||||
});
|
||||
const newEntries = await gapPersister.persistFragmentFill(fragmentEntry, response);
|
||||
const newEntries = await gapWriter.writerFragmentFill(fragmentEntry, response);
|
||||
// find where to replace existing gap with newEntries by doing binary search
|
||||
const gapIdx = sortedIndex(this._entriesList.array, fragmentEntry, (fragmentEntry, entry) => {
|
||||
return fragmentEntry.compare(entry);
|
||||
|
@ -2,7 +2,7 @@ import EventKey from "../EventKey.js";
|
||||
import EventEntry from "../entries/EventEntry.js";
|
||||
import {createEventEntry, directionalAppend} from "./common.js";
|
||||
|
||||
export default class GapPersister {
|
||||
export default class GapWriter {
|
||||
constructor({roomId, storage, fragmentIdComparer}) {
|
||||
this._roomId = roomId;
|
||||
this._storage = storage;
|
||||
@ -71,7 +71,7 @@ export default class GapPersister {
|
||||
txn.timelineFragments.set(fragmentEntry.fragment);
|
||||
}
|
||||
|
||||
async persistFragmentFill(fragmentEntry, response) {
|
||||
async writeFragmentFill(fragmentEntry, response) {
|
||||
const {fragmentId, direction} = fragmentEntry;
|
||||
// assuming that chunk is in chronological order when backwards too?
|
||||
const {chunk, start, end} = response;
|
@ -3,7 +3,7 @@ import EventEntry from "../entries/EventEntry.js";
|
||||
import FragmentBoundaryEntry from "../entries/FragmentBoundaryEntry.js";
|
||||
import {createEventEntry} from "./common.js";
|
||||
|
||||
export default class SyncPersister {
|
||||
export default class SyncWriter {
|
||||
constructor({roomId, storage, fragmentIdComparer}) {
|
||||
this._roomId = roomId;
|
||||
this._storage = storage;
|
||||
@ -65,7 +65,7 @@ export default class SyncPersister {
|
||||
return {oldFragment, newFragment};
|
||||
}
|
||||
|
||||
async persistSync(roomResponse, txn) {
|
||||
async writeSync(roomResponse, txn) {
|
||||
const entries = [];
|
||||
if (!this._lastLiveKey) {
|
||||
// means we haven't synced this room yet (just joined or did initial sync)
|
Loading…
Reference in New Issue
Block a user