@@ -6,6 +6,7 @@ import { createElement, FolderSync, RefreshCcw, FileText, FolderSymlink, CopySla
6
6
import InvioPlugin from '../main' ;
7
7
import style from './style' ;
8
8
import svg from './svg' ;
9
+ import { LocalConflictPrefix , RemoteConflictPrefix } from '../sync'
9
10
10
11
export interface Icon {
11
12
name : string ;
@@ -150,7 +151,8 @@ const createIconNode = (plugin: InvioPlugin, path: string, svgStr: string, color
150
151
// path from the document itself.
151
152
const paths = path . split ( '/' ) ;
152
153
let parentNode : any = null ;
153
- paths ?. reduce ( ( left , cur ) => {
154
+ paths ?. reduce ( async ( leftPromise , cur ) => {
155
+ const left = await leftPromise ;
154
156
let target = '' ;
155
157
if ( ! left ) {
156
158
target = cur ;
@@ -159,28 +161,26 @@ const createIconNode = (plugin: InvioPlugin, path: string, svgStr: string, color
159
161
}
160
162
// checking target path
161
163
let node : any = document . querySelector ( `[data-path="${ target } "]` ) ;
162
- console . log ( 'check node...' , target , node )
163
164
if ( node ) {
164
165
parentNode = node ;
165
166
} else {
166
167
if ( parentNode ) {
167
168
parentNode . click ( ) ;
168
- console . log ( 'clicking node: ' , target , parentNode ) ;
169
+ await sleep ( 300 ) ;
169
170
node = document . querySelector ( `[data-path="${ target } "]` ) ;
170
- console . log ( 'to find child node: ' , node ) ;
171
171
if ( node ) {
172
172
parentNode = node ;
173
173
}
174
174
} else {
175
175
if ( ! repeated ) {
176
176
setTimeout ( ( ) => {
177
177
createIconNode ( plugin , path , svgStr , color , true ) ;
178
- } , 3000 )
178
+ } , 3000 ) ;
179
179
}
180
180
}
181
181
}
182
182
return target ;
183
- } , '' )
183
+ } , Promise . resolve ( '' ) )
184
184
const node = document . querySelector ( `[data-path="${ path } "]` ) ;
185
185
186
186
if ( ! node ) {
@@ -218,6 +218,18 @@ export const addIconForconflictFile = (plugin: InvioPlugin, fileOrFolder: TAbstr
218
218
if ( ( fileOrFolder instanceof TFile ) && fileOrFolder . name . endsWith ( '.conflict.md' ) ) {
219
219
// Add alert icon for conflict file
220
220
const { iconSvgCopySlash } = getIconSvg ( ) ;
221
+ const fileP = fileOrFolder . path ;
222
+
223
+ const idx1 = fileP . indexOf ( LocalConflictPrefix ) ;
224
+ if ( idx1 > 0 ) {
225
+ const folderP = fileP . slice ( 0 , idx1 ) + LocalConflictPrefix
226
+ createIconNode ( plugin , folderP , iconSvgCopySlash , '#dd1b9a' ) ;
227
+ }
228
+ const idx2 = fileP . indexOf ( RemoteConflictPrefix ) ;
229
+ if ( idx2 > 0 ) {
230
+ const folderP = fileP . slice ( 0 , idx2 ) + RemoteConflictPrefix
231
+ createIconNode ( plugin , folderP , iconSvgCopySlash , '#dd1b9a' ) ;
232
+ }
221
233
createIconNode ( plugin , fileOrFolder . path , iconSvgCopySlash , '#dd1b9a' ) ;
222
234
}
223
235
}
0 commit comments