mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-26 07:10:37 +01:00
Improved announce stream
This commit is contained in:
parent
c54422d771
commit
c5ad94b2d3
@ -373,6 +373,9 @@ class SidebandCore():
|
|||||||
def clear_conversation(self, context_dest):
|
def clear_conversation(self, context_dest):
|
||||||
self._db_clear_conversation(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):
|
def delete_conversation(self, context_dest):
|
||||||
self._db_clear_conversation(context_dest)
|
self._db_clear_conversation(context_dest)
|
||||||
self._db_delete_conversation(context_dest)
|
self._db_delete_conversation(context_dest)
|
||||||
@ -666,7 +669,7 @@ class SidebandCore():
|
|||||||
return conv
|
return conv
|
||||||
|
|
||||||
def _db_clear_conversation(self, context_dest):
|
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)
|
db = sqlite3.connect(self.db_path)
|
||||||
dbc = db.cursor()
|
dbc = db.cursor()
|
||||||
|
|
||||||
@ -677,7 +680,7 @@ class SidebandCore():
|
|||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
def _db_delete_conversation(self, context_dest):
|
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)
|
db = sqlite3.connect(self.db_path)
|
||||||
dbc = db.cursor()
|
dbc = db.cursor()
|
||||||
|
|
||||||
@ -687,8 +690,19 @@ class SidebandCore():
|
|||||||
|
|
||||||
db.close()
|
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):
|
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)
|
db = sqlite3.connect(self.db_path)
|
||||||
dbc = db.cursor()
|
dbc = db.cursor()
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ from kivymd.uix.list import MDList, IconLeftWidget, IconRightWidget, OneLineAvat
|
|||||||
from kivymd.uix.menu import MDDropdownMenu
|
from kivymd.uix.menu import MDDropdownMenu
|
||||||
from kivy.uix.gridlayout import GridLayout
|
from kivy.uix.gridlayout import GridLayout
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
|
from kivy.clock import Clock
|
||||||
|
|
||||||
from kivymd.uix.button import MDFlatButton
|
from kivymd.uix.button import MDFlatButton
|
||||||
from kivymd.uix.dialog import MDDialog
|
from kivymd.uix.dialog import MDDialog
|
||||||
@ -42,9 +43,11 @@ class Announces():
|
|||||||
self.added_item_dests = []
|
self.added_item_dests = []
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
us = time.time()
|
||||||
self.fetch_announces()
|
self.fetch_announces()
|
||||||
self.update_widget()
|
self.update_widget()
|
||||||
self.app.sideband.setstate("app.flags.new_announces", False)
|
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):
|
def update_widget(self):
|
||||||
if self.list == None:
|
if self.list == None:
|
||||||
@ -138,8 +141,10 @@ class Announces():
|
|||||||
)
|
)
|
||||||
def dl_yes(s):
|
def dl_yes(s):
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
|
def cb(dt):
|
||||||
self.app.sideband.delete_announce(dest)
|
self.app.sideband.delete_announce(dest)
|
||||||
self.reload()
|
self.update()
|
||||||
|
Clock.schedule_once(cb, 0.2)
|
||||||
def dl_no(s):
|
def dl_no(s):
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
|
|
||||||
@ -171,12 +176,12 @@ class Announces():
|
|||||||
"height": dp(40),
|
"height": dp(40),
|
||||||
"on_release": gen_conv(context_dest, item)
|
"on_release": gen_conv(context_dest, item)
|
||||||
},
|
},
|
||||||
# {
|
{
|
||||||
# "text": "Delete Announce",
|
"text": "Delete Announce",
|
||||||
# "viewclass": "OneLineListItem",
|
"viewclass": "OneLineListItem",
|
||||||
# "height": dp(40),
|
"height": dp(40),
|
||||||
# "on_release": gen_del(context_dest, item)
|
"on_release": gen_del(context_dest, item)
|
||||||
# }
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
elif dest_type == "lxmf.propagation":
|
elif dest_type == "lxmf.propagation":
|
||||||
@ -187,6 +192,12 @@ class Announces():
|
|||||||
"height": dp(40),
|
"height": dp(40),
|
||||||
"on_release": gen_set_node(context_dest, item)
|
"on_release": gen_set_node(context_dest, item)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"text": "Delete Announce",
|
||||||
|
"viewclass": "OneLineListItem",
|
||||||
|
"height": dp(40),
|
||||||
|
"on_release": gen_del(context_dest, item)
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -201,8 +212,6 @@ class Announces():
|
|||||||
width_mult=4,
|
width_mult=4,
|
||||||
elevation=1,
|
elevation=1,
|
||||||
radius=dp(3),
|
radius=dp(3),
|
||||||
opening_transition="linear",
|
|
||||||
opening_time=0.0,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def callback_factory(ref):
|
def callback_factory(ref):
|
||||||
@ -211,7 +220,6 @@ class Announces():
|
|||||||
return x
|
return x
|
||||||
|
|
||||||
item.iconr.bind(on_release=callback_factory(item))
|
item.iconr.bind(on_release=callback_factory(item))
|
||||||
|
|
||||||
item.add_widget(item.iconr)
|
item.add_widget(item.iconr)
|
||||||
|
|
||||||
self.added_item_dests.append(context_dest)
|
self.added_item_dests.append(context_dest)
|
||||||
|
Loading…
Reference in New Issue
Block a user