From 8ea1ae6969ac418250deff845851ec7f6c9e8e3b Mon Sep 17 00:00:00 2001 From: marxzuckerburg Date: Thu, 1 Oct 2020 16:37:57 +0100 Subject: [PATCH] filechooser issues? --- comrad/app/main.py | 2 +- comrad/app/screens/profile/profile.py | 26 ++++++++++++++++---------- comrad/backend/comrades.py | 6 +++++- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/comrad/app/main.py b/comrad/app/main.py index 2f1656d..769b5f3 100644 --- a/comrad/app/main.py +++ b/comrad/app/main.py @@ -833,7 +833,7 @@ if __name__ == '__main__': loop = asyncio.get_event_loop() try: loop.run_until_complete(MainApp().app_func()) - except TypeError: + except AssertionError: print('\n\nGoodbye.\n') pass loop.close() diff --git a/comrad/app/screens/profile/profile.py b/comrad/app/screens/profile/profile.py index d723d94..dde7e26 100644 --- a/comrad/app/screens/profile/profile.py +++ b/comrad/app/screens/profile/profile.py @@ -21,21 +21,27 @@ from copy import copy,deepcopy from kivy.animation import Animation from main import MyLabel,COLOR_ICON from misc import * +from plyer import filechooser class ProfileAvatar(Image): def on_touch_down(self, touch): - if self.screen.carousel.index and self.collide_point(*touch.pos) and self.screen.carousel.slides: - start = self.screen.carousel.slides[0] - start.opacity=0 - self.screen.carousel.index=0 - anim = Animation(opacity=1, duration=0.1) - anim.start(start) - # start = self.screen.carousel.slides[0] - # log('????',start) - # self.screen.carousel.load_slide(start) - # self.screen.carousel.load_next() + if self.collide_point(*touch.pos): + if self.screen.carousel.index and self.screen.carousel.slides: + start = self.screen.carousel.slides[0] + start.opacity=0 + self.screen.carousel.index=0 + anim = Animation(opacity=1, duration=0.1) + anim.start(start) + else: + filechooser.open_file( + on_selection=self.handle_selection, + desktop_override='gnome' + ) + def handle_selection(self, selection): + self.selection = selection + raise Exception(selection) class LayoutAvatar(MDBoxLayout): pass diff --git a/comrad/backend/comrades.py b/comrad/backend/comrades.py index 8528e86..a21525f 100644 --- a/comrad/backend/comrades.py +++ b/comrad/backend/comrades.py @@ -742,7 +742,7 @@ class ComradX(Caller): inbox = [x for x in inbox if not x in set(read)] posts=[] - for post_id in reversed(inbox): + for post_id in inbox: self.log('???',post_id,inbox_prefix) try: res_post = self.read_post(post_id) @@ -755,6 +755,10 @@ class ComradX(Caller): post.post_id=post_id post.inbox_prefix=inbox_prefix posts.append(post) + + # sort by timestamp! + posts.sort(key=lambda post: -post.timestamp) + return posts def read_post(self,post_id,post_encr=None,post_prefix='/post/'):