@@ -29,55 +29,11 @@ struct DefaultBookmarksSaver: BookmarksSaver, BookmarksRefactorFeatureFlagProvid
29
29
let operation : Deferred < Maybe < GUID ? > > ? = {
30
30
switch bookmark. type {
31
31
case . bookmark:
32
- guard let bookmark = bookmark as? BookmarkItemData else { return deferMaybe ( nil ) }
33
-
34
- if bookmark. parentGUID == nil {
35
- let position : UInt32 ? = parentFolderGUID == BookmarkRoots . MobileFolderGUID ? 0 : nil
36
- return profile. places. createBookmark ( parentGUID: parentFolderGUID,
37
- url: bookmark. url,
38
- title: bookmark. title,
39
- position: position) . bind { result in
40
- return result. isFailure ? deferMaybe ( BookmarkDetailPanelError ( ) )
41
- : deferMaybe ( result. successValue)
42
- }
43
- } else {
44
- let position : UInt32 ? = parentFolderGUID == bookmark. parentGUID ? bookmark. position : nil
45
- return profile. places. updateBookmarkNode ( guid: bookmark. guid,
46
- parentGUID: parentFolderGUID,
47
- position: position,
48
- title: bookmark. title,
49
- url: bookmark. url) . bind { result in
50
- return result. isFailure ? deferMaybe ( BookmarkDetailPanelError ( ) ) : deferMaybe ( nil )
51
- }
52
- }
53
-
32
+ return saveBookmark ( bookmark: bookmark, parentFolderGUID: parentFolderGUID)
54
33
case . folder:
55
- guard let folder = bookmark as? BookmarkFolderData else { return deferMaybe ( nil ) }
56
-
57
- if folder. parentGUID == nil {
58
- TelemetryWrapper . recordEvent ( category: . action,
59
- method: . tap,
60
- object: . bookmark,
61
- value: . bookmarkAddFolder)
62
-
63
- let position : UInt32 ? = parentFolderGUID == BookmarkRoots . MobileFolderGUID ? 0 : nil
64
- return profile. places. createFolder ( parentGUID: parentFolderGUID,
65
- title: folder. title,
66
- position: position) . bind { result in
67
- return result. isFailure ? deferMaybe ( BookmarkDetailPanelError ( ) )
68
- : deferMaybe ( result. successValue)
69
- }
70
- } else {
71
- let position : UInt32 ? = parentFolderGUID == folder. parentGUID ? folder. position : nil
72
- return profile. places. updateBookmarkNode ( guid: folder. guid,
73
- parentGUID: parentFolderGUID,
74
- position: position,
75
- title: folder. title) . bind { result in
76
- return result. isFailure ? deferMaybe ( BookmarkDetailPanelError ( ) ) : deferMaybe ( nil )
77
- }
78
- }
79
-
80
- default : return nil
34
+ return saveFolder ( bookmark: bookmark, parentFolderGUID: parentFolderGUID)
35
+ default :
36
+ return nil
81
37
}
82
38
} ( )
83
39
0 commit comments