File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,6 +106,22 @@ export default () => {
106106 removePathFromFavorites ( node . path )
107107 } )
108108
109+ /**
110+ * Update favourites navigation when a folder is renamed
111+ */
112+ subscribe ( 'files:node:renamed' , ( node : Node ) => {
113+ if ( node . type !== FileType . Folder ) {
114+ return
115+ }
116+
117+ // TODO check if favourited
118+ if ( node . attributes . favorite !== 1 ) {
119+ return
120+ }
121+
122+ updateNodeFromFavorites ( node as Folder )
123+ } )
124+
109125 /**
110126 * Sort the favorites paths array and
111127 * update the order property of the existing views
@@ -157,4 +173,17 @@ export default () => {
157173 Navigation . remove ( id )
158174 updateAndSortViews ( )
159175 }
176+
177+ // Update a folder from the favorites paths array and update the views
178+ const updateNodeFromFavorites = function ( node : Folder ) {
179+ const favoriteFolder = favoriteFolders . find ( ( folder ) => folder . fileid === node . fileid )
180+
181+ // Skip if it does not exists
182+ if ( favoriteFolder === undefined ) {
183+ return
184+ }
185+
186+ removePathFromFavorites ( favoriteFolder . path )
187+ addToFavorites ( node )
188+ }
160189}
You can’t perform that action at this time.
0 commit comments