@@ -2,10 +2,11 @@ import naturalSort from "typescript-natural-sort"
2
2
import { cookieStorage , createStorageSignal } from "@solid-primitives/storage"
3
3
import { createMemo , createSignal } from "solid-js"
4
4
import { createStore , produce } from "solid-js/store"
5
- import { Obj , StoreObj } from "~/types"
5
+ import { Obj , ObjType , StoreObj } from "~/types"
6
6
import { bus , log } from "~/utils"
7
7
import { keyPressed } from "./key-event"
8
8
import { local } from "./local_settings"
9
+ import { useT } from "~/hooks"
9
10
10
11
export enum State {
11
12
Initial , // Initial state
@@ -222,3 +223,30 @@ export const setPassword = (password: string) => {
222
223
_setPassword ( password )
223
224
cookieStorage . setItem ( "browser-password" , password )
224
225
}
226
+
227
+ export const countMsg = ( filterType ?: ObjType ) => {
228
+ const t = useT ( )
229
+ const selectedList = selectedObjs ( )
230
+ const isSelected = selectedList . length > 0
231
+ let objs = isSelected ? selectedList : objStore . objs
232
+
233
+ if ( filterType ) {
234
+ objs = objs . filter ( ( obj ) => obj . is_dir || obj . type === filterType )
235
+ }
236
+
237
+ const folders = objs . filter ( ( o ) => o . is_dir ) . length
238
+ const files = objs . length - folders
239
+
240
+ const vars = { folders : `${ folders } ` , files : `${ files } ` }
241
+ const prefix = isSelected ? "selected" : "count"
242
+
243
+ const key =
244
+ folders && files
245
+ ? `${ prefix } `
246
+ : folders
247
+ ? `${ prefix } _folders`
248
+ : files
249
+ ? `${ prefix } _files`
250
+ : ""
251
+ return key ? t ( `home.obj.count.${ key } ` , vars ) : ""
252
+ }
0 commit comments