Improved announce stream

This commit is contained in:
Mark Qvist 2022-10-08 19:55:46 +02:00
parent c54422d771
commit c5ad94b2d3
2 changed files with 36 additions and 14 deletions

View File

@ -373,6 +373,9 @@ class SidebandCore():
def clear_conversation(self, context_dest):
self._db_clear_conversation(context_dest)
def delete_announce(self, context_dest):
self._db_delete_announce(context_dest)
def delete_conversation(self, context_dest):
self._db_clear_conversation(context_dest)
self._db_delete_conversation(context_dest)
@ -666,7 +669,7 @@ class SidebandCore():
return conv
def _db_clear_conversation(self, context_dest):
RNS.log("Clearing conversation with "+RNS.prettyhexrep(context_dest))
RNS.log("Clearing conversation with "+RNS.prettyhexrep(context_dest), RNS.LOG_DEBUG)
db = sqlite3.connect(self.db_path)
dbc = db.cursor()
@ -677,7 +680,7 @@ class SidebandCore():
db.close()
def _db_delete_conversation(self, context_dest):
RNS.log("Deleting conversation with "+RNS.prettyhexrep(context_dest))
RNS.log("Deleting conversation with "+RNS.prettyhexrep(context_dest), RNS.LOG_DEBUG)
db = sqlite3.connect(self.db_path)
dbc = db.cursor()
@ -687,8 +690,19 @@ class SidebandCore():
db.close()
def _db_delete_announce(self, context_dest):
RNS.log("Deleting announce with "+RNS.prettyhexrep(context_dest), RNS.LOG_DEBUG)
db = sqlite3.connect(self.db_path)
dbc = db.cursor()
query = "delete from announce where (source=:ctx_dst);"
dbc.execute(query, {"ctx_dst": context_dest})
db.commit()
db.close()
def _db_create_conversation(self, context_dest, name = None, trust = False):
RNS.log("Creating conversation for "+RNS.prettyhexrep(context_dest))
RNS.log("Creating conversation for "+RNS.prettyhexrep(context_dest), RNS.LOG_DEBUG)
db = sqlite3.connect(self.db_path)
dbc = db.cursor()

View File

@ -8,6 +8,7 @@ from kivymd.uix.list import MDList, IconLeftWidget, IconRightWidget, OneLineAvat
from kivymd.uix.menu import MDDropdownMenu
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.clock import Clock
from kivymd.uix.button import MDFlatButton
from kivymd.uix.dialog import MDDialog
@ -42,9 +43,11 @@ class Announces():
self.added_item_dests = []
def update(self):
us = time.time()
self.fetch_announces()
self.update_widget()
self.app.sideband.setstate("app.flags.new_announces", False)
RNS.log("Updated announce stream widgets in "+RNS.prettytime(time.time()-us), RNS.LOG_DEBUG)
def update_widget(self):
if self.list == None:
@ -138,8 +141,10 @@ class Announces():
)
def dl_yes(s):
dialog.dismiss()
def cb(dt):
self.app.sideband.delete_announce(dest)
self.reload()
self.update()
Clock.schedule_once(cb, 0.2)
def dl_no(s):
dialog.dismiss()
@ -171,12 +176,12 @@ class Announces():
"height": dp(40),
"on_release": gen_conv(context_dest, item)
},
# {
# "text": "Delete Announce",
# "viewclass": "OneLineListItem",
# "height": dp(40),
# "on_release": gen_del(context_dest, item)
# }
{
"text": "Delete Announce",
"viewclass": "OneLineListItem",
"height": dp(40),
"on_release": gen_del(context_dest, item)
}
]
elif dest_type == "lxmf.propagation":
@ -187,6 +192,12 @@ class Announces():
"height": dp(40),
"on_release": gen_set_node(context_dest, item)
},
{
"text": "Delete Announce",
"viewclass": "OneLineListItem",
"height": dp(40),
"on_release": gen_del(context_dest, item)
}
]
else:
@ -201,8 +212,6 @@ class Announces():
width_mult=4,
elevation=1,
radius=dp(3),
opening_transition="linear",
opening_time=0.0,
)
def callback_factory(ref):
@ -211,7 +220,6 @@ class Announces():
return x
item.iconr.bind(on_release=callback_factory(item))
item.add_widget(item.iconr)
self.added_item_dests.append(context_dest)