new lcg; cleanup
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Dan Ballard 2022-01-20 13:05:11 -05:00
parent 793b6e2e1a
commit 589bc4c36c
6 changed files with 20 additions and 25 deletions

View File

@ -1 +1 @@
2022-01-19-16-16-v1.5.4-11-g84d451f
2022-01-20-12-53-v1.5.4-14-g6865ec1

View File

@ -1 +1 @@
2022-01-19-21-15-v1.5.4-11-g84d451f
2022-01-20-17-53-v1.5.4-14-g6865ec1

View File

@ -21,7 +21,6 @@ class ContactInfoState extends ChangeNotifier {
late Map<String, GlobalKey<MessageRowState>> keys;
int _newMarker = 0;
DateTime _newMarkerClearAt = DateTime.now();
//late List<MessageInfo?> messageCache;
late MessageCache messageCache;
// 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._server = server;
this._archived = archived;
//this.messageCache = List.empty(growable: true);
this.messageCache = new MessageCache();
keys = Map<String, GlobalKey<MessageRowState>>();
}
@ -66,6 +64,7 @@ class ContactInfoState extends ChangeNotifier {
String get savePeerHistory => this._savePeerHistory;
String? get acnCircuit => this._acnCircuit;
set acnCircuit(String? acnCircuit) {
this._acnCircuit = acnCircuit;
notifyListeners();
@ -92,6 +91,7 @@ class ContactInfoState extends ChangeNotifier {
}
bool get isGroup => this._isGroup;
set isGroup(bool newVal) {
this._isGroup = newVal;
notifyListeners();
@ -112,12 +112,14 @@ class ContactInfoState extends ChangeNotifier {
}
String get status => this._status;
set status(String newVal) {
this._status = newVal;
notifyListeners();
}
int get unreadMessages => this._unreadMessages;
set unreadMessages(int newVal) {
// don't reset newMarker position when unreadMessages is being cleared
if (newVal > 0) {
@ -151,18 +153,21 @@ class ContactInfoState extends ChangeNotifier {
}
int get totalMessages => this._totalMessages;
set totalMessages(int newVal) {
this._totalMessages = newVal;
notifyListeners();
}
String get imagePath => this._imagePath;
set imagePath(String newVal) {
this._imagePath = newVal;
notifyListeners();
}
DateTime get lastMessageTime => this._lastMessageTime;
set lastMessageTime(DateTime newVal) {
this._lastMessageTime = newVal;
notifyListeners();
@ -217,13 +222,8 @@ class ContactInfoState extends ChangeNotifier {
}
}
void bumpMessageCache() {
this.messageCache.bumpMessageCache();
this.totalMessages += 1;
}
void ackCache(int messageID) {
this.messageCache.ackCache(messageID);
notifyListeners();
}
}
}

View File

@ -141,15 +141,15 @@ Future<MessageInfo?> fetchAndCacheMessageInfo(BuildContext context, String profi
return rawMessageEnvelopeFuture.then((dynamic rawMessageEnvelope) {
try {
dynamic messageWrapper = jsonDecode(rawMessageEnvelope);
// 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
// broken beyond repair, and will either be replaced by a new version, or requires a complete
// restart.
// 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
// calls to libCwtch-go - however because we use goroutines on the backend there is always a chance that one
// will find itself delayed.
// The second case is recoverable by tail-recursing this future.
// 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
// broken beyond repair, and will either be replaced by a new version, or requires a complete
// restart.
// 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
// calls to libCwtch-go - however because we use goroutines on the backend there is always a chance that one
// will find itself delayed.
// The second case is recoverable by tail-recursing this future.
if (messageWrapper['Message'] == null || messageWrapper['Message'] == '' || messageWrapper['Message'] == '{}') {
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.");

View File

@ -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) {
cache[messageID]?.metadata.ackd = true;
}

View File

@ -227,9 +227,9 @@ class _MessageViewState extends State<MessageView> {
Future.delayed(const Duration(milliseconds: 80), () {
var profile = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
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);
Provider.of<ContactInfoState>(context, listen: false).newMarker++;
Provider.of<ContactInfoState>(context, listen: false).totalMessages += 1;
// Resort the contact list...
Provider.of<ProfileInfoState>(context, listen: false).contactList.updateLastMessageTime(Provider.of<ContactInfoState>(context, listen: false).identifier, DateTime.now());
});