Skip to content

Commit 1f5a26c

Browse files
committed
Remove autosave timeout and simplify window closing
The changes remove a 500ms autosave delay mechanism and simplify how the window closes by using the base implementation.
1 parent c4d4931 commit 1f5a26c

File tree

4 files changed

+7
-26
lines changed

4 files changed

+7
-26
lines changed

src/MainWindow.vala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ namespace Notejot {
183183

184184
tview_model.repository.save.begin ();
185185

186-
this.dispose ();
187-
return true;
186+
return base.close_request ();
188187
}
189188

190189
// IO?

src/ViewModels/NoteViewModel.vala

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,7 @@ public class Notejot.NoteViewModel : Object {
104104
}
105105

106106
void save_notes () {
107-
if (timeout_id != 0) {
108-
Source.remove (timeout_id);
109-
}
110-
timeout_id = Timeout.add (500, () => {
111-
timeout_id = 0;
112-
repository.save.begin ();
113-
return Source.REMOVE;
114-
});
107+
timeout_id = 0;
108+
repository.save.begin ();
115109
}
116110
}

src/ViewModels/NotebookViewModel.vala

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,7 @@ public class Notejot.NotebookViewModel : Object {
5454
}
5555

5656
void save_notebooks () {
57-
if (timeout_id != 0)
58-
Source.remove (timeout_id);
59-
60-
timeout_id = Timeout.add (500, () => {
61-
timeout_id = 0;
62-
repository.save.begin ();
63-
return Source.REMOVE;
64-
});
57+
timeout_id = 0;
58+
repository.save.begin ();
6559
}
6660
}

src/ViewModels/TrashViewModel.vala

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,7 @@ public class Notejot.TrashViewModel : Object {
107107
}
108108

109109
void save_trashs () {
110-
if (timeout_id != 0)
111-
Source.remove (timeout_id);
112-
113-
timeout_id = Timeout.add (500, () => {
114-
timeout_id = 0;
115-
repository.save.begin ();
116-
return Source.REMOVE;
117-
});
110+
timeout_id = 0;
111+
repository.save.begin ();
118112
}
119113
}

0 commit comments

Comments
 (0)