|
| 1 | +/* |
| 2 | +different room types create different kind of "sync listeners", who implement the sync lifecycle handlers |
| 3 | +
|
| 4 | +they would each have a factory, |
| 5 | +*/ |
| 6 | + |
| 7 | +interface IRoomSyncHandler { |
| 8 | + prepareSync() |
| 9 | + afterPrepareSync() |
| 10 | + writeSync() |
| 11 | + afterSync() |
| 12 | + afterSyncCompleted() |
| 13 | +} |
| 14 | + |
| 15 | +interface IRoom extends IRoomSyncHandler { |
| 16 | + start(): void; |
| 17 | + load(): void; |
| 18 | + get id(): string; |
| 19 | +} |
| 20 | + |
| 21 | +interface IRoomFactory<T extends IRoom> { |
| 22 | + createRoom(type, roomId, syncResponse): T |
| 23 | + createSchema(db, txn, oldVersion, version, log) |
| 24 | + get storesForSync(): string[]; |
| 25 | + get rooms(): ObservableMap<string, T> |
| 26 | +} |
| 27 | + |
| 28 | +class InstantMessageRoom implements IRoom { |
| 29 | +} |
| 30 | + |
| 31 | +class InstantMessageRoomFactory implements IRoomFactory<InstantMessageRoom>{ |
| 32 | + loadLastMessages(): Promise<void> |
| 33 | + /* |
| 34 | + get all room ids and sort them according to idb sorting order |
| 35 | + open cursor 'f' on `timelineFragments` |
| 36 | + open a cursor 'e' on `timelineEvents` |
| 37 | + for each room: |
| 38 | + with cursor 'f', go to last fragment id and go up from there to find live fragment |
| 39 | + with cursor 'e', go to last event index for fragment id and room id and go up until we have acceptable event type |
| 40 | + for encrypted rooms: |
| 41 | + decrypt message if needed (m.room.encrypted is likely something we want to display) |
| 42 | + */ |
| 43 | +} |
| 44 | + |
| 45 | +class SpaceRoom implements IRoom {} |
| 46 | + |
| 47 | +class SpaceRoomFactory implements IRoomFactory<SpaceRoom> { |
| 48 | + createRoom(type, roomId, syncResponse): IRoomSyncHandler |
| 49 | +} |
| 50 | + |
| 51 | +class Session { |
| 52 | + constructor(roomFactoriesByType: Map<string, IRoomFactory>) { |
| 53 | + |
| 54 | + } |
| 55 | +} |
0 commit comments