Save changes on server
This commit is contained in:
parent
95091ae54e
commit
5bc0a2f480
2 changed files with 38 additions and 4 deletions
|
@ -108,9 +108,10 @@ class JnotesApplication(Adw.Application):
|
|||
)
|
||||
|
||||
def on_note_selected(self, container, row):
|
||||
calendar = self.props.active_window.notes_list.calendar
|
||||
note = calendar[row.get_index()]
|
||||
self.props.active_window.note_edit.set_note(note)
|
||||
if row:
|
||||
calendar = self.props.active_window.notes_list.calendar
|
||||
note = calendar[row.get_index()]
|
||||
self.props.active_window.note_edit.set_note(note)
|
||||
|
||||
def main(version):
|
||||
"""The application's entry point."""
|
||||
|
|
35
src/sync.py
35
src/sync.py
|
@ -99,10 +99,28 @@ class Sync():
|
|||
for journal in remote_calendar.journals():
|
||||
summary = journal.icalendar_component.get("summary", "")
|
||||
description = journal.icalendar_component.get("description", "")
|
||||
calendar.add_note(Note(calendar, summary, description))
|
||||
note = Note(calendar, summary, description)
|
||||
note.journal = journal
|
||||
note.uid = journal.icalendar_component.get("uid", "")
|
||||
print(journal.data)
|
||||
calendar.add_note(note)
|
||||
self.spinner.stop()
|
||||
callback(calendar)
|
||||
|
||||
@classmethod
|
||||
@threaded
|
||||
def save_calendar_note(self, note, callback):
|
||||
self.spinner.start()
|
||||
remote_calendar = self.principal.calendar(note.calendar.displayname)
|
||||
journal = note.journal.icalendar_component
|
||||
journal["summary"] = note.summary
|
||||
journal["description"] = note.description
|
||||
note.journal.save()
|
||||
uid = ""
|
||||
self.spinner.stop()
|
||||
callback(uid)
|
||||
|
||||
|
||||
class CalendarSet(Gio.ListStore):
|
||||
|
||||
def __init__(self):
|
||||
|
@ -133,17 +151,32 @@ class Calendar(Gio.ListStore):
|
|||
def on_notify_note_changed(self, note, gparamstring):
|
||||
(found, position) = self.find(note)
|
||||
if found:
|
||||
note.dirty = True
|
||||
self.items_changed(position, 1, 1)
|
||||
note.sync()
|
||||
|
||||
class Note(GObject.GObject):
|
||||
__gtype_name__ = "Note"
|
||||
uid = None
|
||||
calendar = None
|
||||
journal = None
|
||||
summary = GObject.property(type=str)
|
||||
description = GObject.property(type=str)
|
||||
dirty = GObject.Property(type=bool, default=False)
|
||||
|
||||
def __init__(self, calendar, summary, description):
|
||||
super().__init__()
|
||||
self.calendar = calendar
|
||||
self.summary = summary
|
||||
self.description = description
|
||||
|
||||
def sync(self):
|
||||
if self.dirty:
|
||||
def callback(uid):
|
||||
self.dirty = False
|
||||
if uid:
|
||||
self.uid = uid
|
||||
Sync.save_calendar_note(self, callback)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue