@@ -37,7 +37,6 @@ public class Layouts.Sidebar : Adw.Bin {
37
37
38
38
public Gee . HashMap < string , Layouts . ProjectRow > local_hashmap = new Gee .HashMap <string, Layouts .ProjectRow > ();
39
39
public Gee . HashMap < string , Layouts . ProjectRow > todoist_hashmap = new Gee .HashMap <string, Layouts .ProjectRow > ();
40
- public Gee . HashMap < string , Layouts . ProjectRow > google_hashmap = new Gee .HashMap <string, Layouts .ProjectRow > ();
41
40
public Gee . HashMap < string , Layouts . ProjectRow > caldav_hashmap = new Gee .HashMap <string, Layouts .ProjectRow > ();
42
41
public Gee . HashMap < string , Layouts . ProjectRow > favorites_hashmap = new Gee .HashMap <string, Layouts .ProjectRow > ();
43
42
@@ -387,15 +386,26 @@ public class Layouts.Sidebar : Adw.Bin {
387
386
Services . Database . get_default (). project_updated. connect (update_projects_sort);
388
387
389
388
Services . EventBus . get_default (). project_parent_changed. connect ((project, old_parent_id) = > {
389
+ print (" project: %s\n " . printf (project. name));
390
+ print (" project parent id: %s\n " . printf (project. parent. name));
391
+ print (" old_parent_id: %s\n " . printf (old_parent_id));
392
+
390
393
if (old_parent_id == " " ) {
391
- if (local_hashmap. has_key (project. id_string)) {
392
- local_hashmap [project. id_string]. hide_destroy ();
393
- local_hashmap. unset (project. id_string);
394
+ if (local_hashmap. has_key (project. id)) {
395
+ local_hashmap [project. id]. hide_destroy ();
396
+ local_hashmap. unset (project. id);
397
+
398
+ print (" Elimina sub project\n " );
394
399
}
395
400
396
- if (todoist_hashmap. has_key (project. id_string)) {
397
- todoist_hashmap [project. id_string]. hide_destroy ();
398
- todoist_hashmap. unset (project. id_string);
401
+ if (todoist_hashmap. has_key (project. id)) {
402
+ todoist_hashmap [project. id]. hide_destroy ();
403
+ todoist_hashmap. unset (project. id);
404
+ }
405
+
406
+ if (caldav_hashmap. has_key (project. id)) {
407
+ caldav_hashmap [project. id]. hide_destroy ();
408
+ caldav_hashmap. unset (project. id);
399
409
}
400
410
}
401
411
@@ -404,10 +414,44 @@ public class Layouts.Sidebar : Adw.Bin {
404
414
}
405
415
});
406
416
417
+ Services . EventBus . get_default (). update_inserted_project_map. connect ((_row, old_parent_id) = > {
418
+ var row = (Layouts . ProjectRow ) _row;
419
+
420
+ if (old_parent_id == " " ) {
421
+ if (local_hashmap. has_key (row. project. id)) {
422
+ local_hashmap. unset (row. project. id);
423
+ }
424
+
425
+ if (todoist_hashmap. has_key (row. project. id)) {
426
+ todoist_hashmap. unset (row. project. id);
427
+ }
428
+
429
+ if (caldav_hashmap. has_key (row. project. id)) {
430
+ caldav_hashmap. unset (row. project. id);
431
+ }
432
+ }
433
+
434
+ if (! row. project. is_inbox_project && row. project. parent_id == " " ) {
435
+ if (row. project. backend_type == BackendType . TODOIST ) {
436
+ if (! todoist_hashmap. has_key (row. project. id)) {
437
+ todoist_hashmap[row. project. id] = row;
438
+ }
439
+ } else if (row. project. backend_type == BackendType . LOCAL ) {
440
+ if (! local_hashmap. has_key (row. project. id)) {
441
+ local_hashmap[row. project. id] = row;
442
+ }
443
+ } else if (row. project. backend_type == BackendType . CALDAV ) {
444
+ if (! caldav_hashmap. has_key (row. project. id)) {
445
+ caldav_hashmap[row. project. id] = row;
446
+ }
447
+ }
448
+ }
449
+ });
450
+
407
451
Services . EventBus . get_default (). favorite_toggled. connect ((project) = > {
408
- if (favorites_hashmap. has_key (project. id_string )) {
409
- favorites_hashmap [project. id_string ]. hide_destroy ();
410
- favorites_hashmap. unset (project. id_string );
452
+ if (favorites_hashmap. has_key (project. id )) {
453
+ favorites_hashmap [project. id ]. hide_destroy ();
454
+ favorites_hashmap. unset (project. id );
411
455
} else {
412
456
add_row_favorite (project);
413
457
}
@@ -462,11 +506,6 @@ public class Layouts.Sidebar : Adw.Bin {
462
506
todoist_hashmap [project. id_string] = new Layouts .ProjectRow (project);
463
507
todoist_projects_header. add_child (todoist_hashmap [project. id_string]);
464
508
}
465
- } else if (project. backend_type == BackendType . GOOGLE_TASKS ) {
466
- if (! google_hashmap. has_key (project. id_string)) {
467
- google_hashmap [project. id_string] = new Layouts .ProjectRow (project);
468
- google_projects_header. add_child (google_hashmap [project. id_string]);
469
- }
470
509
} else if (project. backend_type == BackendType . LOCAL ) {
471
510
if (! local_hashmap. has_key (project. id_string)) {
472
511
local_hashmap [project. id_string] = new Layouts .ProjectRow (project);
0 commit comments