forked from cwtch.im/cwtch-ui
android pre load unsynced messages
This commit is contained in:
parent
0bcfe75a63
commit
0647a2d98d
|
@ -101,8 +101,6 @@ class MessageCache extends ChangeNotifier {
|
||||||
// On android reconnect, if backend supplied message count > UI message count, add the differnce to the front of the index
|
// On android reconnect, if backend supplied message count > UI message count, add the differnce to the front of the index
|
||||||
void addFrontIndexGap(int count) {
|
void addFrontIndexGap(int count) {
|
||||||
this._indexUnsynced = count;
|
this._indexUnsynced = count;
|
||||||
// TODO: needed? maybe not? since after totalmessatges and profile will notify
|
|
||||||
//notifyListeners();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get indexUnsynced => _indexUnsynced;
|
int get indexUnsynced => _indexUnsynced;
|
||||||
|
|
|
@ -168,6 +168,16 @@ class _MessageViewState extends State<MessageView> {
|
||||||
|
|
||||||
Future<bool> _onWillPop() async {
|
Future<bool> _onWillPop() async {
|
||||||
Provider.of<ContactInfoState>(context, listen: false).unreadMessages = 0;
|
Provider.of<ContactInfoState>(context, listen: false).unreadMessages = 0;
|
||||||
|
|
||||||
|
var previouslySelected = Provider.of<AppState>(context, listen: false).selectedConversation;
|
||||||
|
if (previouslySelected != null) {
|
||||||
|
Provider
|
||||||
|
.of<ProfileInfoState>(context, listen: false)
|
||||||
|
.contactList
|
||||||
|
.getContact(previouslySelected)!
|
||||||
|
.unselected();
|
||||||
|
}
|
||||||
|
|
||||||
Provider.of<AppState>(context, listen: false).selectedConversation = null;
|
Provider.of<AppState>(context, listen: false).selectedConversation = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,10 @@ class _MessageListState extends State<MessageList> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext outerContext) {
|
Widget build(BuildContext outerContext) {
|
||||||
// On Android we can have unsynced messages at the front of the index from when the UI was asleep, if there are some, kick off sync of those first
|
// On Android we can have unsynced messages at the front of the index from when the UI was asleep, if there are some, kick off sync of those first
|
||||||
if (Provider.of<ContactInfoState>(outerContext).messageCache.indexUnsynced != 0) {
|
if (Provider.of<ContactInfoState>(context).messageCache.indexUnsynced != 0) {
|
||||||
var conversationId = Provider.of<AppState>(context, listen: false).selectedConversation!;
|
var conversationId = Provider.of<AppState>(outerContext, listen: false).selectedConversation!;
|
||||||
MessageCache? cache = Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(conversationId)?.messageCache;
|
MessageCache? cache = Provider.of<ProfileInfoState>(outerContext, listen: false).contactList.getContact(conversationId)?.messageCache;
|
||||||
ByIndex(Provider.of<AppState>(context, listen: false).selectedIndex!).loadUnsynced(Provider.of<FlwtchState>(context, listen: false).cwtch, Provider.of<AppState>(context, listen: false).selectedProfile!, conversationId, cache!);
|
ByIndex(0).loadUnsynced(Provider.of<FlwtchState>(context, listen: false).cwtch, Provider.of<AppState>(outerContext, listen: false).selectedProfile!, conversationId, cache!);
|
||||||
}
|
}
|
||||||
|
|
||||||
var initi = Provider.of<AppState>(outerContext, listen: false).initialScrollIndex;
|
var initi = Provider.of<AppState>(outerContext, listen: false).initialScrollIndex;
|
||||||
|
|
Loading…
Reference in New Issue