* Update matching expanded folder views with a new entry. * @param {string} parentUrl * @param {string} entryUrl * @param {"file"|"folder"} type
(parentUrl, entryUrl, type)
| 1137 | * @param {"file"|"folder"} type |
| 1138 | */ |
| 1139 | function appendEntryToOpenFolder(parentUrl, entryUrl, type) { |
| 1140 | const filesApp = sidebarApps.get("files"); |
| 1141 | const $els = filesApp.getAll(`[data-url="${parentUrl}"]`); |
| 1142 | const isDirectory = type === "folder"; |
| 1143 | const name = Url.basename(entryUrl); |
| 1144 | |
| 1145 | Array.from($els).forEach(($el) => { |
| 1146 | if (!(helpers.isDir($el.dataset.type) || $el.dataset.type === "root")) { |
| 1147 | return; |
| 1148 | } |
| 1149 | |
| 1150 | if (!$el.unclasped) return; |
| 1151 | |
| 1152 | const fileTree = getLoadedFileTree($el); |
| 1153 | if (fileTree) { |
| 1154 | fileTree.appendEntry(name, entryUrl, isDirectory); |
| 1155 | return; |
| 1156 | } |
| 1157 | |
| 1158 | if (isDirectory) { |
| 1159 | appendList($el, createFolderTile(name, entryUrl)); |
| 1160 | } else { |
| 1161 | appendTile($el, createFileTile(name, entryUrl)); |
| 1162 | } |
| 1163 | }); |
| 1164 | } |
| 1165 | |
| 1166 | /** |
| 1167 | * Refresh matching expanded folder views. |
no test coverage detected