EventIndex: Move the event listener registration into the EventIndex class.

This commit is contained in:
Damir Jelić 2019-11-19 10:46:18 +01:00
parent d2a9918359
commit 6017473caf
3 changed files with 40 additions and 30 deletions

View file

@ -31,7 +31,6 @@ import Analytics from "../../Analytics";
import { DecryptionFailureTracker } from "../../DecryptionFailureTracker";
import MatrixClientPeg from "../../MatrixClientPeg";
import PlatformPeg from "../../PlatformPeg";
import EventIndexPeg from "../../EventIndexPeg";
import SdkConfig from "../../SdkConfig";
import * as RoomListSorter from "../../RoomListSorter";
import dis from "../../dispatcher";
@ -1288,31 +1287,6 @@ export default createReactClass({
return self._loggedInView.child.canResetTimelineInRoom(roomId);
});
cli.on('sync', async (state, prevState, data) => {
const eventIndex = EventIndexPeg.get();
if (eventIndex === null) return;
await eventIndex.onSync(state, prevState, data);
});
cli.on("Room.timeline", async (ev, room, toStartOfTimeline, removed, data) => {
const eventIndex = EventIndexPeg.get();
if (eventIndex === null) return;
await eventIndex.onRoomTimeline(ev, room, toStartOfTimeline, removed, data);
});
cli.on("Event.decrypted", async (ev, err) => {
const eventIndex = EventIndexPeg.get();
if (eventIndex === null) return;
await eventIndex.onEventDecrypted(ev, err);
});
cli.on("Room.timelineReset", async (room, timelineSet, resetAllTimelines) => {
const eventIndex = EventIndexPeg.get();
if (eventIndex === null) return;
if (room === null) return;
await eventIndex.onLimitedTimeline(room);
});
cli.on('sync', function(state, prevState, data) {
// LifecycleStore and others cannot directly subscribe to matrix client for
// events because flux only allows store state changes during flux dispatches.