forked from cwtch.im/cwtch-ui
new lcg; cleanup
This commit is contained in:
parent
793b6e2e1a
commit
589bc4c36c
|
@ -1 +1 @@
|
||||||
2022-01-19-16-16-v1.5.4-11-g84d451f
|
2022-01-20-12-53-v1.5.4-14-g6865ec1
|
|
@ -1 +1 @@
|
||||||
2022-01-19-21-15-v1.5.4-11-g84d451f
|
2022-01-20-17-53-v1.5.4-14-g6865ec1
|
|
@ -21,7 +21,6 @@ class ContactInfoState extends ChangeNotifier {
|
||||||
late Map<String, GlobalKey<MessageRowState>> keys;
|
late Map<String, GlobalKey<MessageRowState>> keys;
|
||||||
int _newMarker = 0;
|
int _newMarker = 0;
|
||||||
DateTime _newMarkerClearAt = DateTime.now();
|
DateTime _newMarkerClearAt = DateTime.now();
|
||||||
//late List<MessageInfo?> messageCache;
|
|
||||||
late MessageCache messageCache;
|
late MessageCache messageCache;
|
||||||
|
|
||||||
// todo: a nicer way to model contacts, groups and other "entities"
|
// todo: a nicer way to model contacts, groups and other "entities"
|
||||||
|
@ -56,7 +55,6 @@ class ContactInfoState extends ChangeNotifier {
|
||||||
this._lastMessageTime = lastMessageTime == null ? DateTime.fromMillisecondsSinceEpoch(0) : lastMessageTime;
|
this._lastMessageTime = lastMessageTime == null ? DateTime.fromMillisecondsSinceEpoch(0) : lastMessageTime;
|
||||||
this._server = server;
|
this._server = server;
|
||||||
this._archived = archived;
|
this._archived = archived;
|
||||||
//this.messageCache = List.empty(growable: true);
|
|
||||||
this.messageCache = new MessageCache();
|
this.messageCache = new MessageCache();
|
||||||
keys = Map<String, GlobalKey<MessageRowState>>();
|
keys = Map<String, GlobalKey<MessageRowState>>();
|
||||||
}
|
}
|
||||||
|
@ -66,6 +64,7 @@ class ContactInfoState extends ChangeNotifier {
|
||||||
String get savePeerHistory => this._savePeerHistory;
|
String get savePeerHistory => this._savePeerHistory;
|
||||||
|
|
||||||
String? get acnCircuit => this._acnCircuit;
|
String? get acnCircuit => this._acnCircuit;
|
||||||
|
|
||||||
set acnCircuit(String? acnCircuit) {
|
set acnCircuit(String? acnCircuit) {
|
||||||
this._acnCircuit = acnCircuit;
|
this._acnCircuit = acnCircuit;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
@ -92,6 +91,7 @@ class ContactInfoState extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get isGroup => this._isGroup;
|
bool get isGroup => this._isGroup;
|
||||||
|
|
||||||
set isGroup(bool newVal) {
|
set isGroup(bool newVal) {
|
||||||
this._isGroup = newVal;
|
this._isGroup = newVal;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
@ -112,12 +112,14 @@ class ContactInfoState extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
String get status => this._status;
|
String get status => this._status;
|
||||||
|
|
||||||
set status(String newVal) {
|
set status(String newVal) {
|
||||||
this._status = newVal;
|
this._status = newVal;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
int get unreadMessages => this._unreadMessages;
|
int get unreadMessages => this._unreadMessages;
|
||||||
|
|
||||||
set unreadMessages(int newVal) {
|
set unreadMessages(int newVal) {
|
||||||
// don't reset newMarker position when unreadMessages is being cleared
|
// don't reset newMarker position when unreadMessages is being cleared
|
||||||
if (newVal > 0) {
|
if (newVal > 0) {
|
||||||
|
@ -151,18 +153,21 @@ class ContactInfoState extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
int get totalMessages => this._totalMessages;
|
int get totalMessages => this._totalMessages;
|
||||||
|
|
||||||
set totalMessages(int newVal) {
|
set totalMessages(int newVal) {
|
||||||
this._totalMessages = newVal;
|
this._totalMessages = newVal;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
String get imagePath => this._imagePath;
|
String get imagePath => this._imagePath;
|
||||||
|
|
||||||
set imagePath(String newVal) {
|
set imagePath(String newVal) {
|
||||||
this._imagePath = newVal;
|
this._imagePath = newVal;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime get lastMessageTime => this._lastMessageTime;
|
DateTime get lastMessageTime => this._lastMessageTime;
|
||||||
|
|
||||||
set lastMessageTime(DateTime newVal) {
|
set lastMessageTime(DateTime newVal) {
|
||||||
this._lastMessageTime = newVal;
|
this._lastMessageTime = newVal;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
@ -217,13 +222,8 @@ class ContactInfoState extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bumpMessageCache() {
|
|
||||||
this.messageCache.bumpMessageCache();
|
|
||||||
this.totalMessages += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ackCache(int messageID) {
|
void ackCache(int messageID) {
|
||||||
this.messageCache.ackCache(messageID);
|
this.messageCache.ackCache(messageID);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,15 +141,15 @@ Future<MessageInfo?> fetchAndCacheMessageInfo(BuildContext context, String profi
|
||||||
return rawMessageEnvelopeFuture.then((dynamic rawMessageEnvelope) {
|
return rawMessageEnvelopeFuture.then((dynamic rawMessageEnvelope) {
|
||||||
try {
|
try {
|
||||||
dynamic messageWrapper = jsonDecode(rawMessageEnvelope);
|
dynamic messageWrapper = jsonDecode(rawMessageEnvelope);
|
||||||
// There are 2 conditions in which this error condition can be met:
|
// There are 2 conditions in which this error condition can be met:
|
||||||
// 1. The application == nil, in which case this instance of the UI is already
|
// 1. The application == nil, in which case this instance of the UI is already
|
||||||
// broken beyond repair, and will either be replaced by a new version, or requires a complete
|
// broken beyond repair, and will either be replaced by a new version, or requires a complete
|
||||||
// restart.
|
// restart.
|
||||||
// 2. This index was incremented and we happened to fetch the timeline prior to the messages inclusion.
|
// 2. This index was incremented and we happened to fetch the timeline prior to the messages inclusion.
|
||||||
// This should be rare as Timeline addition/fetching is mutex protected and Dart itself will pipeline the
|
// This should be rare as Timeline addition/fetching is mutex protected and Dart itself will pipeline the
|
||||||
// calls to libCwtch-go - however because we use goroutines on the backend there is always a chance that one
|
// calls to libCwtch-go - however because we use goroutines on the backend there is always a chance that one
|
||||||
// will find itself delayed.
|
// will find itself delayed.
|
||||||
// The second case is recoverable by tail-recursing this future.
|
// The second case is recoverable by tail-recursing this future.
|
||||||
if (messageWrapper['Message'] == null || messageWrapper['Message'] == '' || messageWrapper['Message'] == '{}') {
|
if (messageWrapper['Message'] == null || messageWrapper['Message'] == '' || messageWrapper['Message'] == '{}') {
|
||||||
return Future.delayed(Duration(seconds: 2), () {
|
return Future.delayed(Duration(seconds: 2), () {
|
||||||
print("Tail recursive call to messageHandler called. This should be a rare event. If you see multiples of this log over a short period of time please log it as a bug.");
|
print("Tail recursive call to messageHandler called. This should be a rare event. If you see multiples of this log over a short period of time please log it as a bug.");
|
||||||
|
|
|
@ -51,11 +51,6 @@ class MessageCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO inserting nulls travel down list causing fails for all
|
|
||||||
void bumpMessageCache() {
|
|
||||||
this.cacheByIndex.insert(0, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ackCache(int messageID) {
|
void ackCache(int messageID) {
|
||||||
cache[messageID]?.metadata.ackd = true;
|
cache[messageID]?.metadata.ackd = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,9 +227,9 @@ class _MessageViewState extends State<MessageView> {
|
||||||
Future.delayed(const Duration(milliseconds: 80), () {
|
Future.delayed(const Duration(milliseconds: 80), () {
|
||||||
var profile = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
var profile = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
||||||
var identifier = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
var identifier = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
||||||
//Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(Provider.of<ContactInfoState>(context, listen: false).identifier)?.bumpMessageCache();
|
|
||||||
fetchAndCacheMessageInfo(context, profile, identifier, byIndex: true, index: 0);
|
fetchAndCacheMessageInfo(context, profile, identifier, byIndex: true, index: 0);
|
||||||
Provider.of<ContactInfoState>(context, listen: false).newMarker++;
|
Provider.of<ContactInfoState>(context, listen: false).newMarker++;
|
||||||
|
Provider.of<ContactInfoState>(context, listen: false).totalMessages += 1;
|
||||||
// Resort the contact list...
|
// Resort the contact list...
|
||||||
Provider.of<ProfileInfoState>(context, listen: false).contactList.updateLastMessageTime(Provider.of<ContactInfoState>(context, listen: false).identifier, DateTime.now());
|
Provider.of<ProfileInfoState>(context, listen: false).contactList.updateLastMessageTime(Provider.of<ContactInfoState>(context, listen: false).identifier, DateTime.now());
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue