@samitouri / QOSami-HFS / commits / 801770cc

better code: removed legacy stuff

Massimo Melina committed May 20, 2023 at 19:15 UTC 801770cc0b0e1caa88296656ffaa40a9b65cf1c0
2 files changed +7 -8
frontend/src/icons.ts
+5 -6
@@ -32,25 +32,24 @@ const SYS_ICONS: Record<string, string[]> = {
32 }
33
34 document.fonts.ready.then(async ()=> {
35 - const fontTester = '9px "fontello"'
35 + const fontTester = '9px fontello'
36 await document.fonts.load(fontTester) // force font to be loaded even if we didn't display anything with it yet
37 - if (document.fonts.check(fontTester))
38 - state.iconsClass = ' ' // with fontello we don't need an additional class (unlike google material icons), but the empty space will cause reload
37 + state.iconsReady = document.fonts.check(fontTester)
38 })
39
40 interface IconProps { name:string, className?:string, alt?:string, [rest:string]: any }
41 export const Icon = memo(({ name, alt, className='', ...props }: IconProps) => {
42 const [emoji,clazz] = SYS_ICONS[name] || name.split(':')
44 - const { iconsClass } = useSnapState()
43 + const { iconsReady } = useSnapState()
44 className += ' icon'
45 const nameIsEmoji = name.length <= 2
46 const nameIsFile = name.includes('.')
48 - className += nameIsEmoji ? ' emoji-icon' : nameIsFile ? ' file-icon' : iconsClass ? ' fa-'+(clazz||name) : ' emoji-icon'
47 + className += nameIsEmoji ? ' emoji-icon' : nameIsFile ? ' file-icon' : iconsReady ? ' fa-'+(clazz||name) : ' emoji-icon'
48 return h('span',{
49 'aria-label': alt,
50 role: 'img',
51 ...props,
52 ...nameIsFile ? { style: { backgroundImage: `url(${JSON.stringify(name)})`, ...props?.style } } : undefined,
53 className,
55 - }, nameIsEmoji ? name : iconsClass ? null : (emoji||'#'))
54 + }, nameIsEmoji ? name : iconsReady ? null : (emoji||'#'))
55 })
frontend/src/state.ts
+2 -2
@@ -8,7 +8,7 @@ import { DirList } from './BrowseFiles'
8 export const state = proxy<{
9 stopSearch?: ()=>void,
10 stoppedSearch?: boolean,
11 - iconsClass: string,
11 + iconsReady: boolean,
12 username: string,
13 list: DirList,
14 filteredList?: DirList,
@@ -31,7 +31,7 @@ export const state = proxy<{
31 can_delete?: boolean
32 accept?: string
33 }>({
34 - iconsClass: '',
34 + iconsReady: false,
35 username: '',
36 list: [],
37 loading: false,