From 01f561b41272e0e2aee537d8641c0f06d620d245 Mon Sep 17 00:00:00 2001 From: shekhar-cis Date: Tue, 17 May 2022 21:02:51 +0530 Subject: [PATCH] Fixed Draft mail details bug --- src/bitmessagekivy/baseclass/maildetail.py | 21 ++++++++++++--------- src/bitmessagekivy/mpybit.py | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/bitmessagekivy/baseclass/maildetail.py b/src/bitmessagekivy/baseclass/maildetail.py index 1bb8a6c5..7921319c 100644 --- a/src/bitmessagekivy/baseclass/maildetail.py +++ b/src/bitmessagekivy/baseclass/maildetail.py @@ -10,6 +10,7 @@ from kivy.properties import ( NumericProperty ) from kivy.factory import Factory +from kivy.app import App from kivymd.uix.button import MDFlatButton, MDIconButton from kivymd.uix.dialog import MDDialog @@ -92,16 +93,18 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes def __init__(self, *args, **kwargs): """Mail Details method""" super(MailDetail, self).__init__(*args, **kwargs) + self.kivy_running_app = App.get_running_app() + self.kivy_state = self.kivy_running_app.kivy_state_obj Clock.schedule_once(self.init_ui, 0) def init_ui(self, dt=0): """Clock Schdule for method MailDetail mails""" self.page_type = state.detailPageType if state.detailPageType else '' try: - if state.detailPageType == 'sent' or state.detailPageType == 'draft': + if state.detailPageType == 'sent' or self.kivy_state.detailPageType == 'draft': data = sqlQuery( "select toaddress, fromaddress, subject, message, status," - " ackdata, senttime from sent where ackdata = ?;", state.mail_id) + " ackdata, senttime from sent where ackdata = ?;", self.kivy_state.mail_id) state.status = self state.ackdata = data[0][5] self.assign_mail_details(data) @@ -128,7 +131,7 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes if len(data[0]) == 7: self.status = data[0][4] self.time_tag = ShowTimeHistoy(data[0][4]) if state.detailPageType == 'inbox' else ShowTimeHistoy(data[0][6]) - self.avatarImg = state.imageDir + '/avatar.png' if state.detailPageType == 'draft' else ( + self.avatarImg = state.imageDir + '/avatar.png' if self.kivy_state.detailPageType == 'draft' else ( state.imageDir + '/text_images/{0}.png'.format(avatarImageFirstLetter(self.subject.strip()))) self.timeinseconds = data[0][4] if state.detailPageType == 'inbox' else data[0][6] @@ -157,11 +160,11 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes self.parent.screens[0].ids.ml.clear_widgets() self.parent.screens[0].loadMessagelist(state.association) - elif state.detailPageType == 'draft': - sqlExecute("DELETE FROM sent WHERE ackdata = ?;", state.mail_id) + elif self.kivy_state.detailPageType == 'draft': + sqlExecute("DELETE FROM sent WHERE ackdata = ?;", self.kivy_state.mail_id) msg_count_objs.draft_cnt.ids.badge_txt.text = str( - int(state.draft_count) - 1) - state.draft_count = str(int(state.draft_count) - 1) + int(self.kivy_state.draft_count) - 1) + self.kivy_state.draft_count = str(int(self.kivy_state.draft_count) - 1) self.parent.screens[13].clear_widgets() self.parent.screens[13].add_widget(Factory.Draft()) @@ -214,10 +217,10 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes def write_msg(self, navApp): """Write on draft mail""" - state.send_draft_mail = state.mail_id + state.send_draft_mail = self.kivy_state.mail_id data = sqlQuery( "select toaddress, fromaddress, subject, message from sent where" - " ackdata = ?;", state.mail_id) + " ackdata = ?;", self.kivy_state.mail_id) composer_ids = ( self.parent.parent.ids.sc3.children[1].ids) composer_ids.ti.text = data[0][1] diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index bb893c59..014284f1 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -645,7 +645,7 @@ class NavigateApp(MDApp): self.root.ids.scr_mngr.transition = SlideTransition() self.root.ids.scr_mngr.transition.direction = 'right' self.root.ids.scr_mngr.transition.bind(on_complete=self.reset) - if state.is_allmail or state.detailPageType == 'draft': + if state.is_allmail or self.kivy_state_obj.detailPageType == 'draft': state.is_allmail = False state.detailPageType = '' state.in_composer = False @@ -812,7 +812,7 @@ class NavigateApp(MDApp): delete_btn] elif state.detailPageType == 'sent': dynamic_list = [delete_btn] - elif state.detailPageType == 'draft': + elif self.kivy_state_obj.detailPageType == 'draft': dynamic_list = [ ['pencil', lambda x: self.root.ids.sc14.write_msg(self)], delete_btn]