Updates, fix timer bug

This commit is contained in:
Sarah Jamie Lewis 2021-01-07 21:37:21 -08:00
parent 062e5af108
commit 258093903f
3 changed files with 13 additions and 3 deletions

View File

@ -29,7 +29,7 @@ class FlwtchState extends State<Flwtch> {
// ignore: non_constant_identifier_names
final StartCwtch = startCwtchC.asFunction<StartCwtchFn>();
var cwtchDir = "/home/erinn/.cwtch/dev/";
var cwtchDir = "/home/sarah/.cwtch/dev/";
StartCwtch(Utf8.toUtf8(cwtchDir), cwtchDir.length);
return Provider<FlwtchState>(

View File

@ -37,7 +37,12 @@ class _MessageViewState extends State<MessageView> {
final GetMessage = getMessageC.asFunction<GetJsonBlobFromStrStrIntFn>();
_updateMessageCount(context, NumMessages);
timer = Timer.periodic(Duration(seconds: 1), (Timer t) => _updateMessageCount(context, NumMessages));
if (timer == null) {
timer = Timer.periodic(Duration(seconds: 1), (Timer t) {
print("tick");
_updateMessageCount(context, NumMessages);
});
}
return ProxyProvider0(
@ -64,6 +69,11 @@ class _MessageViewState extends State<MessageView> {
}
Future _updateMessageCount(BuildContext context, GetIntFromStrStrFn cfn) async {
if (!mounted) {
if (timer != null && timer.isActive) timer.cancel();
return;
}
setState(() {
conversationNumMessages = cfn(
Utf8.toUtf8(widget.profileOnion), widget.profileOnion.length,

View File

@ -84,7 +84,7 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
subtitle: Text(profile.onion),
onTap: () {
setState(() {
var selectProfileC = Provider.of<FlwtchState>(context).library.lookup<NativeFunction<get_json_blob_string_function>>("SelectProfile");
var selectProfileC = Provider.of<FlwtchState>(context, listen:false).library.lookup<NativeFunction<get_json_blob_string_function>>("SelectProfile");
// ignore: non_constant_identifier_names
final SelectProfile = selectProfileC.asFunction<GetJsonBlobStringFn>();