implement Thread.fromJson
This commit is contained in:
parent
8f4da40dec
commit
4ca2a5eee3
|
|
@ -26,6 +26,7 @@ import 'package:html_unescape/html_unescape.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:matrix/src/models/timeline_chunk.dart';
|
import 'package:matrix/src/models/timeline_chunk.dart';
|
||||||
|
import 'package:matrix/src/room_timeline.dart';
|
||||||
import 'package:matrix/src/utils/cached_stream_controller.dart';
|
import 'package:matrix/src/utils/cached_stream_controller.dart';
|
||||||
import 'package:matrix/src/utils/file_send_request_credentials.dart';
|
import 'package:matrix/src/utils/file_send_request_credentials.dart';
|
||||||
import 'package:matrix/src/utils/markdown.dart';
|
import 'package:matrix/src/utils/markdown.dart';
|
||||||
|
|
@ -1690,7 +1691,7 @@ class Room {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final timeline = Timeline(
|
final timeline = RoomTimeline(
|
||||||
room: this,
|
room: this,
|
||||||
chunk: chunk,
|
chunk: chunk,
|
||||||
onChange: onChange,
|
onChange: onChange,
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,28 @@
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import 'package:async/async.dart';
|
|
||||||
import 'package:collection/collection.dart';
|
|
||||||
import 'package:html_unescape/html_unescape.dart';
|
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:matrix/src/models/timeline_chunk.dart';
|
|
||||||
import 'package:matrix/src/utils/cached_stream_controller.dart';
|
|
||||||
import 'package:matrix/src/utils/file_send_request_credentials.dart';
|
|
||||||
import 'package:matrix/src/utils/markdown.dart';
|
|
||||||
import 'package:matrix/src/utils/marked_unread.dart';
|
|
||||||
import 'package:matrix/src/utils/space_child.dart';
|
|
||||||
|
|
||||||
class Thread {
|
class Thread {
|
||||||
final Room room;
|
final Room room;
|
||||||
final MatrixEvent rootEvent;
|
final MatrixEvent rootEvent;
|
||||||
|
final MatrixEvent? lastEvent;
|
||||||
|
|
||||||
Thread({
|
Thread({
|
||||||
required Room this.room,
|
required this.room,
|
||||||
required MatrixEvent this.rootEvent
|
required this.rootEvent,
|
||||||
}) {
|
this.lastEvent,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Thread.fromJson(Map<String, dynamic> json, Client client) {
|
||||||
|
final room = client.getRoomById(json['room_id']);
|
||||||
|
if (room == null) throw Error();
|
||||||
|
MatrixEvent? lastEvent;
|
||||||
|
if (json['unsigned']?['m.relations']?['m.thread']?['latest_event'] != null) {
|
||||||
|
lastEvent = MatrixEvent.fromJson(json['unsigned']?['m.relations']?['m.thread']?['latest_event']);
|
||||||
|
}
|
||||||
|
final thread = Thread(
|
||||||
|
room: room,
|
||||||
|
rootEvent: MatrixEvent.fromJson(json),
|
||||||
|
lastEvent: lastEvent
|
||||||
|
);
|
||||||
|
return thread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
import 'package:matrix/matrix.dart';
|
||||||
|
import 'package:matrix/src/models/timeline_chunk.dart';
|
||||||
|
import 'package:matrix/src/thread.dart';
|
||||||
|
|
||||||
|
class ThreadTimeline extends Timeline {
|
||||||
|
final Thread thread;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Event> get events => chunk.events;
|
||||||
|
|
||||||
|
TimelineChunk chunk;
|
||||||
|
|
||||||
|
ThreadTimeline({
|
||||||
|
required this.thread,
|
||||||
|
required this.chunk
|
||||||
|
}) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@override
|
||||||
|
// TODO: implement canRequestFuture
|
||||||
|
bool get canRequestFuture => throw UnimplementedError();
|
||||||
|
|
||||||
|
@override
|
||||||
|
// TODO: implement canRequestHistory
|
||||||
|
bool get canRequestHistory => throw UnimplementedError();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void cancelSubscriptions() {
|
||||||
|
// TODO: implement cancelSubscriptions
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Event?> getEventById(String id) {
|
||||||
|
// TODO: implement getEventById
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> requestFuture({int historyCount = Room.defaultHistoryCount, StateFilter? filter}) {
|
||||||
|
// TODO: implement requestFuture
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> requestHistory({int historyCount = Room.defaultHistoryCount, StateFilter? filter}) {
|
||||||
|
// TODO: implement requestHistory
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void requestKeys({bool tryOnlineBackup = true, bool onlineKeyBackupOnly = true}) {
|
||||||
|
// TODO: implement requestKeys
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> setReadMarker({String? eventId, bool? public}) {
|
||||||
|
// TODO: implement setReadMarker
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Stream<(List<Event>, String?)> startSearch({String? searchTerm, int requestHistoryCount = 100, int maxHistoryRequests = 10, String? prevBatch, String? sinceEventId, int? limit, bool Function(Event p1)? searchFunc}) {
|
||||||
|
// TODO: implement startSearch
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue