@@ -6,6 +6,7 @@ import { LocalStorageService, LocStorageKeys } from './local-storage.service';
66import { IsLoadingService } from '@service-work/is-loading' ;
77import { MyCrypto } from './mycrypto' ;
88import { Clipboard } from '@angular/cdk/clipboard' ;
9+ import * as path from 'path' ;
910
1011import { PasswordDialogComponent } from '../shared/components/password-dialog/password-dialog.component' ;
1112import { FileUpdateService } from './file-update.service' ;
@@ -1007,12 +1008,12 @@ export class DataService {
10071008 return this . Repos . find ( x => x . id == file . repoId ) ;
10081009 }
10091010
1010- public GetFileName ( path : string ) {
1011- return path . substring ( path . lastIndexOf ( '/' ) + 1 ) ;
1011+ public GetFileName ( p : string ) {
1012+ return p . substring ( p . lastIndexOf ( path . sep ) + 1 ) ;
10121013 }
10131014
1014- public GetFilePath ( path : string ) {
1015- return path . substring ( 0 , path . lastIndexOf ( '/' ) ) ;
1015+ public GetFilePath ( p : string ) {
1016+ return p . substring ( 0 , p . lastIndexOf ( path . sep ) ) ;
10161017 }
10171018
10181019 public Debug ( ) {
@@ -1151,8 +1152,8 @@ export class DataService {
11511152 const history = this . getLastFileHistory ( ) ;
11521153 this . availableFiles = this . availableFiles . sort ( ( a , b ) => {
11531154 // put not writable repos to end
1154- if ( a . source == FileSources . GitHub && ! this . GetRepoOfFile ( a ) . isWritable ) return 1 ;
1155- if ( b . source == FileSources . GitHub && ! this . GetRepoOfFile ( b ) . isWritable ) return - 1 ;
1155+ if ( a . source == FileSources . GitHub && ! this . GetRepoOfFile ( a ) ? .isWritable ) return 1 ;
1156+ if ( b . source == FileSources . GitHub && ! this . GetRepoOfFile ( b ) ? .isWritable ) return - 1 ;
11561157
11571158 // sort according to history
11581159 let aIdx = history . findIndex ( x => this . compareFiles ( x , a ) ) ;
0 commit comments