Fixed badge count issue. 37/57337/1
authorpolu.sandeep <polu.sandeep@samsung.com>
Tue, 19 Jan 2016 08:22:08 +0000 (17:22 +0900)
committerpolu.sandeep <polu.sandeep@samsung.com>
Tue, 19 Jan 2016 08:22:08 +0000 (17:22 +0900)
Change-Id: Iabc5e98d6dd76f0624d1160137c48d453df6f978

TelegramTizen/src/telegramtizen.c
tg-engine-service/src/server_response.c

index 5ea36dc..50b9818 100644 (file)
@@ -1827,6 +1827,11 @@ static int on_message_received_from_buddy(appdata_s *app, bundle *const rec_msg,
                char content[512];
 
                int unread_msg_cnt = get_number_of_unread_messages();
+
+               if (unread_msg_cnt <= 0) {
+                       return result;
+               }
+
                sprintf(content, "%d new messages received.", unread_msg_cnt);
 
                char *sound_track = NULL;
@@ -3720,6 +3725,10 @@ Eina_Bool on_load_main_view_requested(void *data)
                hide_loading_popup(ad);
                launch_user_main_view_cb(ad);
                int unread_msg_cnt = get_number_of_unread_messages();
+               if (unread_msg_cnt <= 0) {
+                       return ECORE_CALLBACK_CANCEL;
+               }
+
                int err = badge_set_count(TELEGRAM_APP_ID, unread_msg_cnt);
                if (BADGE_ERROR_NONE != err) {
 
@@ -3908,6 +3917,9 @@ app_pause(void *data)
        if (app_data) {
                app_data->s_app_visible_state = APP_STATE_IN_BACKGROUND;
                int unread_msg_cnt = get_number_of_unread_messages();
+               if (unread_msg_cnt <= 0) {
+                       return;
+               }
                int err = badge_set_count(TELEGRAM_APP_ID, unread_msg_cnt);
                if (BADGE_ERROR_NONE != err) {
 
@@ -3932,11 +3944,12 @@ void free_app_data(appdata_s *app_data, Eina_Bool destroy_server)
        }
 
        int unread_msg_cnt = get_number_of_unread_messages();
-       int err = badge_set_count(TELEGRAM_APP_ID, unread_msg_cnt);
-       if (BADGE_ERROR_NONE != err) {
+       if (unread_msg_cnt > 0) {
+               int err = badge_set_count(TELEGRAM_APP_ID, unread_msg_cnt);
+               if (BADGE_ERROR_NONE != err) {
 
+               }
        }
-
        if (app_data->panel) {
                Evas_Object *panel_list = evas_object_data_get(app_data->panel, "panel_list");
                if (panel_list) {
index 037e115..97137b7 100644 (file)
@@ -872,9 +872,11 @@ void send_message_with_date_received_response(tg_engine_data_s *tg_data, int fro
                char *app_id = TELEGRAM_APP_ID;
                tg_notification_create(tg_data, icon_path, title, content, sound_track, app_id);
 
-               int err = badge_set_count(TELEGRAM_APP_ID, unread_msg_cnt);
-               if (BADGE_ERROR_NONE != err) {
+               if (unread_msg_cnt > 0) {
+                       int err = badge_set_count(TELEGRAM_APP_ID, unread_msg_cnt);
+                       if (BADGE_ERROR_NONE != err) {
 
+                       }
                }
        }
        bundle_free(msg);
@@ -943,9 +945,11 @@ void send_message_received_response(tg_engine_data_s *tg_data, int from_id, int
                char *app_id = TELEGRAM_APP_ID;
                tg_notification_create(tg_data, icon_path, title, content, sound_track, app_id);
 
-               int err = badge_set_count(TELEGRAM_APP_ID, unread_msg_cnt);
-               if (BADGE_ERROR_NONE != err) {
+               if (unread_msg_cnt > 0) {
+                       int err = badge_set_count(TELEGRAM_APP_ID, unread_msg_cnt);
+                       if (BADGE_ERROR_NONE != err) {
 
+                       }
                }
        }
        bundle_free(msg);