@@ -20,6 +20,7 @@ import { loadable } from "jotai/utils";
2020import type * as MonacoTypes from "monaco-editor" ;
2121import { createRef } from "react" ;
2222import { PreviewView } from "./preview" ;
23+ import { makeDirectoryDefaultMenuItems } from "./preview-directory-utils" ;
2324
2425// TODO drive this using config
2526const BOOKMARKS : { label : string ; path : string } [ ] = [
@@ -795,60 +796,9 @@ export class PreviewModel implements ViewModel {
795796 } ) ;
796797 }
797798 if ( loadableSV . state == "hasData" && loadableSV . data . specializedView == "directory" ) {
798- const defaultSort = globalStore . get ( getSettingsKeyAtom ( "preview:defaultsort" ) ) ?? "name" ;
799- const showHiddenFiles = globalStore . get ( this . showHiddenFiles ) ?? true ;
800799 menuItems . push ( { type : "separator" } ) ;
801- menuItems . push ( { label : "Directory Defaults" , enabled : false } ) ;
802- menuItems . push ( {
803- label : "Sort Order" ,
804- submenu : [
805- {
806- label : "Name" ,
807- type : "checkbox" ,
808- checked : defaultSort === "name" ,
809- click : ( ) =>
810- fireAndForget ( ( ) =>
811- RpcApi . SetConfigCommand ( TabRpcClient , { "preview:defaultsort" : "name" } )
812- ) ,
813- } ,
814- {
815- label : "Last Modified" ,
816- type : "checkbox" ,
817- checked : defaultSort === "modtime" ,
818- click : ( ) =>
819- fireAndForget ( ( ) =>
820- RpcApi . SetConfigCommand ( TabRpcClient , { "preview:defaultsort" : "modtime" } )
821- ) ,
822- } ,
823- ] ,
824- } ) ;
825- menuItems . push ( {
826- label : "Show Hidden Files" ,
827- submenu : [
828- {
829- label : "On" ,
830- type : "checkbox" ,
831- checked : showHiddenFiles ,
832- click : ( ) => {
833- globalStore . set ( this . showHiddenFiles , true ) ;
834- fireAndForget ( ( ) =>
835- RpcApi . SetConfigCommand ( TabRpcClient , { "preview:showhiddenfiles" : true } )
836- ) ;
837- } ,
838- } ,
839- {
840- label : "Off" ,
841- type : "checkbox" ,
842- checked : ! showHiddenFiles ,
843- click : ( ) => {
844- globalStore . set ( this . showHiddenFiles , false ) ;
845- fireAndForget ( ( ) =>
846- RpcApi . SetConfigCommand ( TabRpcClient , { "preview:showhiddenfiles" : false } )
847- ) ;
848- } ,
849- } ,
850- ] ,
851- } ) ;
800+ menuItems . push ( { label : "Default Settings" , enabled : false } ) ;
801+ menuItems . push ( ...makeDirectoryDefaultMenuItems ( this ) ) ;
852802 }
853803 return menuItems ;
854804 }
0 commit comments