Browse code

Fix watchapp behavior when receving a second lastSent message

Natasha Kerensikova authored on16/04/2016 21:34:20
Showing1 changed files
... ...
@@ -38,6 +38,7 @@ static time_t minute_first = 0, minute_last = 0;
38 38
 static bool modal_displayed = false;
39 39
 static bool display_dirty = false;
40 40
 static char global_buffer[1024];
41
+static bool sending_data = false;
41 42
 
42 43
 static struct widget {
43 44
 	char		label[64];
... ...
@@ -374,6 +375,7 @@ static void
374 375
 send_next_line(void) {
375 376
 	if (minute_index >= minute_data_size
376 377
 	    && !load_minute_data_page(minute_last)) {
378
+		sending_data = false;
377 379
 		return;
378 380
 	}
379 381
 
... ...
@@ -400,11 +402,18 @@ handle_last_sent(Tuple *tuple) {
400 402
 	APP_LOG(APP_LOG_LEVEL_INFO, "received LAST_SENT %" PRIu32, ikey);
401 403
 
402 404
 	phone.start_time = time(0);
405
+	phone.first_key = phone.current_key = 0;
406
+	web.start_time = 0;
407
+	web.first_key = web.current_key = 0;
403 408
 	minute_index = 0;
404 409
 	minute_data_size = 0;
405 410
 	minute_last = ikey ? (ikey + 1) * 60 : 0;
406 411
 	set_modal_mode(false);
407
-	send_next_line();
412
+
413
+	if (!sending_data) {
414
+		sending_data = true;
415
+		send_next_line();
416
+	}
408 417
 }
409 418
 
410 419
 static void