From fa4efe0132150299d1bedbf79267a7cd9c2c1779 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Sat, 1 Jun 2019 15:40:21 +0200 Subject: [PATCH] rename Gap/SyncPersistence to Writer, in line with TimelineReader --- src/matrix/room/room.js | 8 ++++---- src/matrix/room/timeline/Timeline.js | 6 +++--- .../persistence/{GapPersister.js => GapWriter.js} | 4 ++-- .../persistence/{SyncPersister.js => SyncWriter.js} | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) rename src/matrix/room/timeline/persistence/{GapPersister.js => GapWriter.js} (99%) rename src/matrix/room/timeline/persistence/{SyncPersister.js => SyncWriter.js} (99%) diff --git a/src/matrix/room/room.js b/src/matrix/room/room.js index c6e75e95..09b3427c 100644 --- a/src/matrix/room/room.js +++ b/src/matrix/room/room.js @@ -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() { diff --git a/src/matrix/room/timeline/Timeline.js b/src/matrix/room/timeline/Timeline.js index 2eb8d19b..2ac74e64 100644 --- a/src/matrix/room/timeline/Timeline.js +++ b/src/matrix/room/timeline/Timeline.js @@ -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); diff --git a/src/matrix/room/timeline/persistence/GapPersister.js b/src/matrix/room/timeline/persistence/GapWriter.js similarity index 99% rename from src/matrix/room/timeline/persistence/GapPersister.js rename to src/matrix/room/timeline/persistence/GapWriter.js index 9b92409f..06d450a6 100644 --- a/src/matrix/room/timeline/persistence/GapPersister.js +++ b/src/matrix/room/timeline/persistence/GapWriter.js @@ -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; diff --git a/src/matrix/room/timeline/persistence/SyncPersister.js b/src/matrix/room/timeline/persistence/SyncWriter.js similarity index 99% rename from src/matrix/room/timeline/persistence/SyncPersister.js rename to src/matrix/room/timeline/persistence/SyncWriter.js index 97b21952..f27e8a2e 100644 --- a/src/matrix/room/timeline/persistence/SyncPersister.js +++ b/src/matrix/room/timeline/persistence/SyncWriter.js @@ -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)