TagSpaces is an offline, open source, document manager with tagging support
Performance UI optimizations (#2385)
Ilian54e060805b74
diff --git a/package-lock.json b/package-lock.jsonindex 37dfb172f..069eadb48 100644--- a/package-lock.json+++ b/package-lock.json@@ -15,11 +15,11 @@"@milkdown/crepe": "^7.15.1","@milkdown/kit": "^7.15.1","@milkdown/react": "^7.15.1",- "@mui/icons-material": "^7.1.2",- "@mui/lab": "7.0.0-beta.14",- "@mui/material": "^7.1.2",- "@mui/x-data-grid": "^8.9.1",- "@mui/x-date-pickers": "^8.6.0",+ "@mui/icons-material": "7.3.4",+ "@mui/lab": "7.0.1-beta.18",+ "@mui/material": "7.3.4",+ "@mui/x-data-grid": "8.15.0",+ "@mui/x-date-pickers": "8.15.0","@tagspaces/tagspaces-common": "4.5.102","@tagspaces/tagspaces-common-aws3": "4.5.102","@tagspaces/tagspaces-common-cordova": "4.5.102",@@ -28,7 +28,7 @@"coordinate-parser": "1.0.7","crypto-js": "4.2.0","date-fns": "4.1.0",- "dompurify": "3.2.5",+ "dompurify": "3.3.0","echarts": "^6.0.0","electron-debug": "^3.2.0","electron-log": "^4.4.8",@@ -117,7 +117,7 @@"css-minimizer-webpack-plugin": "^5.0.1","detect-port": "^1.5.1","dotenv-webpack": "^8.0.1",- "electron": "^37.2.6",+ "electron": "37.7.1","electron-builder": "^26.0.12","electron-devtools-installer": "^4.0.0","electronmon": "^2.0.3",@@ -185,7 +185,7 @@"yarn": "please-use-npm"},"optionalDependencies": {- "@tagspacespro/tagspacespro": "5.0.190"+ "@tagspacespro/tagspacespro": "5.0.193"}},"node_modules/@ampproject/remapping": {@@ -12924,9 +12924,9 @@}},"node_modules/@babel/runtime": {- "version": "7.27.6",- "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.27.6.tgz",- "integrity": "sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q==",+ "version": "7.28.4",+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.4.tgz",+ "integrity": "sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ==","license": "MIT","engines": {"node": ">=6.9.0"@@ -15858,9 +15858,9 @@}},"node_modules/@mui/core-downloads-tracker": {- "version": "7.1.2",- "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-7.1.2.tgz",- "integrity": "sha512-0gLO1PvbJwSYe5ji021tGj6HFqrtEPMGKK4L1zWwRbhzrWWUumUJvMvJUsIgWQIYQsgOnhq9k2Fc1BxLGHDsAg==",+ "version": "7.3.4",+ "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-7.3.4.tgz",+ "integrity": "sha512-BIktMapG3r4iXwIhYNpvk97ZfYWTreBBQTWjQKbNbzI64+ULHfYavQEX2w99aSWHS58DvXESWIgbD9adKcUOBw==","license": "MIT","funding": {"type": "opencollective",@@ -15868,12 +15868,12 @@}},"node_modules/@mui/icons-material": {- "version": "7.1.2",- "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-7.1.2.tgz",- "integrity": "sha512-slqJByDub7Y1UcokrM17BoMBMvn8n7daXFXVoTv0MEH5k3sHjmsH8ql/Mt3s9vQ20cORDr83UZ448TEGcbrXtw==",+ "version": "7.3.4",+ "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-7.3.4.tgz",+ "integrity": "sha512-9n6Xcq7molXWYb680N2Qx+FRW8oT6j/LXF5PZFH3ph9X/Rct0B/BlLAsFI7iL9ySI6LVLuQIVtrLiPT82R7OZw==","license": "MIT","dependencies": {- "@babel/runtime": "^7.27.1"+ "@babel/runtime": "^7.28.4"},"engines": {"node": ">=14.0.0"@@ -15883,7 +15883,7 @@"url": "https://opencollective.com/mui-org"},"peerDependencies": {- "@mui/material": "^7.1.2",+ "@mui/material": "^7.3.4","@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0","react": "^17.0.0 || ^18.0.0 || ^19.0.0"},@@ -15894,15 +15894,15 @@}},"node_modules/@mui/lab": {- "version": "7.0.0-beta.14",- "resolved": "https://registry.npmjs.org/@mui/lab/-/lab-7.0.0-beta.14.tgz",- "integrity": "sha512-pn+ZvylDcBKQOo17oa/PhtIA/UFQFq8RvpN+r/jHrztz/CjMDju2CWBne0txvQ5JIS8uTIGp2/IsTa7II1g5wg==",+ "version": "7.0.1-beta.18",+ "resolved": "https://registry.npmjs.org/@mui/lab/-/lab-7.0.1-beta.18.tgz",+ "integrity": "sha512-LC+Eki92aW9/8uUS2RNqo3yytdMlUiIzV3tKvaZVabzecHncyiItAk12SNSqV+U4Pu+TUKqEM9Y5lShAUtuLPQ==","license": "MIT","dependencies": {- "@babel/runtime": "^7.27.1",- "@mui/system": "^7.1.1",- "@mui/types": "^7.4.3",- "@mui/utils": "^7.1.1",+ "@babel/runtime": "^7.28.4",+ "@mui/system": "^7.3.3",+ "@mui/types": "^7.4.7",+ "@mui/utils": "^7.3.3","clsx": "^2.1.1","prop-types": "^15.8.1"},@@ -15916,8 +15916,8 @@"peerDependencies": {"@emotion/react": "^11.5.0","@emotion/styled": "^11.3.0",- "@mui/material": "^7.1.2",- "@mui/material-pigment-css": "^7.1.1",+ "@mui/material": "^7.3.4",+ "@mui/material-pigment-css": "^7.3.3","@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0","react": "^17.0.0 || ^18.0.0 || ^19.0.0","react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"@@ -15938,22 +15938,22 @@}},"node_modules/@mui/material": {- "version": "7.1.2",- "resolved": "https://registry.npmjs.org/@mui/material/-/material-7.1.2.tgz",- "integrity": "sha512-Z5PYKkA6Kd8vS04zKxJNpwuvt6IoMwqpbidV7RCrRQQKwczIwcNcS8L6GnN4pzFYfEs+N9v6co27DmG07rcnoA==",+ "version": "7.3.4",+ "resolved": "https://registry.npmjs.org/@mui/material/-/material-7.3.4.tgz",+ "integrity": "sha512-gEQL9pbJZZHT7lYJBKQCS723v1MGys2IFc94COXbUIyCTWa+qC77a7hUax4Yjd5ggEm35dk4AyYABpKKWC4MLw==","license": "MIT","dependencies": {- "@babel/runtime": "^7.27.1",- "@mui/core-downloads-tracker": "^7.1.2",- "@mui/system": "^7.1.1",- "@mui/types": "^7.4.3",- "@mui/utils": "^7.1.1",+ "@babel/runtime": "^7.28.4",+ "@mui/core-downloads-tracker": "^7.3.4",+ "@mui/system": "^7.3.3",+ "@mui/types": "^7.4.7",+ "@mui/utils": "^7.3.3","@popperjs/core": "^2.11.8","@types/react-transition-group": "^4.4.12","clsx": "^2.1.1","csstype": "^3.1.3","prop-types": "^15.8.1",- "react-is": "^19.1.0",+ "react-is": "^19.1.1","react-transition-group": "^4.4.5"},"engines": {@@ -15966,7 +15966,7 @@"peerDependencies": {"@emotion/react": "^11.5.0","@emotion/styled": "^11.3.0",- "@mui/material-pigment-css": "^7.1.1",+ "@mui/material-pigment-css": "^7.3.3","@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0","react": "^17.0.0 || ^18.0.0 || ^19.0.0","react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"@@ -15987,13 +15987,13 @@}},"node_modules/@mui/private-theming": {- "version": "7.1.1",- "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-7.1.1.tgz",- "integrity": "sha512-M8NbLUx+armk2ZuaxBkkMk11ultnWmrPlN0Xe3jUEaBChg/mcxa5HWIWS1EE4DF36WRACaAHVAvyekWlDQf0PQ==",+ "version": "7.3.3",+ "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-7.3.3.tgz",+ "integrity": "sha512-OJM+9nj5JIyPUvsZ5ZjaeC9PfktmK+W5YaVLToLR8L0lB/DGmv1gcKE43ssNLSvpoW71Hct0necfade6+kW3zQ==","license": "MIT","dependencies": {- "@babel/runtime": "^7.27.1",- "@mui/utils": "^7.1.1",+ "@babel/runtime": "^7.28.4",+ "@mui/utils": "^7.3.3","prop-types": "^15.8.1"},"engines": {@@ -16014,13 +16014,13 @@}},"node_modules/@mui/styled-engine": {- "version": "7.1.1",- "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-7.1.1.tgz",- "integrity": "sha512-R2wpzmSN127j26HrCPYVQ53vvMcT5DaKLoWkrfwUYq3cYytL6TQrCH8JBH3z79B6g4nMZZVoaXrxO757AlShaw==",+ "version": "7.3.3",+ "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-7.3.3.tgz",+ "integrity": "sha512-CmFxvRJIBCEaWdilhXMw/5wFJ1+FT9f3xt+m2pPXhHPeVIbBg9MnMvNSJjdALvnQJMPw8jLhrUtXmN7QAZV2fw==","license": "MIT","dependencies": {- "@babel/runtime": "^7.27.1",- "@emotion/cache": "^11.13.5",+ "@babel/runtime": "^7.28.4",+ "@emotion/cache": "^11.14.0","@emotion/serialize": "^1.3.3","@emotion/sheet": "^1.4.0","csstype": "^3.1.3",@@ -16048,16 +16048,16 @@}},"node_modules/@mui/system": {- "version": "7.1.1",- "resolved": "https://registry.npmjs.org/@mui/system/-/system-7.1.1.tgz",- "integrity": "sha512-Kj1uhiqnj4Zo7PDjAOghtXJtNABunWvhcRU0O7RQJ7WOxeynoH6wXPcilphV8QTFtkKaip8EiNJRiCD+B3eROA==",+ "version": "7.3.3",+ "resolved": "https://registry.npmjs.org/@mui/system/-/system-7.3.3.tgz",+ "integrity": "sha512-Lqq3emZr5IzRLKaHPuMaLBDVaGvxoh6z7HMWd1RPKawBM5uMRaQ4ImsmmgXWtwJdfZux5eugfDhXJUo2mliS8Q==","license": "MIT","dependencies": {- "@babel/runtime": "^7.27.1",- "@mui/private-theming": "^7.1.1",- "@mui/styled-engine": "^7.1.1",- "@mui/types": "^7.4.3",- "@mui/utils": "^7.1.1",+ "@babel/runtime": "^7.28.4",+ "@mui/private-theming": "^7.3.3",+ "@mui/styled-engine": "^7.3.3",+ "@mui/types": "^7.4.7",+ "@mui/utils": "^7.3.3","clsx": "^2.1.1","csstype": "^3.1.3","prop-types": "^15.8.1"@@ -16088,12 +16088,12 @@}},"node_modules/@mui/types": {- "version": "7.4.4",- "resolved": "https://registry.npmjs.org/@mui/types/-/types-7.4.4.tgz",- "integrity": "sha512-p63yhbX52MO/ajXC7hDHJA5yjzJekvWD3q4YDLl1rSg+OXLczMYPvTuSuviPRCgRX8+E42RXz1D/dz9SxPSlWg==",+ "version": "7.4.7",+ "resolved": "https://registry.npmjs.org/@mui/types/-/types-7.4.7.tgz",+ "integrity": "sha512-8vVje9rdEr1rY8oIkYgP+Su5Kwl6ik7O3jQ0wl78JGSmiZhRHV+vkjooGdKD8pbtZbutXFVTWQYshu2b3sG9zw==","license": "MIT","dependencies": {- "@babel/runtime": "^7.27.6"+ "@babel/runtime": "^7.28.4"},"peerDependencies": {"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0"@@ -16105,17 +16105,17 @@}},"node_modules/@mui/utils": {- "version": "7.2.0",- "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-7.2.0.tgz",- "integrity": "sha512-O0i1GQL6MDzhKdy9iAu5Yr0Sz1wZjROH1o3aoztuivdCXqEeQYnEjTDiRLGuFxI9zrUbTHBwobMyQH5sNtyacw==",+ "version": "7.3.3",+ "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-7.3.3.tgz",+ "integrity": "sha512-kwNAUh7bLZ7mRz9JZ+6qfRnnxbE4Zuc+RzXnhSpRSxjTlSTj7b4JxRLXpG+MVtPVtqks5k/XC8No1Vs3x4Z2gg==","license": "MIT","dependencies": {- "@babel/runtime": "^7.27.6",- "@mui/types": "^7.4.4",+ "@babel/runtime": "^7.28.4",+ "@mui/types": "^7.4.7","@types/prop-types": "^15.7.15","clsx": "^2.1.1","prop-types": "^15.8.1",- "react-is": "^19.1.0"+ "react-is": "^19.1.1"},"engines": {"node": ">=14.0.0"@@ -16135,17 +16135,18 @@}},"node_modules/@mui/x-data-grid": {- "version": "8.9.1",- "resolved": "https://registry.npmjs.org/@mui/x-data-grid/-/x-data-grid-8.9.1.tgz",- "integrity": "sha512-N1R3bcxaIpiXqZl7E9nu2b3zp1DC9w5cyaeSJiGhkPpgjKcuogJlL5tMp7UMyUE2h+c0i+1ANMUzD+chHZ6lhg==",+ "version": "8.15.0",+ "resolved": "https://registry.npmjs.org/@mui/x-data-grid/-/x-data-grid-8.15.0.tgz",+ "integrity": "sha512-JNPG2WSYJVKbUAbDpLCbWmIY25k9hyfUjAVnzDREbJMwPL+/5B9pIK0ikRQEXc0wRKY2T59SeR/Um2FZjBeeWQ==","license": "MIT","dependencies": {- "@babel/runtime": "^7.27.6",- "@mui/utils": "^7.2.0",- "@mui/x-internals": "8.8.0",+ "@babel/runtime": "^7.28.4",+ "@mui/utils": "^7.3.3",+ "@mui/x-internals": "8.14.0",+ "@mui/x-virtualizer": "0.2.5","clsx": "^2.1.1","prop-types": "^15.8.1",- "use-sync-external-store": "^1.5.0"+ "use-sync-external-store": "^1.6.0"},"engines": {"node": ">=14.0.0"@@ -16171,37 +16172,15 @@}}},- "node_modules/@mui/x-data-grid/node_modules/@mui/x-internals": {- "version": "8.8.0",- "resolved": "https://registry.npmjs.org/@mui/x-internals/-/x-internals-8.8.0.tgz",- "integrity": "sha512-qTRK5oINkAjZ7sIHpSnESLNq1xtQUmmfmGscYUSEP0uHoYh6pKkNWH9+7yzggRHuTv+4011VBwN9s+efrk+xZg==",- "license": "MIT",- "dependencies": {- "@babel/runtime": "^7.27.6",- "@mui/utils": "^7.2.0",- "reselect": "^5.1.1"- },- "engines": {- "node": ">=14.0.0"- },- "funding": {- "type": "opencollective",- "url": "https://opencollective.com/mui-org"- },- "peerDependencies": {- "@mui/system": "^5.15.14 || ^6.0.0 || ^7.0.0",- "react": "^17.0.0 || ^18.0.0 || ^19.0.0"- }- },"node_modules/@mui/x-date-pickers": {- "version": "8.6.0",- "resolved": "https://registry.npmjs.org/@mui/x-date-pickers/-/x-date-pickers-8.6.0.tgz",- "integrity": "sha512-zZsyEJrmC2zv9noQGTLpjsKmbHxiaO0exKwQgvn/CbCIl6Dqlo6E6l+R3V5uB93u5mUK3yLsVHzeLWARLZBC9A==",+ "version": "8.15.0",+ "resolved": "https://registry.npmjs.org/@mui/x-date-pickers/-/x-date-pickers-8.15.0.tgz",+ "integrity": "sha512-I5cNUwaaGJASwlhlSZHE1ddidRvDFei9Sh7ikpAgoznfyxJoLX2nxk6e2csafJ9/1cV4Js7Odo63n8zsYgFn1A==","license": "MIT","dependencies": {- "@babel/runtime": "^7.27.6",- "@mui/utils": "^7.1.1",- "@mui/x-internals": "8.6.0",+ "@babel/runtime": "^7.28.4",+ "@mui/utils": "^7.3.3",+ "@mui/x-internals": "8.14.0","@types/react-transition-group": "^4.4.12","clsx": "^2.1.1","prop-types": "^15.8.1",@@ -16260,14 +16239,15 @@}},"node_modules/@mui/x-internals": {- "version": "8.6.0",- "resolved": "https://registry.npmjs.org/@mui/x-internals/-/x-internals-8.6.0.tgz",- "integrity": "sha512-ed6IOmnUpm18b607JRTJS+xya731CrQtJKX35l/4TlH8Df1SpkSJsmoyBBmZ09DNX8YNEFpYt5EyfXI28iyM2A==",+ "version": "8.14.0",+ "resolved": "https://registry.npmjs.org/@mui/x-internals/-/x-internals-8.14.0.tgz",+ "integrity": "sha512-esYyl61nuuFXiN631TWuPh2tqdoyTdBI/4UXgwH3rytF8jiWvy6prPBPRHEH1nvW3fgw9FoBI48FlOO+yEI8xg==","license": "MIT","dependencies": {- "@babel/runtime": "^7.27.6",- "@mui/utils": "^7.1.1",- "reselect": "^5.1.1"+ "@babel/runtime": "^7.28.4",+ "@mui/utils": "^7.3.3",+ "reselect": "^5.1.1",+ "use-sync-external-store": "^1.6.0"},"engines": {"node": ">=14.0.0"@@ -16277,10 +16257,31 @@"url": "https://opencollective.com/mui-org"},"peerDependencies": {- "@mui/system": "^5.15.14 || ^6.0.0 || ^7.0.0","react": "^17.0.0 || ^18.0.0 || ^19.0.0"}},+ "node_modules/@mui/x-virtualizer": {+ "version": "0.2.5",+ "resolved": "https://registry.npmjs.org/@mui/x-virtualizer/-/x-virtualizer-0.2.5.tgz",+ "integrity": "sha512-kCo/i9YfNavbupqZGO1649CHwIABrwUDHVZh+GvGierHhIglUc9MHxYKsPhuojOg6izWa2HP+klt3nq2n/arOw==",+ "license": "MIT",+ "dependencies": {+ "@babel/runtime": "^7.28.4",+ "@mui/utils": "^7.3.3",+ "@mui/x-internals": "8.14.0"+ },+ "engines": {+ "node": ">=14.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/mui-org"+ },+ "peerDependencies": {+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"+ }+ },"node_modules/@napi-rs/canvas": {"version": "0.1.71","resolved": "https://registry.npmjs.org/@napi-rs/canvas/-/canvas-0.1.71.tgz",@@ -19371,9 +19372,9 @@}},"node_modules/@tagspacespro/tagspacespro": {- "version": "5.0.190",- "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.190/bd47ed322af4909970f57a7bf76c6851f8872239",- "integrity": "sha512-eoPlqNNZcDrTfhmX/Cm6QRIhK9skkIlYgpQJj2IZHAz8lZDTDBSDVy3R9C+3TH7LXm4smsDvlTxoyJzRfzUN+Q==",+ "version": "5.0.193",+ "resolved": "https://npm.pkg.github.com/download/@tagspacespro/tagspacespro/5.0.193/f04811258f904c59fee876703bb63dafe456f109",+ "integrity": "sha512-JuUJpcYSLr/mtbqg+oJr3XgFHgOFZ3wYFI+gUkX0MwMSwt3vj/QAIblOkExaEx7PbHOQFRRJW96cJIOXvc8bOA==","license": "Proprietary","optional": true},@@ -25364,9 +25365,9 @@}},"node_modules/dompurify": {- "version": "3.2.5",- "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.2.5.tgz",- "integrity": "sha512-mLPd29uoRe9HpvwP2TxClGQBzGXeEC/we/q+bFlmPPmj2p2Ugl3r6ATu/UU1v77DXNcehiBg9zsr1dREyA/dJQ==",+ "version": "3.3.0",+ "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.3.0.tgz",+ "integrity": "sha512-r+f6MYR1gGN1eJv0TVQbhA7if/U7P87cdPl3HN5rikqaBSBxLiCb/b9O+2eG0cxz0ghyU+mU1QkbsOwERMYlWQ==","license": "(MPL-2.0 OR Apache-2.0)","optionalDependencies": {"@types/trusted-types": "^2.0.7"@@ -25557,9 +25558,9 @@}},"node_modules/electron": {- "version": "37.2.6",- "resolved": "https://registry.npmjs.org/electron/-/electron-37.2.6.tgz",- "integrity": "sha512-Ns6xyxE+hIK5UlujtRlw7w4e2Ju/ImCWXf1Q/PoOhc0N3/6SN6YW7+ujCarsHbxWnolbW+1RlkHtdklUJpjbPA==",+ "version": "37.7.1",+ "resolved": "https://registry.npmjs.org/electron/-/electron-37.7.1.tgz",+ "integrity": "sha512-2EmIqWv4T8BtgFQosB3/0Fezs09X3l0wXhIzes/cNt/GI+UDljbQr3NiF2J9WnqP0aFSbUEfztGUQMiX+qDvsw==","dev": true,"hasInstallScript": true,"license": "MIT",@@ -46457,9 +46458,9 @@}},"node_modules/use-sync-external-store": {- "version": "1.5.0",- "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.5.0.tgz",- "integrity": "sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A==",+ "version": "1.6.0",+ "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz",+ "integrity": "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==","license": "MIT","peerDependencies": {"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"diff --git a/package.json b/package.jsonindex 7d6cce4c6..312bf1346 100644--- a/package.json+++ b/package.json@@ -140,6 +140,7 @@"start:renderer": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack serve --config ./.erb/configs/webpack.config.renderer.dev.ts","test-clone-data": "rimraf tests/testdata && git clone https://github.com/tagspaces/testdata tests/testdata","test-playwright": "npx playwright install --with-deps && cross-env npx playwright test --project=electron-light",+ "test-playwright-one": "npx playwright install --with-deps && cross-env npx playwright test --project=electron -g '/TST0632/'","test-playwright-pro": "npx playwright install --with-deps && cross-env npx playwright test --project=electron","test-playwright-s3": "npx playwright install --with-deps && cross-env NODE_OPTIONS=--openssl-legacy-provider npx playwright test --project=electron-s3","test-playwright-minio": "npx playwright install --with-deps && cross-env npx playwright test --project=electron-minio",@@ -168,11 +169,11 @@"@milkdown/crepe": "^7.15.1","@milkdown/kit": "^7.15.1","@milkdown/react": "^7.15.1",- "@mui/icons-material": "^7.1.2",- "@mui/lab": "7.0.0-beta.14",- "@mui/material": "^7.1.2",- "@mui/x-data-grid": "^8.9.1",- "@mui/x-date-pickers": "^8.6.0",+ "@mui/icons-material": "7.3.4",+ "@mui/lab": "7.0.1-beta.18",+ "@mui/material": "7.3.4",+ "@mui/x-data-grid": "8.15.0",+ "@mui/x-date-pickers": "8.15.0","@tagspaces/tagspaces-common": "4.5.102","@tagspaces/tagspaces-common-aws3": "4.5.102","@tagspaces/tagspaces-common-cordova": "4.5.102",@@ -181,7 +182,7 @@"coordinate-parser": "1.0.7","crypto-js": "4.2.0","date-fns": "4.1.0",- "dompurify": "3.2.5",+ "dompurify": "3.3.0","echarts": "^6.0.0","electron-debug": "^3.2.0","electron-log": "^4.4.8",@@ -238,7 +239,7 @@"zod-to-json-schema": "^3.24.1"},"optionalDependencies": {- "@tagspacespro/tagspacespro": "5.0.191"+ "@tagspacespro/tagspacespro": "5.0.193"},"devDependencies": {"@electron/notarize": "^2.5.0",@@ -273,7 +274,7 @@"css-minimizer-webpack-plugin": "^5.0.1","detect-port": "^1.5.1","dotenv-webpack": "^8.0.1",- "electron": "^37.2.6",+ "electron": "37.7.1","electron-builder": "^26.0.12","electron-devtools-installer": "^4.0.0","electronmon": "^2.0.3",diff --git a/src/main/main.ts b/src/main/main.tsindex d458bf480..6260f8654 100644--- a/src/main/main.ts+++ b/src/main/main.ts@@ -8,6 +8,8 @@* When running `npm run build` or `npm run build:main`, this file is compiled to* `./src/main.js` using webpack. This gives us some performance wins.*/++import pm2 from '@elife/pm2';import {BrowserWindow,BrowserWindowConstructorOptions,@@ -17,12 +19,9 @@ import {ipcMain,shell,} from 'electron';-import path from 'path';-// import { autoUpdater } from 'electron-updater';-//import log from 'electron-log';-import pm2 from '@elife/pm2';import windowStateKeeper from 'electron-window-state';import findFreePorts from 'find-free-ports';+import path from 'path';import propertiesReader from 'properties-reader';import i18nInit from '../renderer/services/i18nInit';import buildDockMenu from './electron-dock-menu';@@ -35,48 +34,29 @@ import settings from './settings';import { Extensions } from './types';import { resolveHtmlPath } from './util';-// class AppUpdater {-// constructor() {-// log.transports.file.level = 'info';-// autoUpdater.logger = log;-// autoUpdater.checkForUpdatesAndNotify();-// }-// }-+// --- App State ---let isMacLike = process.platform === 'darwin';-let mainWindow: BrowserWindow | null = null;-/*let usedWsPort = undefined;--function getUsedWsPort() {- return usedWsPort;-}*/-let globalShortcutsEnabled = false;+let startupFilePath: string | undefined;+let portableMode: boolean | undefined;-if (process.env.NODE_ENV === 'production') {- const sourceMapSupport = require('source-map-support');- sourceMapSupport.install();-}-+// --- Debug/Dev Mode ---const isDebug =process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true';-const testMode = process.env.NODE_ENV === 'test';if (isDebug || testMode) {require('electron-debug')({ showDevTools: false });if (isMacLike) {- // temp fix https://github.com/electron/electron/issues/43415#issuecomment-2359194469app.disableHardwareAcceleration();}} else {+ // Silence console logs in productionconsole.log = () => {};}-let startupFilePath;-let portableMode;-+// --- Parse Startup Arguments ---process.argv.forEach((arg, count) => {console.log('Opening file: ' + arg);if (@@ -90,41 +70,31 @@ process.argv.forEach((arg, count) => {app.setPath('userData', process.cwd() + '/tsprofile'); // making the app portableportableMode = true;} else if (testMode || isDebug) {- // ignoring the spectron testingarg = '';} else if (arg.endsWith('main.prod.js') ||arg.indexOf('node_modules/electron/dist/') > -1 ||arg.endsWith('electronmon/src/hook.js') ||- //arg === './app/main.dev.babel.js' ||arg === '.' ||arg === '--require' ||count === 0) {- // ignoring the first argument+ // ignore} else if (arg.length > 2) {- // console.warn('Opening file: ' + arg);- //if (arg !== './app/main.dev.js' && arg !== './app/' && arg !== '') {startupFilePath = arg;- //}}-if (portableMode) {startupFilePath = undefined;}});-// if (isDebug) {-// app.commandLine.appendSwitch('--allow-file-access-from-files');-// }-+// --- Browser Window Options ---const browserWindowOptions: BrowserWindowConstructorOptions = {show: false,center: true,autoHideMenuBar: true,titleBarStyle: isMacLike ? 'hidden' : 'default',webPreferences: {- // webSecurity: !isDebug,spellcheck: true,preload:app.isPackaged || !isDebug@@ -138,11 +108,11 @@ const defaultAppSize = {defaultHeight: 800,};+// --- DevTools Extension Installer ---const installExtensions = async () => {const installer = require('electron-devtools-installer');const forceDownload = !!process.env.UPGRADE_EXTENSIONS;const extensions = ['REACT_DEVELOPER_TOOLS'];-return installer.default(extensions.map((name) => installer[name]),@@ -151,20 +121,15 @@ const installExtensions = async () => {.catch(console.log);};-function getSpellcheckLanguage(i18n) {+// --- Utility Functions ---+function getSpellcheckLanguage(i18n: string) {const supportedLanguages =mainWindow?.webContents.session.availableSpellCheckerLanguages;- if (!supportedLanguages) {- return 'en';- }- if (supportedLanguages.includes(i18n)) {- return i18n;- }+ if (!supportedLanguages) return 'en';+ if (supportedLanguages.includes(i18n)) return i18n;if (i18n.length > 2) {const shortI18n = i18n.substring(0, 2);- if (supportedLanguages.includes(shortI18n)) {- return shortI18n;- }+ if (supportedLanguages.includes(shortI18n)) return shortI18n;}return 'en';}@@ -173,190 +138,150 @@ function showApp() {const windows = BrowserWindow.getAllWindows();windows.forEach((win, i) => {if (win && i < 1) {- if (win.isMinimized()) {- win.restore();- } else {- win.show();- }+ if (win.isMinimized()) win.restore();+ else win.show();}});- // if (mainWindow) {- // if (mainWindow.isMinimized()) {- // mainWindow.restore();- // }- // mainWindow?.show();- // }}function showMainWindow() {if (mainWindow) {- if (mainWindow.isMinimized()) {- mainWindow.restore();- }- mainWindow?.show();+ if (mainWindow.isMinimized()) mainWindow.restore();+ mainWindow.show();}}+// --- Panel/Command Functions ---function openLocationManagerPanel() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('panels', 'open-location-manager-panel');+ BrowserWindow.getFocusedWindow()?.webContents.send(+ 'panels',+ 'open-location-manager-panel',+ );}-function openTagLibraryPanel() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('panels', 'open-tag-library-panel');+ BrowserWindow.getFocusedWindow()?.webContents.send(+ 'panels',+ 'open-tag-library-panel',+ );}-function openHelpFeedbackPanel() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('panels', 'open-help-feedback-panel');+ BrowserWindow.getFocusedWindow()?.webContents.send(+ 'panels',+ 'open-help-feedback-panel',+ );}-function goBack() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('history', 'go-back');+ BrowserWindow.getFocusedWindow()?.webContents.send('history', 'go-back');}-function goForward() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('history', 'go-forward');+ BrowserWindow.getFocusedWindow()?.webContents.send('history', 'go-forward');}-function setZoomResetApp() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('cmd', 'set-zoom-reset-app');+ BrowserWindow.getFocusedWindow()?.webContents.send(+ 'cmd',+ 'set-zoom-reset-app',+ );}-function setZoomInApp() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('cmd', 'set-zoom-in-app');+ BrowserWindow.getFocusedWindow()?.webContents.send('cmd', 'set-zoom-in-app');}-function setZoomOutApp() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('cmd', 'set-zoom-out-app');+ BrowserWindow.getFocusedWindow()?.webContents.send('cmd', 'set-zoom-out-app');}-function exitFullscreen() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('cmd', 'exit-fullscreen');+ BrowserWindow.getFocusedWindow()?.webContents.send('cmd', 'exit-fullscreen');}-function toggleSettingsDialog() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('toggle-settings-dialog');+ BrowserWindow.getFocusedWindow()?.webContents.send('toggle-settings-dialog');}-function toggleKeysDialog() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('toggle-keys-dialog');+ BrowserWindow.getFocusedWindow()?.webContents.send('toggle-keys-dialog');}-function toggleOnboardingDialog() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('toggle-onboarding-dialog');+ BrowserWindow.getFocusedWindow()?.webContents.send(+ 'toggle-onboarding-dialog',+ );}--function openURLExternally(data) {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('open-url-externally', data);+function openURLExternally(data: any) {+ BrowserWindow.getFocusedWindow()?.webContents.send(+ 'open-url-externally',+ data,+ );}-function toggleLicenseDialog() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('toggle-license-dialog');+ BrowserWindow.getFocusedWindow()?.webContents.send('toggle-license-dialog');}-function toggleThirdPartyLibsDialog() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('toggle-third-party-libs-dialog');+ BrowserWindow.getFocusedWindow()?.webContents.send(+ 'toggle-third-party-libs-dialog',+ );}-function toggleAboutDialog() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('toggle-about-dialog');+ BrowserWindow.getFocusedWindow()?.webContents.send('toggle-about-dialog');}-function showSearch() {const focusedWindow = BrowserWindow.getFocusedWindow();- if (focusedWindow) {- focusedWindow?.webContents.send('cmd', 'open-search');- } else {+ if (focusedWindow) focusedWindow.webContents.send('cmd', 'open-search');+ else {showMainWindow();mainWindow?.webContents.send('cmd', 'open-search');}}-function newTextFile() {const focusedWindow = BrowserWindow.getFocusedWindow();- if (focusedWindow) {- focusedWindow?.webContents.send('new-text-file');- } else {+ if (focusedWindow) focusedWindow.webContents.send('new-text-file');+ else {showMainWindow();mainWindow?.webContents.send('new-text-file');}}-function newMDFile() {const focusedWindow = BrowserWindow.getFocusedWindow();- if (focusedWindow) {- focusedWindow?.webContents.send('new-md-file');- } else {+ if (focusedWindow) focusedWindow.webContents.send('new-md-file');+ else {showMainWindow();mainWindow?.webContents.send('new-md-file');}}-function getNextFile() {const focusedWindow = BrowserWindow.getFocusedWindow();- if (focusedWindow) {- focusedWindow?.webContents.send('perspective', 'next-file');- } else {+ if (focusedWindow) focusedWindow.webContents.send('perspective', 'next-file');+ else {showMainWindow();mainWindow?.webContents.send('perspective', 'next-file');}}-function getPreviousFile() {const focusedWindow = BrowserWindow.getFocusedWindow();- if (focusedWindow) {- focusedWindow?.webContents.send('perspective', 'previous-file');- } else {+ if (focusedWindow)+ focusedWindow.webContents.send('perspective', 'previous-file');+ else {showMainWindow();mainWindow?.webContents.send('perspective', 'previous-file');}}-function showCreateDirectoryDialog() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('show-create-directory-dialog');+ BrowserWindow.getFocusedWindow()?.webContents.send(+ 'show-create-directory-dialog',+ );}-function toggleOpenLinkDialog() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.send('toggle-open-link-dialog');+ BrowserWindow.getFocusedWindow()?.webContents.send('toggle-open-link-dialog');}-function resumePlayback() {- const windows = BrowserWindow.getAllWindows();- windows.forEach((win, i) => {- win?.webContents.send('play-pause');- });+ BrowserWindow.getAllWindows().forEach((win) =>+ win.webContents.send('play-pause'),+ );}-function reloadApp() {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.loadURL(resolveHtmlPath('index.html'));+ BrowserWindow.getFocusedWindow()?.loadURL(resolveHtmlPath('index.html'));}--function createNewWindowInstance(url?) {+function createNewWindowInstance(url?: string) {if (BrowserWindow.getAllWindows().length === 0) {createWindow(appI18N);return;}-const mainWindowState = windowStateKeeper(defaultAppSize);-const newWindowInstance = new BrowserWindow({...browserWindowOptions,width: mainWindowState.width,@@ -372,17 +297,13 @@ function createNewWindowInstance(url?) {// @ts-ignoremainWindow.descriptionChanged = false;}-newWindowInstance.setMenuBarVisibility(false);-- if (url) {- newWindowInstance.loadURL(url);- } else {- newWindowInstance.loadURL(resolveHtmlPath('index.html'));- }+ if (url) newWindowInstance.loadURL(url);+ else newWindowInstance.loadURL(resolveHtmlPath('index.html'));}-function bindTrayMenu(i18n) {+// --- Menu Binding ---+function bindTrayMenu(i18n: any) {buildTrayMenu({showTagSpaces: showApp,@@ -399,8 +320,7 @@ function bindTrayMenu(i18n) {globalShortcutsEnabled,);}--function bindAppMenu(i18n) {+function bindAppMenu(i18n: any) {buildDesktopMenu({showTagSpaces: showApp,@@ -433,20 +353,10 @@ function bindAppMenu(i18n) {);}-/*const RESOURCES_PATH = app.isPackaged- ? path.join(process.resourcesPath, 'assets')- : path.join(__dirname, '../../assets');--const getAssetPath = (...paths: string[]): string => {- return path.join(RESOURCES_PATH, ...paths);-};*/-+// --- WebSocket Server ---async function findPort() {- if (isDebug || testMode) {- return 2000;- }+ if (isDebug || testMode) return 2000;const defaultWSPort = settings.getInitWsPort();- //console.log('defaultWSPort:' + defaultWSPort);try {const [port] = await findFreePorts(1, { startPort: defaultWSPort });return port;@@ -459,12 +369,10 @@ async function findPort() {function startWS() {try {- let filepath;- let script;- let envPath;+ let filepath, script, envPath;if (app.isPackaged) {- filepath = process.resourcesPath; // path.join(__dirname, '../../..');- script = 'app.asar/node_modules/@tagspaces/tagspaces-ws/build/index.js'; //app.asar/+ filepath = process.resourcesPath;+ script = 'app.asar/node_modules/@tagspaces/tagspaces-ws/build/index.js';envPath = path.join(filepath, 'app.asar/.env');} else {filepath = path.join(@@ -474,20 +382,17 @@ function startWS() {script = 'index.js';envPath = path.join(__dirname, '../.env');}- const properties = propertiesReader(envPath); //getAssetPath('.env')- //console.debug(JSON.stringify(properties.get('KEY')));-+ const properties = propertiesReader(envPath);const results = new Promise((resolve, reject) => {findPort().then((freePort) => {try {pm2.start({name: 'Tagspaces WS',- script, // Script to be run- cwd: filepath, // './node_modules/tagspaces-ws', // './process1', cwd: '/path/to/npm/module/',+ script,+ cwd: filepath,args: ['-p', freePort, '-k', properties.get('KEY')],restartAt: [],- // log: path.join(process.cwd(), 'thumbGen.log')},(err, pid) => {if (err && pid) {@@ -498,9 +403,7 @@ function startWS() {reject(err);} else {settings.setUsedWsPort(freePort);- mainWindow?.webContents.send('start_ws', {- port: freePort,- });+ mainWindow?.webContents.send('start_ws', { port: freePort });console.debug('start_ws:' + freePort);resolve(`Starting ${pid.name} on ${pid.cwd} - pid (${pid.child.pid})`,@@ -522,10 +425,10 @@ function startWS() {}}-const createWindow = async (i18n) => {+// --- Main Window Creation ---+const createWindow = async (i18n: any) => {let startupParameter = '';if (startupFilePath) {- //console.log(JSON.stringify(process.env));console.log('Startup file path: ' + startupFilePath);if (startupFilePath.startsWith('./') || startupFilePath.startsWith('.\\')) {startupParameter =@@ -535,9 +438,7 @@ const createWindow = async (i18n) => {}}- if (isDebug) {- await installExtensions();- }+ if (isDebug) await installExtensions();const mainWindowState = windowStateKeeper(defaultAppSize);@@ -561,28 +462,9 @@ const createWindow = async (i18n) => {resolveHtmlPath('index.html') + startupParameter,testWinOnUnix ? { userAgent: winUserAgent } : {},);- /*.then(() => {- mainWindow.webContents.send('start_ws', {- port: getUsedWsPort(),- });- });*/-- /*mainWindow.webContents.on('did-finish-load', () => {- const cssPath = app.isPackaged ? path.join(- process.resourcesPath,- 'node_modules/@milkdown/theme-nord/lib/style.css',- ) : path.join(- __dirname,- '../../node_modules/@milkdown/theme-nord/lib/style.css',- )- mainWindow?.webContents.insertCSS(fs.readFileSync(cssPath, 'utf8'));- });*/mainWindow.webContents.on('before-input-event', (_, input) => {- if (!mainWindow) {- throw new Error('"mainWindow" is not defined');- }-+ if (!mainWindow) throw new Error('"mainWindow" is not defined');if (input.type === 'keyDown' && input.key === 'F12') {mainWindow.webContents.isDevToolsOpened()? mainWindow.webContents.closeDevTools()@@ -591,26 +473,13 @@ const createWindow = async (i18n) => {});mainWindow.on('ready-to-show', () => {- if (!mainWindow) {- throw new Error('"mainWindow" is not defined');- }-- //console.log('prosess:' + stringifyMaxDepth(process, 3));- if (process.env.START_MINIMIZED) {- mainWindow.minimize();- } else {- mainWindow.show();- }+ if (!mainWindow) throw new Error('"mainWindow" is not defined');+ if (process.env.START_MINIMIZED) mainWindow.minimize();+ else mainWindow.show();});mainWindow.on('show', () => {- if (!mainWindow) {- throw new Error('"mainWindow" is not defined');- }-- // if (isMacLike) {- // mainWindow.webContents.setZoomFactor(0.9);- // }+ if (!mainWindow) throw new Error('"mainWindow" is not defined');});mainWindow.on('close', (e) => {@@ -625,11 +494,7 @@ const createWindow = async (i18n) => {message: i18n.t('unsavedChangesMessage'),detail: i18n.t('unsavedChangesDetails'),});-- if (choice === 0) {- // Cancel- e.preventDefault(); // Prevent closing- }+ if (choice === 0) e.preventDefault();// No action needed for "Close Application", window will close}});@@ -641,15 +506,12 @@ const createWindow = async (i18n) => {mainWindow.webContents.on('render-process-gone',(_, { reason, exitCode }) => {- /*console.error(- `[web ui] render-process-gone: ${reason}, code: ${exitCode}`- );*/- // 'crashed'pm2.stopAll();globalShortcut.unregisterAll();app.quit();},);+try {bindAppMenu(i18n);bindTrayMenu(i18n);@@ -662,17 +524,10 @@ const createWindow = async (i18n) => {shell.openExternal(edata.url);return { action: 'deny' };});-- // Remove this if your app does not use auto updates- // eslint-disable-next-line- // new AppUpdater();};-app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required'); // Fix broken autoplay functionality in the av player--/**- * Add event listeners...- */+// --- Electron App Events ---+app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');app.on('window-all-closed', () => {// Respect the macOS convention of having the application in memory even@@ -685,7 +540,6 @@ app.on('window-all-closed', () => {});app.on('activate', (event, hasVisibleWindows) => {- // console.log('Activate ' + hasVisibleWindows);const windows = BrowserWindow.getAllWindows();// On macOS it's common to re-create a window in the app when the// dock icon is clicked and there are no other windows open.@@ -705,16 +559,16 @@ app.on('quit', () => {app.on('web-contents-created', (event, contents) => {contents.on('will-navigate', (event, navigationUrl) => {const parsedUrl = new URL(navigationUrl);-if (parsedUrl.origin !== 'file://') {event.preventDefault();}});});+// --- Startup ---startWS();-let appI18N;+let appI18N: any;protocol.register();@@ -757,24 +611,16 @@ app}});- ipcMain.on('show-main-window', () => {- showApp();- });-- ipcMain.on('create-new-window', (e, url) => {- createNewWindowInstance(url);- });+ // --- IPC Main Handlers ---+ ipcMain.on('show-main-window', showApp);+ ipcMain.on('create-new-window', (e, url) => createNewWindowInstance(url));ipcMain.on('file-changed', (e, isChanged) => {- if (mainWindow) {- // @ts-ignore- mainWindow.fileChanged = isChanged;- }+ // @ts-ignore+ if (mainWindow) mainWindow.fileChanged = isChanged;});ipcMain.on('description-changed', (e, isChanged) => {- if (mainWindow) {- // @ts-ignore- mainWindow.descriptionChanged = isChanged;- }+ // @ts-ignore+ if (mainWindow) mainWindow.descriptionChanged = isChanged;});loadMainEvents();@@ -790,40 +636,29 @@ appextensions,supportedFileTypes,};- console.log('set_extensions' + JSON.stringify(setExtensions));mainWindow?.webContents.send('set_extensions', setExtensions);- // mainWindow.webContents.send('set_supported_file_types', supportedFileTypes);}).catch((err) => console.error('load-extensions', err));});- ipcMain.on('focus-window', () => {- mainWindow?.focus();- });-+ ipcMain.on('focus-window', () => mainWindow?.focus());ipcMain.on('get-user-home-path', (event) => {event.returnValue = app.getPath('home');});-ipcMain.on('worker-response', (event, arg) => {mainWindow?.webContents.send(arg.id, arg);});-ipcMain.on('app-data-path-request', (event) => {- event.returnValue = app.getPath('appData'); // eslint-disable-line+ event.returnValue = app.getPath('appData');});-ipcMain.on('app-version-request', (event) => {- event.returnValue = app.getVersion(); // eslint-disable-line+ event.returnValue = app.getVersion();});-ipcMain.on('set-language', (e, language) => {i18n.changeLanguage(language);});-ipcMain.on('setZoomFactor', (event, zoomLevel) => {- const focusedWindow = BrowserWindow.getFocusedWindow();- focusedWindow?.webContents.setZoomFactor(zoomLevel);+ BrowserWindow.getFocusedWindow()?.webContents.setZoomFactor(zoomLevel);});ipcMain.on('global-shortcuts-enabled', (e, globalShortcuts) => {@@ -850,21 +685,15 @@ appipcMain.on('relaunch-app', reloadApp);- process.removeAllListeners('uncaughtException'); // app crashes on ECONNRESET in default uncaughtException of Electron-+ process.removeAllListeners('uncaughtException');process.on('uncaughtException', (error) => {- // Always log the full error for diagnosticsconsole.error('UNCAUGHT EXCEPTION in main:',error && error.stack ? error.stack : error,);-- // Normalize message/code for checksconst msg = error && error.message ? error.message : '';//@ts-ignoreconst code = error && error.code ? error.code : '';-- // Ignore or quietly handle known/non-fatal errorsconst isAbort = error && error.name === 'AbortError';const isSocketHangUp =msg.includes('socket hang up') ||@@ -872,13 +701,12 @@ appcode === 'ECONNABORTED';if (isAbort || isSocketHangUp) {- // Expected when cancelling requests — just log and continue.console.warn('Known non-fatal error (ignored):',msg || code || error,);return;- } // For other errors: try graceful recovery (reload) or exit gracefully.+ }try {reloadApp();} catch (reloadErr) {@@ -886,7 +714,6 @@ app'reloadApp() failed, exiting process:',reloadErr && reloadErr.stack ? reloadErr.stack : reloadErr,);- // Exit with non-zero code to indicate failure (or perform other cleanup)process.exit(1);}});diff --git a/src/renderer/components/CommonIcons.tsx b/src/renderer/components/CommonIcons.tsxindex 20255f97b..98dc2cf18 100644--- a/src/renderer/components/CommonIcons.tsx+++ b/src/renderer/components/CommonIcons.tsx@@ -346,7 +346,21 @@ export const MainMenuIcon = (props) => (xmlns="http://www.w3.org/2000/svg"><path d="m 17.949153,3.2288136 c 2.38594,0.00262 4.319493,1.9987321 4.322034,4.4618644 v 8.923729 c -0.0025,2.463133 -1.936094,4.459242 -4.322034,4.461865 H 5.8474576 C 3.4615172,21.073649 1.5279643,19.07754 1.5254237,16.614407 V 7.690678 C 1.5279646,5.2275457 3.4615175,3.2314368 5.8474576,3.2288136 H 17.949153 M 3.2542373,16.614407 c 0,1.47539 1.1640678,2.677119 2.5932203,2.677119 H 9.3050847 V 5.0135594 H 5.8474576 c -1.4291525,0 -2.5932203,1.2017288 -2.5932203,2.6771186 v 8.923729 M 20.542373,7.690678 c 0,-1.4753898 -1.164068,-2.6771186 -2.59322,-2.6771186 H 11.033898 V 19.291526 h 6.915255 c 1.429152,0 2.59322,-1.201729 2.59322,-2.677119 z M 7.5762712,11.260169 c -5e-7,-0.492844 -0.3870084,-0.892372 -0.8644068,-0.892372 H 5.8474576 c -1.1536045,0.0011 -1.1536045,1.785844 0,1.784745 h 0.8644068 c 0.4773987,0 0.8644069,-0.399529 0.8644068,-0.892373 m 0,3.569492 c -5e-7,-0.492844 -0.3870084,-0.892372 -0.8644068,-0.892372 H 5.8474576 c -1.1536045,0.0011 -1.1536045,1.785844 0,1.784745 h 0.8644068 c 0.4773987,0 0.8644069,-0.399529 0.8644068,-0.892373 M 4.9830508,7.690678 c 0,0.4928439 0.3870081,0.8923729 0.8644068,0.8923729 h 0.8644068 c 1.1525419,0 1.1525419,-1.7847458 0,-1.7847458 H 5.8474576 c -0.4773987,0 -0.8644068,0.399529 -0.8644068,0.8923729"></path>- {/* <path d="m 9.3261719,2.6660156 c -1.1202981,0 -2.0132424,-0.00355 -2.75,0.056641 -0.6523209,0.053309 -1.241444,0.158837 -1.7910157,0.3945312 a 0.30511527,0.30511527 0 0 0 -0.00977,0.00586 L 4.5605469,3.2246094 a 0.30511527,0.30511527 0 0 0 -0.00781,0.00391 C 3.7024606,3.6617559 2.9921642,4.3199285 2.4960938,5.1289062 a 0.30511527,0.30511527 0 0 0 -0.00586,0.011719 l -0.1875,0.3339844 a 0.30511527,0.30511527 0 0 0 -0.00586,0.00977 C 1.9840141,6.0986492 1.8519531,6.76201 1.7910156,7.5078125 1.7308256,8.2445593 1.734375,9.1375271 1.734375,10.257813 v 3.236328 c 0,1.120176 -0.00355,2.015192 0.056641,2.751953 0.060953,0.745884 0.1930987,1.407512 0.5058594,2.021484 a 0.30511527,0.30511527 0 0 0 0.00586,0.0098 l 0.1875,0.335937 a 0.30511527,0.30511527 0 0 0 0.00586,0.01172 c 0.4960728,0.808968 1.2063975,1.467139 2.0566406,1.900391 a 0.30511527,0.30511527 0 0 0 0.00977,0.0059 l 0.2148437,0.09961 a 0.30511527,0.30511527 0 0 0 0.00781,0.0039 c 0.5497232,0.23588 1.1385906,0.34119 1.7910157,0.394531 0.7361862,0.06011 1.6293411,0.05859 2.75,0.05859 h 5.2656251 c 1.12066,0 2.015658,0.0015 2.751953,-0.05859 0.74521,-0.06095 1.407006,-0.190927 2.021484,-0.503906 a 0.30511527,0.30511527 0 0 0 0.0098,-0.0059 l 0.333984,-0.1875 a 0.30511527,0.30511527 0 0 0 0.01172,-0.0059 c 0.809209,-0.496167 1.46901,-1.208073 1.902344,-2.058594 a 0.30511527,0.30511527 0 0 0 0.0059,-0.0098 l 0.09961,-0.214843 a 0.30511527,0.30511527 0 0 0 0.0039,-0.0078 c 0.235618,-0.549379 0.341185,-1.136634 0.394531,-1.789062 0.06011,-0.736189 0.05859,-1.631416 0.05859,-2.751953 v -3.236328 c 0,-1.1206475 0.0015,-2.013828 -0.05859,-2.7500005 -0.05335,-0.6522994 -0.158784,-1.2414137 -0.394531,-1.7910156 a 0.30511527,0.30511527 0 0 0 -0.0039,-0.00781 l -0.09961,-0.2148438 a 0.30511527,0.30511527 0 0 0 -0.0059,-0.00977 C 21.189617,4.6337398 20.529473,3.9236719 19.720703,3.4277344 a 0.30511527,0.30511527 0 0 0 -0.01172,-0.00586 L 19.375,3.234375 a 0.30511527,0.30511527 0 0 0 -0.0098,-0.00586 C 18.751255,2.9157641 18.089521,2.7835973 17.34375,2.7226563 16.60688,2.6624633 15.712095,2.6660156 14.591797,2.6660156 Z M 10.035156,4.890625 h 4.556641 c 1.147086,0 1.954384,0.00257 2.568359,0.052734 0.604326,0.049372 0.942269,0.1386191 1.195313,0.2675781 l 0.201172,0.1132812 c 0.459866,0.281991 0.835422,0.6878741 1.082031,1.171875 l 0.08984,0.2070313 c 0.08124,0.2275198 0.140721,0.5328318 0.177734,0.9863281 0.05019,0.6139666 0.05273,1.4213175 0.05273,2.5683599 v 3.236328 c 0,1.146968 -0.0026,1.954403 -0.05273,2.568359 -0.03702,0.453646 -0.09643,0.758897 -0.177734,0.986328 l -0.08984,0.208984 c -0.24649,0.483735 -0.621586,0.887623 -1.082031,1.169922 l -0.201172,0.113282 c -0.253955,0.129392 -0.591717,0.220153 -1.195313,0.269531 -0.613421,0.05003 -1.420943,0.05078 -2.568359,0.05078 H 10.033203 Z M 7.8085937,4.90625 V 18.845703 C 7.4204622,18.839799 7.0433146,18.833877 6.7578125,18.810547 6.3050879,18.773475 6.000183,18.712515 5.7714844,18.630859 L 5.5644531,18.541016 C 5.0804724,18.294405 4.6745806,17.918851 4.3925781,17.458984 L 4.2792969,17.257812 C 4.1503278,17.00473 4.0610914,16.666942 4.0117187,16.0625 3.9615577,15.448528 3.9589844,14.641105 3.9589844,13.494141 v -3.236328 c 0,-1.1470374 0.00257,-1.9543732 0.052734,-2.5683599 C 4.0610865,7.0851839 4.1500757,6.749723 4.2792969,6.4960937 L 4.3925781,6.2929687 C 4.6733502,5.8350757 5.0773804,5.4614923 5.5585937,5.2148437 l 0.2128907,-0.091797 h 0.00391 C 6.0037567,5.0418047 6.3068298,4.9802048 6.7578125,4.9433594 7.04437,4.9199521 7.4208036,4.912657 7.8085937,4.90625 Z"></path> */}+ </svg>+ </SvgIcon>+);++export const OllamaIcon = (props) => (+ <SvgIcon>+ <svg+ xmlns="http://www.w3.org/2000/svg"+ fill="currentColor"+ fillRule="evenodd"+ viewBox="0 0 646 854"+ >+ <path d="M140.629.24c-7.969 1.287-17.532 5.456-24.275 10.605-20.413 15.51-36.229 48.428-42.91 89.438-2.514 15.509-4.23 37.026-4.23 53.455 0 19.371 2.268 44.136 5.517 61.239.736 3.801 1.103 7.173.797 7.418-.245.245-3.25 2.697-6.62 5.394-11.525 9.195-24.705 23.356-33.778 36.291-17.41 24.704-28.688 52.78-33.409 83.185-1.839 12.015-2.33 36.29-.858 48.305 3.25 27.708 11.586 51.125 25.87 72.581l4.658 6.927-1.349 2.268c-9.563 16.061-17.716 39.294-21.516 61.607-3.004 17.655-3.372 22.375-3.372 46.037 0 23.847.307 28.567 3.127 45.057 3.371 19.739 10.237 40.642 17.9 54.558 2.513 4.536 8.643 13.976 9.378 14.467.246.122-.49 2.39-1.655 5.026-8.827 19.31-16.367 44.995-19.493 66.635-2.207 14.834-2.514 19.616-2.514 35.248 0 19.922 1.104 29.608 5.272 45.485l.613 2.329h52.535l-1.716-3.249c-10.605-19.616-11.586-56.029-2.452-92.38 4.168-16.797 8.888-29.118 17.716-46.099l5.272-10.298v-6.314c0-5.885-.123-6.559-2.023-10.421-1.472-2.943-3.433-5.456-6.927-8.889-5.947-5.762-10.238-11.831-13.67-19.31-15.08-32.735-18.023-81.346-7.418-122.786 4.414-17.287 11.709-32.673 19.371-41.071 5.21-5.763 7.908-12.199 7.908-18.881 0-6.927-2.452-12.628-7.97-18.574-15.815-16.919-25.562-37.517-29.056-61.485-4.965-34.145 4.046-71.355 24.52-100.84 20.046-28.935 48.183-47.509 79.631-52.474 7.049-1.165 20.229-.981 27.585.368 8.031 1.41 13.057.98 18.207-1.472 6.375-3.003 9.563-6.743 13.302-15.325 3.31-7.662 5.885-11.831 12.812-20.474 8.337-10.36 16.367-17.41 29.24-25.931 14.713-9.624 31.448-16.612 48.122-19.984 6.068-1.226 8.888-1.41 20.229-1.41s14.161.184 20.229 1.41c24.459 4.966 48.735 17.594 68.106 35.493 4.168 3.862 14.16 16.245 17.348 21.395 1.226 2.022 3.372 6.314 4.72 9.501 3.739 8.582 6.927 12.322 13.302 15.325 4.966 2.391 10.176 2.882 17.9 1.594 12.199-2.084 21.578-1.9 33.532.552 40.704 8.214 76.136 41.746 91.829 86.68 13.67 39.416 9.808 80.672-10.544 112.18-3.433 5.334-6.866 9.625-11.831 14.897-10.728 11.463-10.728 25.685-.061 37.455 17.532 19.187 28.505 66.389 25.194 108.012-2.206 27.463-9.256 52.045-18.942 65.96-1.716 2.452-5.271 6.62-7.969 9.195-3.494 3.433-5.455 5.946-6.927 8.889-1.9 3.862-2.023 4.536-2.023 10.421v6.314l5.272 10.298c8.828 16.981 13.548 29.302 17.716 46.099 9.012 35.861 8.215 71.538-2.084 91.829-.858 1.716-1.594 3.31-1.594 3.494 0 .184 11.709.306 26.053.306h25.992l.674-2.636c.368-1.409.981-3.555 1.287-4.781.675-2.697 2.023-10.666 3.127-18.329 1.042-7.724 1.042-36.168 0-44.75-3.923-31.141-10.483-55.845-21.21-79.201-1.165-2.636-1.901-4.904-1.656-5.026.307-.184 2.023-2.636 3.862-5.395 13.364-20.229 21.578-45.669 25.747-79.262 1.103-9.257 1.103-49.041 0-57.93-2.943-22.926-6.498-38.497-12.383-54.251-2.452-6.559-8.95-20.413-11.708-24.888l-1.349-2.268 4.659-6.927c14.283-21.456 22.62-44.873 25.869-72.581 1.471-12.015.981-36.29-.858-48.305-4.782-30.467-16-58.42-33.409-83.185-9.073-12.935-22.253-27.096-33.777-36.291-3.372-2.697-6.376-5.149-6.621-5.394-.306-.245.062-3.617.797-7.418 7.418-38.681 7.172-86.924-.613-124.625-6.743-32.857-19.003-58.971-34.819-74.051C523.209 4.286 510.336-.864 494.888.117c-35.432 2.085-63.998 42.85-75.278 107.093-1.839 10.36-3.432 22.498-3.432 25.808 0 1.287-.246 2.329-.552 2.329-.307 0-2.697-1.226-5.272-2.758-27.34-16.184-57.746-24.827-87.354-24.827-29.608 0-60.014 8.643-87.354 24.827-2.575 1.532-4.965 2.758-5.272 2.758-.306 0-.552-1.042-.552-2.329 0-3.433-1.655-15.938-3.432-25.808-10.238-57.684-33.716-95.875-64.918-105.499C157.181.424 144.982-.434 140.629.24zm10.422 49.899c8.827 6.988 18.635 26.972 24.275 49.347 1.042 4.046 2.145 8.705 2.452 10.421.245 1.656.919 5.395 1.471 8.276 2.391 12.996 3.494 27.034 3.617 44.137l.061 16.858-4.23 6.252-4.229 6.314h-9.87c-11.524 0-22.988 1.472-33.961 4.414-3.923.981-7.724 1.962-8.459 2.146-1.165.245-1.349-.123-2.023-5.15-3.617-27.279-3.433-57.5.552-82.634 4.413-28.014 14.712-53.393 24.765-60.871 2.391-1.778 2.82-1.717 5.579.49zm349.538-.43c6.069 4.476 12.751 16.368 17.716 31.57 9.992 30.406 12.812 72.152 7.54 111.875-.674 5.027-.858 5.395-2.023 5.15-.735-.184-4.536-1.165-8.459-2.146-10.973-2.942-22.437-4.414-33.961-4.414h-9.87l-4.229-6.314-4.23-6.252.061-16.858c.123-23.785 2.33-42.359 7.601-63.018 5.579-22.19 15.448-42.175 24.214-49.163 2.759-2.207 3.188-2.268 5.64-.43z"></path>+ <path d="M313.498 358.237c-13.303 1.288-16.919 1.778-23.295 3.066-10.36 2.145-24.214 6.927-33.838 11.647-33.47 16.367-56.519 43.646-63.569 75.216-1.41 6.253-1.594 8.337-1.594 18.881 0 10.421.184 12.689 1.533 18.635 9.379 41.256 47.385 71.723 96.549 77.301 10.666 1.165 56.765 1.165 67.431 0 39.478-4.475 73.439-25.869 88.703-55.907 4.045-8.03 6.007-13.241 7.846-21.394 1.349-5.946 1.533-8.214 1.533-18.635 0-10.544-.184-12.628-1.594-18.881-10.238-45.853-54.742-81.959-109.3-88.825-7.111-.858-25.746-1.594-30.405-1.104zm22.926 33.348c18.207 1.962 36.536 8.46 51.248 18.268 7.908 5.272 19.065 16.306 23.846 23.54 5.885 8.949 9.256 18.083 10.789 29.179.674 5.088.307 8.95-1.533 17.164-2.881 12.26-11.831 25.072-23.907 34.022-5.64 4.107-17.348 10.054-24.52 12.383-13.609 4.352-22.498 5.149-54.252 4.904-20.719-.184-24.398-.368-30.344-1.471-20.29-3.801-36.351-11.893-47.998-24.214-9.441-9.931-13.732-19.003-16.061-33.654-1.042-6.805.919-18.084 4.904-27.586 4.843-11.586 17.348-25.991 29.731-34.267 14.344-9.563 33.225-16.367 50.573-18.206 6.682-.736 20.842-.736 27.524-.062z"></path>+ <path d="M299.584 436.336c-4.659 2.513-7.908 8.888-6.927 13.608 1.103 5.088 5.578 10.238 12.566 14.468 3.74 2.268 3.985 2.574 4.169 4.842.122 1.349-.368 5.211-1.042 8.644-.736 3.371-1.288 6.927-1.288 7.908.062 2.636 2.514 6.927 5.088 9.011 2.269 1.839 2.698 1.9 9.073 2.084 5.824.184 7.05.061 9.379-1.042 6.008-2.943 7.54-8.337 5.333-18.697-1.839-8.643-1.471-9.992 3.127-12.628 4.842-2.82 9.992-7.785 11.524-11.157 2.943-6.436.245-13.731-6.253-17.103-1.593-.797-3.555-1.164-6.436-1.164-4.475 0-7.356 1.042-12.628 4.413l-3.004 1.901-1.9-1.165c-7.785-4.598-9.195-5.149-13.916-5.088-3.371 0-5.21.306-6.865 1.165zM150.744 365.165c-10.85 3.433-18.942 11.402-23.11 22.743-2.023 5.395-3.004 13.916-2.146 18.513 2.023 10.973 11.034 20.965 21.272 23.724 12.873 3.371 22.497 1.164 31.018-7.295 4.965-4.843 7.663-9.073 10.36-15.939 1.961-4.842 2.084-5.7 2.084-12.566l.061-7.356-2.574-5.272c-4.108-8.337-11.525-14.529-20.107-16.797-4.843-1.226-12.628-1.164-16.858.245zM478.153 364.982c-8.398 2.268-15.877 8.52-19.862 16.735l-2.574 5.272.061 7.356c0 6.866.123 7.724 2.084 12.566 2.698 6.866 5.395 11.096 10.36 15.939 8.521 8.459 18.145 10.666 31.019 7.295 7.417-1.962 14.834-8.215 18.39-15.51 3.065-6.191 3.8-10.666 2.82-17.716-2.268-16.122-11.709-27.83-25.747-31.937-4.107-1.226-12.076-1.226-16.551 0z"></path></svg></SvgIcon>);diff --git a/src/renderer/components/CustomLogo.tsx b/src/renderer/components/CustomLogo.tsxindex 29c7f06f3..05422f86a 100644--- a/src/renderer/components/CustomLogo.tsx+++ b/src/renderer/components/CustomLogo.tsx@@ -23,7 +23,7 @@ import Tooltip from '-/components/Tooltip';import TsIconButton from '-/components/TsIconButton';import { useAboutDialogContext } from '-/components/dialogs/hooks/useAboutDialogContext';import { isUpdateAvailable } from '-/reducers/app';-import { Badge, Typography } from '@mui/material';+import { Badge, Box, Typography } from '@mui/material';import { useMemo } from 'react';import { useTranslation } from 'react-i18next';import { useSelector } from 'react-redux';@@ -50,9 +50,9 @@ function CustomLogo() {}, []);return (- <div+ <BoxonClick={() => openAboutDialog()}- style={{+ sx={{width: '100%',textAlign: 'center',// @ts-ignore@@ -71,18 +71,15 @@ function CustomLogo() {horizontal: 'right',}}invisible={!updateAvailable}- style={+ sx={{- marginTop: 7,+ marginTop: '7px',WebkitAppRegion: 'no-drag',} as React.CSSProperties & { WebkitAppRegion?: string }}>{AppConfig.showTSLogo && (- <TsIconButton- //tooltip={tsAboutTitle}- style={{ padding: 0, marginTop: -5, height: 40 }}- >+ <TsIconButton sx={{ padding: 0, marginTop: '-5px', height: 40 }}><imgstyle={{@@ -98,7 +95,7 @@ function CustomLogo() {)}<TsIconButton// tooltip={tsAboutTitle}- style={{ height: 40, padding: 0, marginTop: -5 }}+ sx={{ height: 40, padding: 0, marginTop: '-5px' }}data-tid="aboutTagSpaces"><img@@ -117,10 +114,10 @@ function CustomLogo() {<><sup><Typography- style={{+ sx={{display: 'inline',fontSize: '10px',- marginLeft: 3,+ marginLeft: '3px',lineHeight: '16px',}}>@@ -129,11 +126,11 @@ function CustomLogo() {</sup><sub><Typography- style={+ sx={{display: 'inline',fontSize: '10px',- marginLeft: -25,+ marginLeft: '-25px',lineHeight: '40px',WebkitAppRegion: 'no-drag',} as React.CSSProperties & { WebkitAppRegion?: string }@@ -146,7 +143,7 @@ function CustomLogo() {)}</Badge></Tooltip>- </div>+ </Box>);}diff --git a/src/renderer/components/DirectoryListView.tsx b/src/renderer/components/DirectoryListView.tsxindex 9afde82f0..cb9589e30 100644--- a/src/renderer/components/DirectoryListView.tsx+++ b/src/renderer/components/DirectoryListView.tsx@@ -1,29 +1,36 @@-import React, { useRef, useState, useEffect } from 'react';-import { useSelector } from 'react-redux';+import AppConfig from '-/AppConfig';+import {+ FolderOutlineIcon as FolderIcon,+ NewFolderIcon,+ ParentFolderIcon,+} from '-/components/CommonIcons';+import { useCreateDirectoryDialogContext } from '-/components/dialogs/hooks/useCreateDirectoryDialogContext';import TsButton from '-/components/TsButton';import TsSelect from '-/components/TsSelect';-import MenuItem from '@mui/material/MenuItem';+import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';+import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';+import { getShowUnixHiddenEntries } from '-/reducers/settings';+import { TS } from '-/tagspaces.namespace';+import { CommonLocation } from '-/utils/CommonLocation';+import { Box } from '@mui/material';import FormControl from '@mui/material/FormControl';import List from '@mui/material/List';-import ListItemText from '@mui/material/ListItemText';import ListItem from '@mui/material/ListItem';import ListItemIcon from '@mui/material/ListItemIcon';+import ListItemText from '@mui/material/ListItemText';+import MenuItem from '@mui/material/MenuItem';+import Typography from '@mui/material/Typography';import { locationType } from '@tagspaces/tagspaces-common/misc';import { extractContainingDirectoryPath } from '@tagspaces/tagspaces-common/paths';-import { getShowUnixHiddenEntries } from '-/reducers/settings';-import AppConfig from '-/AppConfig';-import { TS } from '-/tagspaces.namespace';-import {- ParentFolderIcon,- NewFolderIcon,- FolderOutlineIcon as FolderIcon,-} from '-/components/CommonIcons';+import React, {+ useCallback,+ useEffect,+ useMemo,+ useRef,+ useState,+} from 'react';import { useTranslation } from 'react-i18next';-import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';-import Typography from '@mui/material/Typography';-import { CommonLocation } from '-/utils/CommonLocation';-import { useCreateDirectoryDialogContext } from '-/components/dialogs/hooks/useCreateDirectoryDialogContext';-import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';+import { useSelector } from 'react-redux';interface Props {setTargetDir: (dirPath: string) => void;@@ -42,14 +49,44 @@ const DirectoryListView: React.FC<Props> = ({const { currentDirectoryEntries } = useDirectoryContentContext();const { openCreateDirectoryDialog } = useCreateDirectoryDialogContext();const showUnixHiddenEntries: boolean = useSelector(getShowUnixHiddenEntries);+const chosenLocationId = useRef<string>(- targetLocationID ? targetLocationID : currentLocation?.uuid,+ targetLocationID || currentLocation?.uuid,);const chosenDirectory = useRef<string>(targetPath);const [directoryContent, setDirectoryContent] = useState<TS.FileSystemEntry[]>(currentDirectoryEntries.filter((entry) => !entry.isFile));+ // List directory content and filter out unwanted entries+ const listDirectory = useCallback(+ (directoryPath: string) => {+ chosenDirectory.current = directoryPath;+ const location = findLocation(chosenLocationId.current);+ if (!location) return;+ location+ .listDirectoryPromise(directoryPath, [], [])+ .then((results) => {+ if (results !== undefined) {+ setDirectoryContent(+ results.filter(+ (entry) =>+ !entry.isFile &&+ entry.name !== AppConfig.metaFolder &&+ !entry.name.endsWith('/' + AppConfig.metaFolder) &&+ !(!showUnixHiddenEntries && entry.name.startsWith('.')),+ ),+ );+ }+ })+ .catch((error) => {+ console.error('listDirectoryPromise', error);+ });+ },+ [findLocation, showUnixHiddenEntries],+ );++ // On mount, if targetLocationID is different, list its directoryuseEffect(() => {if (targetLocationID && targetLocationID !== currentLocation?.uuid) {const chosenLocation = findLocation(chosenLocationId.current);@@ -57,18 +94,24 @@ const DirectoryListView: React.FC<Props> = ({listDirectory(targetPath);}}+ // eslint-disable-next-line}, []);- const handleLocationChange = (event: React.ChangeEvent<HTMLInputElement>) => {- chosenLocationId.current = event.target.value;- const chosenLocation = findLocation(chosenLocationId.current);- if (chosenLocation) {- listDirectory(chosenLocation.path);- setTargetDir(chosenLocation.path);- }- };+ // Handle location change from dropdown+ const handleLocationChange = useCallback(+ (event: React.ChangeEvent<HTMLInputElement>) => {+ chosenLocationId.current = event.target.value;+ const chosenLocation = findLocation(chosenLocationId.current);+ if (chosenLocation) {+ listDirectory(chosenLocation.path);+ setTargetDir(chosenLocation.path);+ }+ },+ [findLocation, listDirectory, setTargetDir],+ );- function getDirLocations() {+ // Render location selector if local locations are available+ const dirLocations = useMemo(() => {const chosenLocation = findLocation(chosenLocationId.current);if (!chosenLocation || chosenLocation.type !== locationType.TYPE_LOCAL) {return null;@@ -77,17 +120,16 @@ const DirectoryListView: React.FC<Props> = ({<FormControlfullWidthvariant="standard"- style={{+ sx={{flexFlow: 'nowrap',alignItems: 'center',}}>- <Typography style={{ display: 'inline' }} variant="subtitle2">+ <Typography sx={{ display: 'inline' }} variant="subtitle2">{t('targetLocation')}: </Typography><TsSelect- fullWidth={true}- // style={{ display: 'inline' }}+ fullWidthonChange={handleLocationChange}value={chosenLocationId.current}>@@ -95,120 +137,92 @@ const DirectoryListView: React.FC<Props> = ({.filter((loc) => loc.type === locationType.TYPE_LOCAL).map((location: CommonLocation) => (<MenuItem key={location.uuid} value={location.uuid}>- <span style={{ width: '100%' }}>{location.name}</span>+ <Box sx={{ width: '100%' }}>{location.name}</Box></MenuItem>))}</TsSelect></FormControl>);- }+ }, [findLocation, handleLocationChange, locations, t]);- function listDirectory(directoryPath) {- chosenDirectory.current = directoryPath;- findLocation(chosenLocationId.current)- .listDirectoryPromise(- directoryPath,- [], // mode,- [],- )- .then((results) => {- if (results !== undefined) {- setDirectoryContent(- results.filter((entry) => {- return (- !entry.isFile &&- entry.name !== AppConfig.metaFolder &&- !entry.name.endsWith('/' + AppConfig.metaFolder) &&- !(!showUnixHiddenEntries && entry.name.startsWith('.'))- );- }),- // .sort((a, b) => b.name - a.name)- );- // props.setTargetDir(directoryPath);- }- return true;- })- .catch((error) => {- console.log('listDirectoryPromise', error);- });- }-- function getFolderContent() {+ // Render folder content+ const folderContent = useMemo(() => {if (directoryContent && directoryContent.length > 0) {return directoryContent.map((entry) => (<ListItemkey={entry.path}data-tid={'MoveTarget' + entry.name}title={'Navigate to: ' + entry.path}- onClick={() => {- setTargetDir(entry.path);- }}- onDoubleClick={() => {- listDirectory(entry.path);- }}+ onClick={() => setTargetDir(entry.path)}+ onDoubleClick={() => listDirectory(entry.path)}>- <ListItemIcon style={{ minWidth: 35 }}>+ <ListItemIcon sx={{ minWidth: 35 }}><FolderIcon /></ListItemIcon><ListItemText primary={entry.name} /></ListItem>));}- return <div style={{ padding: 10 }}>{t('core:noSubFoldersFound')}</div>;- }+ return <Box sx={{ padding: '10px' }}>{t('core:noSubFoldersFound')}</Box>;+ }, [directoryContent, listDirectory, setTargetDir, t]);++ // Handler for navigating to parent directory+ const handleNavigateParent = useCallback(() => {+ if (chosenDirectory.current) {+ let currentPath = chosenDirectory.current;+ if (currentPath.endsWith(currentLocation?.getDirSeparator())) {+ currentPath = currentPath.slice(0, -1);+ }+ const parentDir = extractContainingDirectoryPath(currentPath);+ listDirectory(parentDir);+ setTargetDir(parentDir);+ }+ }, [currentLocation, listDirectory, setTargetDir]);++ // Handler for creating a new subdirectory+ const handleCreateSubdirectory = useCallback(() => {+ openCreateDirectoryDialog(+ chosenDirectory.current,+ (newDirPath) => {+ listDirectory(chosenDirectory.current);+ setTargetDir(newDirPath);+ },+ true,+ );+ }, [listDirectory, openCreateDirectoryDialog, setTargetDir]);return (- <div style={{ marginTop: 10 }}>- {getDirLocations()}+ <Box sx={{ marginTop: '10px' }}>+ {dirLocations}<TsButtonstartIcon={<ParentFolderIcon />}- style={{ marginTop: 10, marginBottom: 10 }}+ sx={{ marginTop: '10px', marginBottom: '10px' }}data-tid="navigateToParentTID"- onClick={() => {- if (chosenDirectory.current) {- let currentPath = chosenDirectory.current;- if (currentPath.endsWith(currentLocation?.getDirSeparator())) {- currentPath = currentPath.slice(0, -1);- }- const parentDir = extractContainingDirectoryPath(currentPath);- listDirectory(parentDir);- setTargetDir(parentDir);- }- }}+ onClick={handleNavigateParent}>{t('core:navigateToParentDirectory')}</TsButton><TsButtonstartIcon={<NewFolderIcon />}- style={{ marginLeft: 5, marginTop: 10, marginBottom: 10 }}+ sx={{ marginLeft: '5px', marginTop: '10px', marginBottom: '10px' }}data-tid="newSubdirectoryTID"- onClick={() => {- openCreateDirectoryDialog(- chosenDirectory.current,- (newDirPath) => {- listDirectory(chosenDirectory.current);- setTargetDir(newDirPath);- },- true,- );- //reflect: false,- }}+ onClick={handleCreateSubdirectory}>{t('core:newSubdirectory')}</TsButton><Listdense- style={{+ sx={{borderRadius: AppConfig.defaultCSSRadius,border: '1px solid gray',maxHeight: 300,overflowY: 'auto',}}>- {getFolderContent()}+ {folderContent}</List>- </div>+ </Box>);};-export default DirectoryListView;+export default React.memo(DirectoryListView);diff --git a/src/renderer/components/DirectoryTreeView.tsx b/src/renderer/components/DirectoryTreeView.tsxindex ba4ac8934..0a7719693 100644--- a/src/renderer/components/DirectoryTreeView.tsx+++ b/src/renderer/components/DirectoryTreeView.tsx@@ -16,15 +16,7 @@**/-import {- Ref,- forwardRef,- useEffect,- useImperativeHandle,- useState,-} from 'react';import AppConfig from '-/AppConfig';-import { cleanTrailingDirSeparator } from '@tagspaces/tagspaces-common/paths';import { FolderOutlineIcon } from '-/components/CommonIcons';import CustomDragLayer from '-/components/CustomDragLayer';import DragItemTypes from '-/components/DragItemTypes';@@ -35,9 +27,18 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { getShowUnixHiddenEntries } from '-/reducers/settings';import { resolveRelativePath } from '-/services/utils-io';import { TS } from '-/tagspaces.namespace';+import { Box } from '@mui/material';import { alpha, useTheme } from '@mui/material/styles';import { locationType } from '@tagspaces/tagspaces-common/misc';+import { cleanTrailingDirSeparator } from '@tagspaces/tagspaces-common/paths';import Table from 'rc-table';+import {+ Ref,+ forwardRef,+ useEffect,+ useImperativeHandle,+ useState,+} from 'react';import { NativeTypes } from 'react-dnd-html5-backend';import { useSelector } from 'react-redux';@@ -186,17 +187,18 @@ const DirectoryTreeView = forwardRef(const renderNameColumnAction = (field: string) => {const children = (- <span style={{ fontSize: 15 }} title={field}>+ <Box sx={{ fontSize: '15px', display: 'inline-block' }} title={field}><FolderOutlineIcon- style={{+ sx={{marginTop: 0,- marginLeft: 3,- marginRight: 6,- marginBottom: -8,+ marginLeft: '3px',+ marginRight: '6px',+ marginBottom: '-8px',+ display: 'inline-block',}}/>{field.length > 25 ? field.substr(0, 25) + '...' : field}- </span>+ </Box>);return { children, props: {} };};diff --git a/src/renderer/components/EntryProperties.tsx b/src/renderer/components/EntryProperties.tsxindex 97da40b5a..7e5c1c6e9 100644--- a/src/renderer/components/EntryProperties.tsx+++ b/src/renderer/components/EntryProperties.tsx@@ -61,6 +61,7 @@ import {} from '-/services/utils-io';import { TS } from '-/tagspaces.namespace';import { generateClipboardLink } from '-/utils/dom';+import { formatTimestampLocal } from '-/utils/formatLocalTime';import { parseGeoLocation } from '-/utils/geo';import useFirstRender from '-/utils/useFirstRender';import {@@ -85,8 +86,10 @@ import {import L from 'leaflet';import React, {ChangeEvent,+ useCallback,useContext,useEffect,+ useMemo,useReducer,useRef,useState,@@ -102,7 +105,6 @@ import {} from 'react-leaflet';import { useSelector } from 'react-redux';import { Pro } from '../pro';-import { formatTimestampLocal } from '-/utils/formatLocalTime';const ThumbnailTextField = styled(TsTextField)(({ theme }) => ({[`& .${inputBaseClasses.root}`]: {@@ -110,12 +112,8 @@ const ThumbnailTextField = styled(TsTextField)(({ theme }) => ({},}));-/*const ThumbnailChooserDialog =- Pro && Pro.UI ? Pro.UI.ThumbnailChooserDialog : false;*/const CustomBackgroundDialog =Pro && Pro.UI ? Pro.UI.CustomBackgroundDialog : false;-/*const BgndImgChooserDialog =- Pro && Pro.UI ? Pro.UI.BgndImgChooserDialog : false;*/interface Props {tileServer: TS.MapTileServer;@@ -156,7 +154,7 @@ const defaultBackgrounds = ['linear-gradient( 110deg, rgba(48,207,208,1) 11.2%, rgba(51,8,103,1) 90% )',];-function EntryProperties(props: Props) {+function EntryProperties({ tileServer }: Props) {const { t } = useTranslation();const theme = useTheme();const { openedEntry, sharingLink, getOpenedDirProps, fileChanged } =@@ -185,67 +183,69 @@ function EntryProperties(props: Props) {: undefined;const tagDelimiter: string = useSelector(getTagDelimiter);- const dirProps = useRef<TS.DirProp>(undefined);+ const dirProps = useRef<TS.DirProp>();const fileNameRef = useRef<HTMLInputElement>(null);const sharingLinkRef = useRef<HTMLInputElement>(null);const disableConfirmButton = useRef<boolean>(true);const fileNameError = useRef<boolean>(false);- const location = findLocation(openedEntry.locationID);+ const location = findLocation(openedEntry?.locationID);- const entryName = openedEntry- ? openedEntry.isFile+ const entryName = useMemo(() => {+ if (!openedEntry) return '';+ return openedEntry.isFile? extractFileName(openedEntry.path, location?.getDirSeparator())- : extractDirectoryName(openedEntry.path, location?.getDirSeparator())- : '';+ : extractDirectoryName(openedEntry.path, location?.getDirSeparator());+ }, [openedEntry, location]);- const [editName, setEditName] = useState<string>(undefined);- const [showSharingLinkDialog, setShowSharingLinkDialog] =- useState<boolean>(false);- const [displayColorPicker, setDisplayColorPicker] = useState<boolean>(false);+ const [editName, setEditName] = useState<string>();+ const [showSharingLinkDialog, setShowSharingLinkDialog] = useState(false);+ const [displayColorPicker, setDisplayColorPicker] = useState(false);const backgroundImage = useRef<string>('none');const thumbImage = useRef<string>('none');- const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);+ const [, forceUpdate] = useReducer((x) => x + 1, 0);const firstRender = useFirstRender();- const [popoverAnchorEl, setPopoverAnchorEl] =- React.useState<HTMLElement | null>(null);-+ const [popoverAnchorEl, setPopoverAnchorEl] = useState<HTMLElement | null>(+ null,+ );const popoverOpen = Boolean(popoverAnchorEl);const popoverId = popoverOpen ? 'popoverBackground' : undefined;- const handlePopeverClick = (event: React.MouseEvent<HTMLElement>) => {- setPopoverAnchorEl(event.currentTarget);- };-- const handlePopoverClose = () => {- setPopoverAnchorEl(null);- };+ const handlePopoverClick = useCallback(+ (event: React.MouseEvent<HTMLElement>) => {+ setPopoverAnchorEl(event.currentTarget);+ },+ [],+ );+ const handlePopoverClose = useCallback(() => setPopoverAnchorEl(null), []);useEffect(() => {reloadBackground();reloadThumbnails();- }, [openedEntry]); //location]);+ // eslint-disable-next-line+ }, [openedEntry]);useEffect(() => {if (!firstRender && metaActions && metaActions.length > 0 && openedEntry) {for (const action of metaActions) {if (action.action === 'bgdImgChange') {- reloadBackground(); //todo rethink this duplicate from openedEntry changes+ reloadBackground();} else if (action.action === 'thumbChange') {reloadThumbnails();}}}+ // eslint-disable-next-line}, [metaActions, openedEntry]);function reloadBackground() {- if (location) {+ if (location && openedEntry) {location.getFolderBgndPath(openedEntry.path, openedEntry.meta?.lastUpdated).then((bgPath) => {- const bgImage = bgPath ? 'url("' + bgPath + '")' : 'none';+ const bgImage = bgPath ? `url("${bgPath}")` : 'none';if (bgImage !== backgroundImage.current) {backgroundImage.current = bgImage;forceUpdate();@@ -255,7 +255,7 @@ function EntryProperties(props: Props) {}function reloadThumbnails() {- if (location) {+ if (location && openedEntry) {location.getThumbPath(openedEntry.meta?.thumbPath,@@ -263,7 +263,7 @@ function EntryProperties(props: Props) {).then((thumbPath) => {const thbImage = thumbPath- ? 'url("' + thumbPath.replace(/#/g, '%23') + '")'+ ? `url("${thumbPath.replace(/#/g, '%23')}")`: 'none';if (thbImage !== thumbImage.current) {thumbImage.current = thbImage;@@ -277,10 +277,10 @@ function EntryProperties(props: Props) {if (editName === entryName && fileNameRef.current) {fileNameRef.current.focus();}- }, [editName]);+ }, [editName, entryName]);- const renameEntry = () => {- if (editName !== undefined) {+ const renameEntry = useCallback(() => {+ if (editName !== undefined && openedEntry) {const dirSeparator = location?.getDirSeparator();const path = extractContainingDirectoryPath(openedEntry.path,@@ -292,7 +292,7 @@ function EntryProperties(props: Props) {if (openedEntry.isFile) {renameFile(openedEntry.path, nextPath, openedEntry.locationID).catch(() => {- fileNameRef.current.value = entryName;+ if (fileNameRef.current) fileNameRef.current.value = entryName;},);} else {@@ -301,43 +301,43 @@ function EntryProperties(props: Props) {editName,openedEntry.locationID,).catch(() => {- fileNameRef.current.value = entryName;+ if (fileNameRef.current) fileNameRef.current.value = entryName;});}-setEditName(undefined);}- };+ }, [editName, openedEntry, location, entryName, renameFile, renameDirectory]);- const activateEditNameField = () => {- if (location.isReadOnly) {+ const activateEditNameField = useCallback(() => {+ if (location?.isReadOnly) {setEditName(undefined);return;}setEditName(entryName);- };+ }, [location, entryName]);- const deactivateEditNameField = () => {+ const deactivateEditNameField = useCallback(() => {setEditName(undefined);fileNameError.current = false;- if (fileNameRef) {+ if (fileNameRef.current) {fileNameRef.current.value = entryName;}- };+ }, [entryName]);- const toggleMoveCopyFilesDialog = () => {- openMoveCopyFilesDialog([- {- ...openedEntry,- isFile: openedEntry.isFile,- name: entryName,- tags: [],- },- ]);- //setMoveCopyFilesDialogOpened(!isMoveCopyFilesDialogOpened);- };+ const toggleMoveCopyFilesDialog = useCallback(() => {+ if (openedEntry) {+ openMoveCopyFilesDialog([+ {+ ...openedEntry,+ isFile: openedEntry.isFile,+ name: entryName,+ tags: [],+ },+ ]);+ }+ }, [openMoveCopyFilesDialog, openedEntry, entryName]);- const openThumbFilesDialog = () => {+ const openThumbFilesDialog = useCallback(() => {if (!Pro) {showNotification(t('core:thisFunctionalityIsAvailableInPro'));return true;@@ -345,143 +345,168 @@ function EntryProperties(props: Props) {if (!isEditMode && editName === undefined && thumbDialogContext) {thumbDialogContext.openThumbsDialog(openedEntry);}- };+ }, [+ Pro,+ showNotification,+ t,+ isEditMode,+ editName,+ thumbDialogContext,+ openedEntry,+ ]);- const openBgndImgDialog = () => {+ const openBgndImgDialog = useCallback(() => {if (!Pro) {showNotification(t('core:thisFunctionalityIsAvailableInPro'));return true;}- if (!isEditMode && editName === undefined) {+ if (!isEditMode && editName === undefined && bgndDialogContext) {bgndDialogContext.openBgndDialog(openedEntry);}- };+ }, [+ Pro,+ showNotification,+ t,+ isEditMode,+ editName,+ bgndDialogContext,+ openedEntry,+ ]);- const fileSize = () => {- if (openedEntry.isFile) {+ const fileSize = useCallback(() => {+ if (openedEntry?.isFile) {return formatBytes(openedEntry.size);} else if (dirProps.current) {return formatBytes(dirProps.current.totalSize);}return t(location?.haveObjectStoreSupport() ? 'core:notAvailable' : '?');- };+ }, [openedEntry, t, location]);- const toggleBackgroundColorPicker = () => {- if (location.isReadOnly) {- return;- }+ const toggleBackgroundColorPicker = useCallback(() => {+ if (location?.isReadOnly) return;if (!Pro) {showNotification(t('core:thisFunctionalityIsAvailableInPro'));return;}- setDisplayColorPicker(!displayColorPicker);- };+ setDisplayColorPicker((prev) => !prev);+ }, [location, Pro, showNotification, t]);- const handleChangeColor = (color) => {- if (color === 'transparent0') {- // eslint-disable-next-line no-param-reassign- color = 'transparent';- }- //openedEntry.color = color;- setBackgroundColorChange(openedEntry, color).then((success) => {- if (success) {- openedEntry.meta = { ...openedEntry.meta, color };- }- });- };-- const handleFileNameChange = (event: ChangeEvent<HTMLInputElement>) => {- const { target } = event;- const { value, name } = target;+ const handleChangeColor = useCallback(+ (color) => {+ if (color === 'transparent0') color = 'transparent';+ setBackgroundColorChange(openedEntry, color).then((success) => {+ if (success && openedEntry) {+ openedEntry.meta = { ...openedEntry.meta, color };+ }+ });+ },+ [openedEntry, setBackgroundColorChange],+ );- if (name === 'name') {- const initValid = disableConfirmButton.current;- let noValid;- if (openedEntry.isFile) {- noValid = fileNameValidation(value);- } else {- noValid = dirNameValidation(value);- }- disableConfirmButton.current = noValid;- if (noValid || initValid !== noValid) {- fileNameError.current = noValid;+ const handleFileNameChange = useCallback(+ (event: ChangeEvent<HTMLInputElement>) => {+ const { value, name } = event.target;+ if (name === 'name') {+ const initValid = disableConfirmButton.current;+ let noValid;+ if (openedEntry.isFile) {+ noValid = fileNameValidation(value);+ } else {+ noValid = dirNameValidation(value);+ }+ disableConfirmButton.current = noValid;+ if (noValid || initValid !== noValid) {+ fileNameError.current = noValid;+ }+ setEditName(value);}- setEditName(value);- }- };+ },+ [openedEntry],+ );- const handleChange = (name: string, value: Array<TS.Tag>, action: string) => {- if (openedEntry && fileChanged) {- showNotification(- `You can't edit tags, because '${openedEntry.path}' is opened for editing`,- 'default',- true,- );- return;- }- if (action === 'remove-value') {- if (!value) {- // no tags left in the select element+ const handleChange = useCallback(+ (name: string, value: Array<TS.Tag>, action: string) => {+ if (openedEntry && fileChanged) {+ showNotification(+ `You can't edit tags, because '${openedEntry.path}' is opened for editing`,+ 'default',+ true,+ );+ return;+ }+ if (action === 'remove-value') {+ if (!value) {+ return removeTagsFromEntry(openedEntry);+ } else {+ return removeTagsFromEntry(openedEntry, value);+ }+ } else if (action === 'clear') {return removeTagsFromEntry(openedEntry);- } else {- return removeTagsFromEntry(openedEntry, value);}- } else if (action === 'clear') {- return removeTagsFromEntry(openedEntry);- }- // create-option or select-option- const tags =- openedEntry.tags === undefined- ? value- : value.filter(- (tag) => !openedEntry.tags.some((obj) => obj.title === tag.title),- );- return addTagsToFsEntry(openedEntry, tags);- };+ // create-option or select-option+ const tags =+ openedEntry.tags === undefined+ ? value+ : value.filter(+ (tag) => !openedEntry.tags.some((obj) => obj.title === tag.title),+ );+ return addTagsToFsEntry(openedEntry, tags);+ },+ [+ openedEntry,+ fileChanged,+ showNotification,+ removeTagsFromEntry,+ addTagsToFsEntry,+ ],+ );if (!openedEntry || !openedEntry.path || openedEntry.path === '') {return <div />;}const ldtm = openedEntry.lmdt ? formatTimestampLocal(openedEntry.lmdt) : ' ';-const cdt = openedEntry.cdt? formatTimestampLocal(openedEntry.cdt): undefined;- const changePerspective = (event: any) => {- const perspective = event.target.value;- openedEntry.meta = {- ...(openedEntry.meta && openedEntry.meta),- perspective,- };- saveDirectoryPerspective(openedEntry, perspective, openedEntry.locationID);- };+ const changePerspective = useCallback(+ (event: any) => {+ const perspective = event.target.value;+ openedEntry.meta = {+ ...(openedEntry.meta && openedEntry.meta),+ perspective,+ };+ saveDirectoryPerspective(+ openedEntry,+ perspective,+ openedEntry.locationID,+ );+ },+ [openedEntry, saveDirectoryPerspective],+ );- let perspectiveDefault;- if (openedEntry.meta && openedEntry.meta.perspective) {- perspectiveDefault = openedEntry.meta.perspective; // props.perspective;- } else {- perspectiveDefault = 'unspecified'; // perspectives.DEFAULT;- }+ let perspectiveDefault = openedEntry.meta?.perspective || 'unspecified';// https://github.com/Leaflet/Leaflet/blob/main/src/layer/marker/Icon.Default.js#L22- const iconFileMarker = new L.Icon({- iconUrl: MarkerIcon,- iconRetinaUrl: Marker2xIcon,- shadowUrl: MarkerShadowIcon,- tooltipAnchor: [16, -28],- iconSize: [25, 41], // size of the icon- shadowSize: [41, 41], // size of the shadow- iconAnchor: [12, 41], // point of the icon which will correspond to marker's location- shadowAnchor: [5, 41], // the same for the shadow- popupAnchor: [1, -34], // point from which the popup should open relative to the iconAnchor- });+ const iconFileMarker = useMemo(+ () =>+ new L.Icon({+ iconUrl: MarkerIcon,+ iconRetinaUrl: Marker2xIcon,+ shadowUrl: MarkerShadowIcon,+ tooltipAnchor: [16, -28],+ iconSize: [25, 41],+ shadowSize: [41, 41],+ iconAnchor: [12, 41], // point of the icon which will correspond to marker's location+ shadowAnchor: [5, 41],+ popupAnchor: [1, -34], // point from which the popup should open relative to the iconAnchor+ }),+ [],+ );function getGeoLocation(tags: Array<TS.Tag>) {- if (!Pro) {- return;- }+ if (!Pro) return;if (tags) {for (let i = 0; i < tags.length; i += 1) {const location = parseGeoLocation(tags[i].title);@@ -497,10 +522,10 @@ function EntryProperties(props: Props) {);const isCloudLocation = openedEntry.url && openedEntry.url.length > 5;-const showLinkForDownloading =isCloudLocation && openedEntry.isFile && !openedEntry.isEncrypted;+ // --- RENDER ---return (<div><Grid container>@@ -517,9 +542,9 @@ function EntryProperties(props: Props) {endAdornment: (<InputAdornment position="end">{!location.isReadOnly && !isEditMode && (- <div style={{ textAlign: 'right' }}>+ <Box sx={{ textAlign: 'right' }}>{editName !== undefined ? (- <div>+ <><TsButtondata-tid="cancelRenameEntryTID"onClick={deactivateEditNameField}@@ -535,7 +560,7 @@ function EntryProperties(props: Props) {>{t('core:confirmSaveButton')}</TsButton>- </div>+ </>) : (<TsButtondata-tid="startRenameEntryTID"@@ -545,7 +570,7 @@ function EntryProperties(props: Props) {{t('core:rename')}</TsButton>)}- </div>+ </Box>)}</InputAdornment>),@@ -602,7 +627,6 @@ function EntryProperties(props: Props) {margin: 2,marginTop: 8,borderRadius: AppConfig.defaultCSSRadius,- // border: '1px solid rgba(0, 0, 0, 0.38)',}}doubleClickZoom={true}keyboard={false}@@ -613,10 +637,10 @@ function EntryProperties(props: Props) {zoomControl={true}attributionControl={false}>- {props.tileServer ? (+ {tileServer ? (<TileLayer- attribution={props.tileServer.serverInfo}- url={props.tileServer.serverURL}+ attribution={tileServer.serverInfo}+ url={tileServer.serverURL}/>) : (<NoTileServer />@@ -628,7 +652,7 @@ function EntryProperties(props: Props) {><Popup><Typography- style={{ margin: 0, color: theme.palette.text.primary }}+ sx={{ margin: 0, color: theme.palette.text.primary }}>{t('core:lat') + ' : ' + geoLocation.lat}<br />@@ -656,7 +680,7 @@ function EntryProperties(props: Props) {OpenStreetMap</TsButton><TsButton- style={{+ sx={{marginLeft: AppConfig.defaultSpaceBetweenButtons,}}onClick={() => {@@ -788,11 +812,11 @@ function EntryProperties(props: Props) {<InputAdornment position="start">{isCloudLocation ? (<CloudLocationIcon- style={{ color: theme.palette.text.secondary }}+ sx={{ color: theme.palette.text.secondary }}/>) : (<LocalLocationIcon- style={{ color: theme.palette.text.secondary }}+ sx={{ color: theme.palette.text.secondary }}/>)}</InputAdornment>@@ -906,7 +930,7 @@ function EntryProperties(props: Props) {</Grid>)}{!openedEntry.isFile && (- <Grid size={12} style={{ marginTop: 5 }}>+ <Grid size={12} sx={{ marginTop: '5px' }}><TsTextFieldname="path"label={<>{t('core:backgroundColor')}</>}@@ -919,7 +943,7 @@ function EntryProperties(props: Props) {<TsButtontooltip={t('editBackgroundColor')}fullWidth- style={{+ sx={{width: 160,height: 25,background: openedEntry.meta?.color,@@ -939,7 +963,7 @@ function EntryProperties(props: Props) {<TsIconButtondata-tid="changeBackgroundColorTID"aria-describedby={popoverId}- onClick={handlePopeverClick}+ onClick={handlePopoverClick}disabled={!Pro}><ColorPaletteIcon />@@ -959,7 +983,7 @@ function EntryProperties(props: Props) {horizontal: 'center',}}>- <Box style={{ padding: 10 }}>+ <Box sx={{ padding: '10px' }}>{defaultBackgrounds.map((background, cnt) => (<><TsIconButton@@ -970,10 +994,10 @@ function EntryProperties(props: Props) {handleChangeColor(background);handlePopoverClose();}}- style={{+ sx={{backgroundColor: background,backgroundImage: background,- margin: 5,+ margin: '5px',}}><SetColorIcon />@@ -1025,7 +1049,7 @@ function EntryProperties(props: Props) {<ThumbnailTextFieldmargin="dense"variant="outlined"- style={{ marginTop: 0 }}+ sx={{ marginTop: 0 }}fullWidthslotProps={{input: {@@ -1035,7 +1059,7 @@ function EntryProperties(props: Props) {<Stackdirection="column"spacing={0}- style={{ alignItems: 'center' }}+ sx={{ alignItems: 'center' }}>{!location.isReadOnly &&!isEditMode &&@@ -1051,10 +1075,10 @@ function EntryProperties(props: Props) {</TsButton></ProTooltip>)}- <div+ <Boxrole="button"tabIndex={0}- style={{+ sx={{backgroundSize: 'cover',backgroundRepeat: 'no-repeat',backgroundImage: thumbImage.current,@@ -1062,7 +1086,7 @@ function EntryProperties(props: Props) {borderRadius: AppConfig.defaultCSSRadius,minHeight: 150,minWidth: 150,- marginBottom: 5,+ marginBottom: '5px',}}onClick={openThumbFilesDialog}/>@@ -1079,7 +1103,7 @@ function EntryProperties(props: Props) {<ThumbnailTextFieldmargin="dense"fullWidth- style={{+ sx={{marginTop: 0,}}variant="outlined"@@ -1091,7 +1115,7 @@ function EntryProperties(props: Props) {<Stackdirection="column"spacing={0}- style={{ alignItems: 'center' }}+ sx={{ alignItems: 'center' }}>{!location.isReadOnly &&!isEditMode &&@@ -1107,11 +1131,11 @@ function EntryProperties(props: Props) {</TsButton></ProTooltip>)}- <div+ <Boxdata-tid="propsBgnImageTID"role="button"tabIndex={0}- style={{+ sx={{backgroundSize: 'cover',backgroundRepeat: 'no-repeat',backgroundImage: backgroundImage.current,@@ -1119,7 +1143,7 @@ function EntryProperties(props: Props) {borderRadius: AppConfig.defaultCSSRadius,minHeight: 150,minWidth: 150,- marginBottom: 5,+ marginBottom: '5px',}}onClick={openBgndImgDialog}/>@@ -1196,4 +1220,4 @@ function EntryProperties(props: Props) {);}-export default EntryProperties;+export default React.memo(EntryProperties);diff --git a/src/renderer/components/FolderContainer.tsx b/src/renderer/components/FolderContainer.tsxindex 7bd9f6ad8..ffc3d1407 100644--- a/src/renderer/components/FolderContainer.tsx+++ b/src/renderer/components/FolderContainer.tsx@@ -17,11 +17,14 @@*/import AppConfig from '-/AppConfig';+import { BetaLabel } from '-/components/HelperComponents';+import PathBreadcrumbs from '-/components/PathBreadcrumbs';import RenderPerspective from '-/components/RenderPerspective';import SearchBox from '-/components/SearchBox';import Tooltip from '-/components/Tooltip';import TsButton from '-/components/TsButton';import TsIconButton from '-/components/TsIconButton';+import TsMenuList from '-/components/TsMenuList';import { AIProvider } from '-/components/chat/ChatTypes';import { adjustKeyBinding } from '-/components/dialogs/KeyboardDialog';import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';@@ -49,7 +52,7 @@ import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';import Typography from '@mui/material/Typography';import { useTheme } from '@mui/material/styles';import useMediaQuery from '@mui/material/useMediaQuery';-import { useState } from 'react';+import React, { useCallback, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';import { useSelector } from 'react-redux';import {@@ -59,19 +62,15 @@ import {MainMenuIcon,SearchIcon,} from './CommonIcons';-import { BetaLabel } from './HelperComponents';-import PathBreadcrumbs from './PathBreadcrumbs';-import TsMenuList from './TsMenuList';interface Props {toggleDrawer?: () => void;drawerOpened: boolean;- style?: any;+ hidden?: boolean;}-function FolderContainer(props: Props) {+function FolderContainer({ toggleDrawer, drawerOpened, hidden }: Props) {const devMode: boolean = useSelector(isDevMode);- const { toggleDrawer, drawerOpened, style } = props;const { t } = useTranslation();const theme = useTheme();const keyBindings = useSelector(getKeyBindingObject);@@ -95,19 +94,22 @@ function FolderContainer(props: Props) {const [perspectiveMenuAnchorEl, setPerspectiveMenuAnchorEl] =useState<null | HTMLElement>(null);- const open = Boolean(perspectiveMenuAnchorEl);- const perspectiveMenuOpenClick = (event: React.MouseEvent<HTMLElement>) => {- setPerspectiveMenuAnchorEl(event.currentTarget);- };- const handlePerspectiveMenuClose = () => {- setPerspectiveMenuAnchorEl(null);- };++ const openPerspectiveMenu = useCallback(+ (event: React.MouseEvent<HTMLElement>) =>+ setPerspectiveMenuAnchorEl(event.currentTarget),+ [],+ );+ const handlePerspectiveMenuClose = useCallback(+ () => setPerspectiveMenuAnchorEl(null),+ [],+ );const showWelcomePanel =!currentDirectoryPath && currentDirectoryEntries.length < 1;- function CircularProgressWithLabel(prop) {- return (+ const CircularProgressWithLabel = useCallback(+ (prop: { value: number }) => (<Box position="relative" display="inline-flex"><CircularProgress size={24} variant="determinate" {...prop} /><Box@@ -123,155 +125,155 @@ function FolderContainer(props: Props) {<Typographyvariant="caption"component="div"- style={{ color: theme.palette.text.primary, fontSize: 8 }}+ sx={{ color: theme.palette.text.primary, fontSize: '8px' }}>{`${prop.value}%`}</Typography></Box></Box>- );- }+ ),+ [theme.palette.text.primary],+ );- const getProgressValue = () => {+ const getProgressValue = useCallback(() => {const objProgress = progress.find((fileProgress) =>fileProgress.progress < 100 && fileProgress.progress > -1,);- if (objProgress !== undefined) {- return objProgress.progress;- }- return 100;- };+ return objProgress ? objProgress.progress : 100;+ }, [progress]);- const switchPerspective = (perspectiveId: string) => {- if (- Pro ||- perspectiveId === PerspectiveIDs.GRID ||- perspectiveId === PerspectiveIDs.LIST- ) {- setManualDirectoryPerspective(perspectiveId);- } else if (perspectiveId === PerspectiveIDs.GALLERY) {- openProTeaserDialog(PerspectiveIDs.GALLERY);- } else if (perspectiveId === PerspectiveIDs.MAPIQUE) {- openProTeaserDialog(PerspectiveIDs.MAPIQUE);- } else if (perspectiveId === PerspectiveIDs.KANBAN) {- openProTeaserDialog(PerspectiveIDs.KANBAN);- } else if (perspectiveId === PerspectiveIDs.FOLDERVIZ) {- openProTeaserDialog(PerspectiveIDs.FOLDERVIZ);- }- };+ const switchPerspective = useCallback(+ (perspectiveId: string) => {+ if (+ Pro ||+ perspectiveId === PerspectiveIDs.GRID ||+ perspectiveId === PerspectiveIDs.LIST+ ) {+ setManualDirectoryPerspective(perspectiveId);+ } else if (+ [+ PerspectiveIDs.GALLERY,+ PerspectiveIDs.MAPIQUE,+ PerspectiveIDs.KANBAN,+ PerspectiveIDs.FOLDERVIZ,+ ].includes(perspectiveId)+ ) {+ openProTeaserDialog(perspectiveId);+ }+ },+ [setManualDirectoryPerspective, openProTeaserDialog],+ );- const perspectiveToggleButtons = [];- AvailablePerspectives.forEach((perspective) => {- if (!devMode && perspective.id === PerspectiveIDs.CALENDAR) {- return;- }- perspectiveToggleButtons.push(- <ToggleButton- value={perspective.id}- aria-label={perspective.id}- key={perspective.id}- data-tid={perspective.key}- onClick={() => switchPerspective(perspective.id)}- style={{- opacity: 0.9,- backgroundColor: theme.palette.background.default,- borderColor: theme.palette.divider,- }}- >- <Tooltip- title={- perspective.title +- (perspective.beta ? ' ' + t('core:betaStatus').toUpperCase() : '')- }+ const perspectiveToggleButtons = useMemo(+ () =>+ AvailablePerspectives.filter(+ (perspective) => devMode || perspective.id !== PerspectiveIDs.CALENDAR,+ ).map((perspective) => (+ <ToggleButton+ value={perspective.id}+ aria-label={perspective.id}+ key={perspective.id}+ data-tid={perspective.key}+ onClick={() => switchPerspective(perspective.id)}+ style={{+ opacity: 0.9,+ backgroundColor: theme.palette.background.default,+ borderColor: theme.palette.divider,+ }}>- <div style={{ display: 'flex' }}>{perspective.icon}</div>- </Tooltip>- </ToggleButton>,- );- });+ <Tooltip+ title={+ perspective.title ++ (perspective.beta ? ' ' + t('core:betaStatus').toUpperCase() : '')+ }+ >+ <Box sx={{ display: 'flex' }}>{perspective.icon}</Box>+ </Tooltip>+ </ToggleButton>+ )),+ [+ devMode,+ switchPerspective,+ theme.palette.background.default,+ theme.palette.divider,+ t,+ ],+ );- const openSearchMode = () => {- // setSearchQuery({ textQuery: '' });+ const openSearchMode = useCallback(() => {enterSearchMode();- };+ }, [enterSearchMode]);- const openSearchKeyBinding = `${adjustKeyBinding(keyBindings.openSearch)}`;+ const openSearchKeyBinding = useMemo(+ () => `${adjustKeyBinding(keyBindings.openSearch)}`,+ [keyBindings.openSearch],+ );const smallScreen = useMediaQuery(theme.breakpoints.down('md'));const readOnlyLocation = findLocation()?.isReadOnly;- const perspectiveMenuItem = [];- AvailablePerspectives.forEach((perspective) => {- let badge = <></>;- // if (!Pro && perspective.pro) {- // badge = <ProLabel />;- // }- if (perspective.beta) {- badge = <BetaLabel />;- }- if (!devMode && perspective.id === PerspectiveIDs.CALENDAR) {- return;- }- perspectiveMenuItem.push(- <MenuItem- key={perspective.key}- data-tid={perspective.key}- onClick={() => {- handlePerspectiveMenuClose();- switchPerspective(perspective.id);- }}- >- <ListItemIcon>{perspective.icon}</ListItemIcon>- <ListItemText- primary={- <>- {perspective.title}- {badge}- </>- }- />- </MenuItem>,- );- });+ const perspectiveMenuItems = useMemo(+ () =>+ AvailablePerspectives.filter(+ (perspective) => devMode || perspective.id !== PerspectiveIDs.CALENDAR,+ ).map((perspective) => {+ let badge = perspective.beta ? <BetaLabel /> : null;+ return (+ <MenuItem+ key={perspective.key}+ data-tid={perspective.key}+ onClick={() => {+ handlePerspectiveMenuClose();+ switchPerspective(perspective.id);+ }}+ >+ <ListItemIcon>{perspective.icon}</ListItemIcon>+ <ListItemText+ primary={+ <>+ {perspective.title}+ {badge}+ </>+ }+ />+ </MenuItem>+ );+ }),+ [devMode, handlePerspectiveMenuClose, switchPerspective],+ );return (- <div- style={{+ <Box+ sx={{width: '100%',+ display: hidden ? 'none' : 'flex',height: 'calc(100% - 50px)',backgroundColor: theme.palette.background.default,- display: 'flex',flexDirection: 'column',position: 'relative',- ...style,}}data-tid="folderContainerTID">- <div- style={{- paddingLeft: 5,- paddingRight: 5,+ <Box+ sx={{+ paddingLeft: '5px',+ paddingRight: '5px',display: 'flex',alignItems: 'center',minHeight: 50,- // @ts-ignoreWebkitAppRegion: 'drag',marginLeft:AppConfig.isMacLike &&isDesktopMode &&!AppConfig.isWeb &&!drawerOpened- ? 60+ ? '60px': 0,}}><TsIconButtonid="mobileMenuButton"- style={- {- WebkitAppRegion: 'no-drag',- } as React.CSSProperties & { WebkitAppRegion?: string }- }+ sx={{ WebkitAppRegion: 'no-drag' } as React.CSSProperties}onClick={toggleDrawer}tooltip={t('core:toggleSidebar')}>@@ -284,11 +286,7 @@ function FolderContainer(props: Props) {id="goBackButton"disabled={historyIndex === 0}onClick={goBack}- style={- {- WebkitAppRegion: 'no-drag',- } as React.CSSProperties & { WebkitAppRegion?: string }- }+ sx={{ WebkitAppRegion: 'no-drag' } as React.CSSProperties}><GoBackIcon /></TsIconButton>@@ -298,22 +296,17 @@ function FolderContainer(props: Props) {id="goForwardButton"disabled={historyIndex === 0}onClick={goForward}- style={- {- WebkitAppRegion: 'no-drag',- } as React.CSSProperties & { WebkitAppRegion?: string }- }+ sx={{ WebkitAppRegion: 'no-drag' } as React.CSSProperties}><GoForwardIcon /></TsIconButton>)}{isSearchMode ? (- /* todo rethink if open props is needed */<SearchBox />) : (<>- <div- style={{+ <Box+ sx={{margin: '0 10px 0 10px',flex: '1 1 1%',display: 'flex',@@ -327,11 +320,11 @@ function FolderContainer(props: Props) {}data-tid="toggleSearch"onClick={openSearchMode}- style={+ sx={{maxWidth: 100,WebkitAppRegion: 'no-drag',- } as React.CSSProperties & { WebkitAppRegion?: string }+ } as React.CSSProperties}><SearchIcon />@@ -342,10 +335,10 @@ function FolderContainer(props: Props) {onClick={openSearchMode}color="secondary"startIcon={<SearchIcon />}- style={+ sx={{- marginTop: -2,- marginRight: 5,+ marginTop: '-2px',+ marginRight: '5px',minWidth: 100,maxHeight: 32,width: 'stretch',@@ -354,29 +347,28 @@ function FolderContainer(props: Props) {whiteSpace: 'nowrap',overflow: 'hidden',WebkitAppRegion: 'no-drag',- } as React.CSSProperties & { WebkitAppRegion?: string }+ } as React.CSSProperties}>{t('core:searchTitle')}- <span style={{ width: 10 }} />+ <Box sx={{ width: 10 }} />{openSearchKeyBinding}</TsButton>)}- </div>-+ </Box>{progress?.length > 0 && (<TsIconButtonid="progressButton"title={t('core:progress')}data-tid="uploadProgress"onClick={() => openFileUploadDialog()}- style={+ sx={{position: 'relative',padding: '8px 12px 6px 8px',- margin: '0',+ margin: 0,WebkitAppRegion: 'no-drag',- } as React.CSSProperties & { WebkitAppRegion?: string }+ } as React.CSSProperties}><CircularProgressWithLabel value={getProgressValue()} />@@ -388,12 +380,12 @@ function FolderContainer(props: Props) {/></>)}- </div>- <div style={{ minHeight: '100%', width: '100%', overflowY: 'auto' }}>+ </Box>+ <Box sx={{ minHeight: '100%', width: '100%', overflowY: 'auto' }}>{/* eslint-disable-next-line jsx-a11y/anchor-has-content,jsx-a11y/anchor-is-valid */}<a href="#" id="downloadFile" /><RenderPerspective />- </div>+ </Box>{isDesktopMode ? (<ToggleButtonGroupvalue={currentPerspective}@@ -402,11 +394,10 @@ function FolderContainer(props: Props) {disabled={showWelcomePanel}aria-label="change perspective"exclusive- style={{+ sx={{bottom: -35,right: 15,zIndex: 1000,- // opacity: 0.9,position: 'absolute',}}>@@ -421,15 +412,14 @@ function FolderContainer(props: Props) {><ToggleButtonvalue=""- // disabled={readOnlyLocation}aria-label="chat-label"data-tid="chatTID"style={{- marginLeft: 5,+ marginLeft: '5px',borderColor: theme.palette.divider,- ...(!readOnlyLocation && {- color: theme.palette.primary.main,- }),+ ...(readOnlyLocation+ ? {}+ : { color: theme.palette.primary.main }),backgroundColor: theme.palette.background.default,}}onClick={() => {@@ -448,12 +438,12 @@ function FolderContainer(props: Props) {size="medium"color="secondary"aria-label="add"- style={{+ sx={{bottom: -30,right: 20,position: 'absolute',}}- onClick={perspectiveMenuOpenClick}+ onClick={openPerspectiveMenu}><BlurOnIcon /></Fab>@@ -461,7 +451,7 @@ function FolderContainer(props: Props) {id="demo-positioned-menu"aria-labelledby="demo-positioned-button"anchorEl={perspectiveMenuAnchorEl}- open={open}+ open={Boolean(perspectiveMenuAnchorEl)}onClose={handlePerspectiveMenuClose}anchorOrigin={{vertical: 'top',@@ -472,12 +462,12 @@ function FolderContainer(props: Props) {horizontal: 'center',}}>- <TsMenuList>{perspectiveMenuItem}</TsMenuList>+ <TsMenuList>{perspectiveMenuItems}</TsMenuList></Menu></>)}- </div>+ </Box>);}-export default FolderContainer;+export default React.memo(FolderContainer);diff --git a/src/renderer/components/LocationView.tsx b/src/renderer/components/LocationView.tsxindex 3cd69d1dd..b17beba5e 100644--- a/src/renderer/components/LocationView.tsx+++ b/src/renderer/components/LocationView.tsx@@ -50,7 +50,7 @@ import ListItemIcon from '@mui/material/ListItemIcon';import Typography from '@mui/material/Typography';import { useTheme } from '@mui/material/styles';import { locationType } from '@tagspaces/tagspaces-common/misc';-import React, { useRef } from 'react';+import React, { useCallback, useMemo, useRef } from 'react';import { NativeTypes } from 'react-dnd-html5-backend';import { useTranslation } from 'react-i18next';import { useDispatch } from 'react-redux';@@ -66,6 +66,9 @@ interface Props {function LocationView(props: Props) {const { t } = useTranslation();+ const theme = useTheme();++ const dispatch: AppDispatch = useDispatch();const { uploadFilesAPI, uploadMeta } = useIOActionsContext();const { setMetaUpload } = useFileUploadContext();@@ -83,25 +86,25 @@ function LocationView(props: Props) {const { setSelectedEntries, selectedEntries } = useSelectedEntriesContext();const { currentLocationPath, openDirectory } = useDirectoryContentContext();const { showNotification } = useNotificationContext();+const directoryTreeRef = useRef<DirectoryTreeViewRef>(null);- const theme = useTheme();- const dispatch: AppDispatch = useDispatch();const { location, hideDrawer, workspace } = props;const subFolderLocation = findLocation(location.locationID);const isCloudLocation = subFolderLocation?.type === locationType.TYPE_CLOUD;- const handleLocationIconClick = (- event: React.MouseEvent<HTMLSpanElement, MouseEvent>,- ) => {- event.preventDefault();- event.stopPropagation();- if (directoryTreeRef.current) {- directoryTreeRef.current.changeLocation(location);- }- };+ const handleLocationIconClick = useCallback(+ (event: React.MouseEvent<HTMLSpanElement, MouseEvent>) => {+ event.preventDefault();+ event.stopPropagation();+ if (directoryTreeRef.current) {+ directoryTreeRef.current.changeLocation(location);+ }+ },+ [location],+ );- const handleLocationClick = () => {+ const handleLocationClick = useCallback(() => {if (currentLocation && location.locationID === currentLocation.uuid) {// the same location clickopenDirectory(currentLocationPath).then(() => {@@ -114,119 +117,149 @@ function LocationView(props: Props) {hideDrawer();}}- };+ }, [+ currentLocation,+ location,+ openDirectory,+ currentLocationPath,+ setActions,+ openLocation,+ subFolderLocation,+ hideDrawer,+ ]);- const handleLocationContextMenuClick = (- event: any,- chosenLocation: CommonLocation,- ) => {- event.preventDefault();- event.stopPropagation();- setSelectedLocation(chosenLocation);- setLocationDirectoryContextMenuAnchorEl(event.currentTarget);- };+ const handleLocationContextMenuClick = useCallback(+ (event: any, chosenLocation: CommonLocation) => {+ event.preventDefault();+ event.stopPropagation();+ setSelectedLocation(chosenLocation);+ setLocationDirectoryContextMenuAnchorEl(event.currentTarget);+ },+ [setSelectedLocation, setLocationDirectoryContextMenuAnchorEl],+ );- const onUploadProgress = (progress, response) => {- dispatch(AppActions.onUploadProgress(progress, response));- };+ const onUploadProgress = useCallback(+ (progress, response) => {+ dispatch(AppActions.onUploadProgress(progress, response));+ },+ [dispatch],+ );/*** https://github.com/react-component/table/blob/master/examples/react-dnd.js* @param item* @param monitor*/- const handleFileMoveDrop = (item, monitor) => {- if (item) {- const { entry } = item;- let arrFiles: TS.FileSystemEntry[] = [];- if (- selectedEntries &&- selectedEntries.length > 0 &&- selectedEntries.some((e) => e.path === entry.path)- ) {- arrFiles = selectedEntries; //.map((i) => i.path);- } else if (entry) {- arrFiles.push(entry);- }-- if (currentLocation?.isReadOnly) {- showNotification(t('core:dndDisabledReadOnlyMode'), 'error', true);- return;- }- const itemLocation = item.targetLocation;- const targetLocation = findLocation(itemLocation?.locationID);- let targetPath = itemLocation ? itemLocation.path || '' : undefined;- if (targetPath === undefined) {- targetPath = item.targetPath;- }+ const handleFileMoveDrop = useCallback(+ (item, monitor) => {+ if (item) {+ const { entry } = item;+ let arrFiles: TS.FileSystemEntry[] = [];+ if (+ selectedEntries &&+ selectedEntries.length > 0 &&+ selectedEntries.some((e) => e.path === entry.path)+ ) {+ arrFiles = selectedEntries;+ } else if (entry) {+ arrFiles.push(entry);+ }- if (targetPath !== undefined && targetLocation !== undefined) {- // TODO handle monitor -> isOver and change folder icon- console.log('Dropped files in: ' + targetPath);- if (targetLocation.type !== currentLocation.type) {- //locationType.TYPE_CLOUD) {- dispatch(AppActions.resetProgress());- openFileUploadDialog(targetPath, undefined);- return uploadFilesAPI(- arrFiles,- targetPath,- onUploadProgress,- false,- false,- targetLocation.uuid,- currentLocation.uuid,- )- .then((fsEntries: Array<TS.FileSystemEntry>) => {- setMetaUpload(() =>- uploadMeta(- arrFiles.map((f) => f.path),- targetPath,- onUploadProgress,- false,- targetLocation.uuid,- currentLocation.uuid,- ),- );- const actions: TS.EditMetaAction[] = fsEntries.map((entry) => ({- action: 'thumbGenerate',- entry: entry,- }));- setReflectMetaActions(...actions);- return true;- })- .catch((error) => {- console.log('uploadFiles', error);- setMetaUpload(undefined);- });- } else if (targetLocation.type === locationType.TYPE_LOCAL) {- const entries =- selectedEntries.length > 0 ? selectedEntries : [entry];- openMoveCopyFilesDialog(entries, targetPath, targetLocation.uuid);- //openMoveOrCopyFilesDialog(entries, targetPath, targetLocation.uuid);- //moveFiles(arrPath, targetPath, targetLocation.uuid);- } else {- showNotification(t('Moving file not possible'), 'error', true);+ if (currentLocation?.isReadOnly) {+ showNotification(t('core:dndDisabledReadOnlyMode'), 'error', true);return;}- setSelectedEntries([]);+ const itemLocation = item.targetLocation;+ const targetLocation = findLocation(itemLocation?.locationID);+ let targetPath = itemLocation ? itemLocation.path || '' : undefined;+ if (targetPath === undefined) {+ targetPath = item.targetPath;+ }++ if (targetPath !== undefined && targetLocation !== undefined) {+ // TODO handle monitor -> isOver and change folder icon+ console.log('Dropped files in: ' + targetPath);+ if (targetLocation.type !== currentLocation.type) {+ dispatch(AppActions.resetProgress());+ openFileUploadDialog(targetPath, undefined);+ return uploadFilesAPI(+ arrFiles,+ targetPath,+ onUploadProgress,+ false,+ false,+ targetLocation.uuid,+ currentLocation.uuid,+ )+ .then((fsEntries: Array<TS.FileSystemEntry>) => {+ setMetaUpload(() =>+ uploadMeta(+ arrFiles.map((f) => f.path),+ targetPath,+ onUploadProgress,+ false,+ targetLocation.uuid,+ currentLocation.uuid,+ ),+ );+ const actions: TS.EditMetaAction[] = fsEntries.map((entry) => ({+ action: 'thumbGenerate',+ entry: entry,+ }));+ setReflectMetaActions(...actions);+ return true;+ })+ .catch((error) => {+ console.log('uploadFiles', error);+ setMetaUpload(undefined);+ });+ } else if (targetLocation.type === locationType.TYPE_LOCAL) {+ const entries =+ selectedEntries.length > 0 ? selectedEntries : [entry];+ openMoveCopyFilesDialog(entries, targetPath, targetLocation.uuid);+ } else {+ showNotification(t('Moving file not possible'), 'error', true);+ return;+ }+ setSelectedEntries([]);+ }}- }- };+ },+ [+ selectedEntries,+ currentLocation,+ showNotification,+ t,+ findLocation,+ openFileUploadDialog,+ uploadFilesAPI,+ onUploadProgress,+ setMetaUpload,+ uploadMeta,+ setReflectMetaActions,+ openMoveCopyFilesDialog,+ setSelectedEntries,+ dispatch,+ ],+ );- let locationNameTitle = location?.path;- if (isCloudLocation && subFolderLocation?.bucketName) {- if (subFolderLocation.endpointURL) {- locationNameTitle =- subFolderLocation.endpointURL + ' - ' + subFolderLocation.bucketName;- } else if (subFolderLocation.region) {- locationNameTitle =- subFolderLocation.region + ' - ' + subFolderLocation.bucketName;+ // Compute location name for tooltip/title+ const locationNameTitle = useMemo(() => {+ if (isCloudLocation && subFolderLocation?.bucketName) {+ if (subFolderLocation.endpointURL) {+ return (+ subFolderLocation.endpointURL + ' - ' + subFolderLocation.bucketName+ );+ } else if (subFolderLocation.region) {+ return subFolderLocation.region + ' - ' + subFolderLocation.bucketName;+ }}- }+ return location?.path;+ }, [isCloudLocation, subFolderLocation, location]);const LocationTitle = (- <div- style={{+ <Box+ sx={{whiteSpace: 'nowrap',overflow: 'hidden',textOverflow: 'ellipsis',@@ -235,29 +268,33 @@ function LocationView(props: Props) {><Typographyvariant="inherit"- style={{- paddingLeft: 5,- paddingRight: 5,+ sx={{+ paddingLeft: '5px',+ paddingRight: '5px',}}data-tid="locationTitleElement"noWrap>- <Tooltip title={locationNameTitle}>{location.name}</Tooltip>+ <Tooltip title={locationNameTitle}>+ <>{location.name}</>+ </Tooltip>{workspace && (<Tooltip title={t('core:workspace') + ': ' + workspace.fullName}>- {' - ' + workspace.shortName}+ <>{' - ' + workspace.shortName}</></Tooltip>)}</Typography>- </div>+ </Box>);+const { FILE } = NativeTypes;const isLocationSelected =currentLocation && currentLocation.uuid === location.locationID;+return (<Box- style={{- paddingLeft: 5,+ sx={{+ paddingLeft: '5px',paddingRight: 0,height: '100%',}}@@ -270,11 +307,9 @@ function LocationView(props: Props) {<CustomDragLayer /><ListItemdisablePadding- style={{+ sx={{borderRadius: AppConfig.defaultCSSRadius,- backgroundColor: isLocationSelected- ? theme.palette.primary.light- : 'inherit',+ backgroundColor: isLocationSelected ? 'primary.light' : 'inherit',}}><ListItemButton@@ -283,14 +318,14 @@ function LocationView(props: Props) {onContextMenu={(event) =>handleLocationContextMenuClick(event, subFolderLocation)}- style={{+ sx={{padding: 0,- paddingRight: 15,+ paddingRight: '15px',borderRadius: AppConfig.defaultCSSRadius,}}><ListItemIcon- style={{+ sx={{minWidth: 'auto',cursor: 'pointer',}}@@ -299,16 +334,16 @@ function LocationView(props: Props) {<Tooltip title={t('clickToExpand')}>{isCloudLocation ? (<CloudLocationIcon- style={{+ sx={{cursor: 'pointer',- margin: theme.spacing(1),+ margin: 1,}}/>) : (<LocalLocationIcon- style={{+ sx={{cursor: 'pointer',- margin: theme.spacing(1),+ margin: 1,}}/>)}diff --git a/src/renderer/components/MobileNavigation.tsx b/src/renderer/components/MobileNavigation.tsxindex 89e9e1172..44d290a47 100644--- a/src/renderer/components/MobileNavigation.tsx+++ b/src/renderer/components/MobileNavigation.tsx@@ -82,7 +82,13 @@ import MenuItem from '@mui/material/MenuItem';import Paper from '@mui/material/Paper';import Popper from '@mui/material/Popper';import { alpha, useTheme } from '@mui/material/styles';-import React, { useContext, useState } from 'react';+import React, {+ useCallback,+ useContext,+ useMemo,+ useRef,+ useState,+} from 'react';import { useTranslation } from 'react-i18next';import { useDispatch, useSelector } from 'react-redux';import TsIconButton from './TsIconButton';@@ -112,15 +118,18 @@ function MobileNavigation(props: Props) {const { openDownloadUrl } = useDownloadUrlDialogContext();const keyBindings = useSelector(getKeyBindingObject);const { currentUser } = useUserContext();- const [showTeaserBanner, setShowTeaserBanner] = useState<boolean>(true);+ const [showTeaserBanner, setShowTeaserBanner] = useState(true);const [anchorUser, setAnchorUser] = useState<HTMLButtonElement | null>(null);const showProTeaser = !Pro && showTeaserBanner;const { hideDrawer, width } = props;- const switchTheme = () => dispatch(SettingsActions.switchTheme());- const [openedCreateMenu, setOpenCreateMenu] = React.useState(false);- const [openedWorkSpaceMenu, setOpenWorkSpaceMenu] = React.useState(false);- const anchorWSpaceRef = React.useRef<HTMLButtonElement>(null);- const anchorRef = React.useRef<HTMLButtonElement>(null);+ const switchTheme = useCallback(+ () => dispatch(SettingsActions.switchTheme()),+ [dispatch],+ );+ const [openedCreateMenu, setOpenCreateMenu] = useState(false);+ const [openedWorkSpaceMenu, setOpenWorkSpaceMenu] = useState(false);+ const anchorWSpaceRef = useRef<HTMLButtonElement>(null);+ const anchorRef = useRef<HTMLButtonElement>(null);const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext? useContext<TS.WorkSpacesContextData>(@@ -128,41 +137,70 @@ function MobileNavigation(props: Props) {): undefined;const workSpaces: TS.WorkSpace[] = workSpacesContext?.getWorkSpaces() ?? [];- /*const foundWorkSpaces: TS.WorkSpace[] = workSpaces.filter((ws) =>- locations.some((l) => l.workSpaceId === ws.uuid),- );*/-- const handleToggle = () => {- setOpenCreateMenu((prevOpen) => !prevOpen);- };- const handleToggleWorkSpaces = () => {- setOpenWorkSpaceMenu((prevOpen) => !prevOpen);- };-- const handleClose = (event: Event) => {+ const handleToggle = useCallback(+ () => setOpenCreateMenu((prev) => !prev),+ [],+ );+ const handleToggleWorkSpaces = useCallback(+ () => setOpenWorkSpaceMenu((prev) => !prev),+ [],+ );+ const handleClose = useCallback((event: Event) => {if (anchorRef.current &&anchorRef.current.contains(event.target as HTMLElement)- ) {+ )return;- }setOpenCreateMenu(false);- };-- const handleCloseWSpace = (event: Event) => {+ }, []);+ const handleCloseWSpace = useCallback((event: Event) => {if (anchorWSpaceRef.current &&anchorWSpaceRef.current.contains(event.target as HTMLElement)- ) {+ )return;- }setOpenWorkSpaceMenu(false);- };+ }, []);++ // Memoize workspace menu items for performance+ const workspaceMenuItems = useMemo(+ () => [+ <MenuItem+ key="allWSpace"+ data-tid={'wSpaceAllTID'}+ onClick={() => {+ workSpacesContext?.setCurrentWorkSpaceId(undefined);+ setOpenWorkSpaceMenu(false);+ }}+ >+ <ListItemIcon>+ <WorkspacesIcon />+ </ListItemIcon>+ <ListItemText primary={t('all')} />+ </MenuItem>,+ ...workSpaces.map((wSpace) => (+ <MenuItem+ key={wSpace.uuid}+ data-tid={'wSpace' + wSpace.shortName + 'TID'}+ onClick={() => {+ workSpacesContext?.setCurrentWorkSpaceId(wSpace.uuid);+ setOpenWorkSpaceMenu(false);+ }}+ >+ <ListItemIcon>+ <WorkspacesIcon />+ </ListItemIcon>+ <ListItemText primary={`${wSpace.fullName} - ${wSpace.shortName}`} />+ </MenuItem>+ )),+ ],+ [workSpaces, t, workSpacesContext],+ );return (<Box- style={{+ sx={{background: alpha(theme.palette.background.default, 0.85),backdropFilter: 'blur(5px)',height: '100%',@@ -172,7 +210,7 @@ function MobileNavigation(props: Props) {}}><Box- style={{+ sx={{overflow: 'hidden',height: showProTeaser ? 'calc(100% - 190px)' : 'calc(100% - 55px)',}}@@ -180,21 +218,20 @@ function MobileNavigation(props: Props) {<Box><CustomLogo /><Box- style={{+ sx={{width: '100%',justifyContent: 'center',- // justifyContent: 'space-between',- paddingLeft: 10,+ paddingLeft: '10px',display: 'flex',alignItems: 'center',}}><ButtonGrouparia-label="split button"- style={{+ sx={{textAlign: 'center',- marginLeft: 5,- marginRight: 5,+ marginLeft: '5px',+ marginRight: '5px',}}><TsButton@@ -208,14 +245,14 @@ function MobileNavigation(props: Props) {onClick={handleToggle}startIcon={<CreateFileIcon />}endIcon={<ArrowDropDown />}- style={{+ sx={{borderRadius: 'unset',borderTopLeftRadius: AppConfig.defaultCSSRadius,borderBottomLeftRadius: AppConfig.defaultCSSRadius,}}><Box- style={{+ sx={{textOverflow: 'ellipsis',whiteSpace: 'nowrap',overflow: 'hidden',@@ -223,7 +260,6 @@ function MobileNavigation(props: Props) {}}>{t('core:new')}- {/* {t('core:createNew')} */}</Box></TsButton>{workSpaces && workSpaces.length > 0 && (@@ -238,19 +274,17 @@ function MobileNavigation(props: Props) {data-tid="openedWorkSpaceMenuButtonTID"onClick={handleToggleWorkSpaces}endIcon={<ArrowDropDown />}- style={{- borderRadius: 'unset',- }}+ sx={{ borderRadius: 'unset' }}><Box- style={{+ sx={{textOverflow: 'ellipsis',whiteSpace: 'nowrap',overflow: 'hidden',maxWidth: 100,}}>- {workSpacesContext.getCurrentWorkSpace()?.shortName ||+ {workSpacesContext?.getCurrentWorkSpace()?.shortName ||t('core:all')}</Box></TsButton>@@ -258,38 +292,16 @@ function MobileNavigation(props: Props) {<TsButtontooltip={t('core:openSharingLink')}data-tid="openLinkNavigationTID"- onClick={() => {- openLinkDialog();- }}- style={{+ onClick={openLinkDialog}+ sx={{borderRadius: 'unset',borderTopRightRadius: AppConfig.defaultCSSRadius,borderBottomRightRadius: AppConfig.defaultCSSRadius,}}- // startIcon={<OpenLinkIcon />}><OpenLinkIcon />- {/* <Box- style={{- textOverflow: 'ellipsis',- whiteSpace: 'nowrap',- overflow: 'hidden',- maxWidth: 100,- }}- >- {t('core:openLink')}- </Box> */}</TsButton></ButtonGroup>- {/* <TsIconButton- tooltip={t('core:openSharingLink')}- data-tid="openLinkNavigationTID"- onClick={() => {- openLinkDialog();- }}- >- <OpenLinkIcon />- </TsIconButton> */}{currentUser ? (<><TsIconButton@@ -333,9 +345,7 @@ function MobileNavigation(props: Props) {<ClickAwayListener onClickAway={handleCloseWSpace}><PopperanchorEl={anchorWSpaceRef.current}- sx={{- zIndex: 1,- }}+ sx={{ zIndex: 1 }}open={openedWorkSpaceMenu}role={undefined}transition@@ -351,38 +361,7 @@ function MobileNavigation(props: Props) {><Paper><TsMenuList id="create-file-menu" autoFocusItem>- <MenuItem- key="allWSpace"- data-tid={'wSpaceAllTID'}- onClick={() => {- workSpacesContext.setCurrentWorkSpaceId(undefined);- setOpenWorkSpaceMenu(false);- }}- >- <ListItemIcon>- <WorkspacesIcon />- </ListItemIcon>- <ListItemText primary={t('all')} />- </MenuItem>- {workSpaces.map((wSpace) => (- <MenuItem- key={wSpace.uuid}- data-tid={'wSpace' + wSpace.shortName + 'TID'}- onClick={() => {- workSpacesContext.setCurrentWorkSpaceId(- wSpace.uuid,- );- setOpenWorkSpaceMenu(false);- }}- >- <ListItemIcon>- <WorkspacesIcon />- </ListItemIcon>- <ListItemText- primary={wSpace.fullName + ' - ' + wSpace.shortName}- />- </MenuItem>- ))}+ {workspaceMenuItems}</TsMenuList></Paper></Grow>@@ -392,9 +371,7 @@ function MobileNavigation(props: Props) {)}<ClickAwayListener onClickAway={handleClose}><Popper- sx={{- zIndex: 1,- }}+ sx={{ zIndex: 1 }}open={openedCreateMenu}anchorEl={anchorRef.current}role={undefined}@@ -417,9 +394,7 @@ function MobileNavigation(props: Props) {onClick={() => {openNewFileDialog('txt');setOpenCreateMenu(false);- if (hideDrawer) {- hideDrawer();- }+ hideDrawer?.();}}><ListItemIcon>@@ -433,9 +408,7 @@ function MobileNavigation(props: Props) {onClick={() => {openNewFileDialog('md');setOpenCreateMenu(false);- if (hideDrawer) {- hideDrawer();- }+ hideDrawer?.();}}><ListItemIcon>@@ -450,9 +423,7 @@ function MobileNavigation(props: Props) {onClick={() => {openNewFileDialog('html');setOpenCreateMenu(false);- if (hideDrawer) {- hideDrawer();- }+ hideDrawer?.();}}><ListItemIcon>@@ -467,9 +438,7 @@ function MobileNavigation(props: Props) {onClick={() => {openNewFileDialog('url');setOpenCreateMenu(false);- if (hideDrawer) {- hideDrawer();- }+ hideDrawer?.();}}><ListItemIcon>@@ -484,9 +453,7 @@ function MobileNavigation(props: Props) {onClick={() => {openNewAudioDialog();setOpenCreateMenu(false);- if (hideDrawer) {- hideDrawer();- }+ hideDrawer?.();}}><ListItemIcon>@@ -508,9 +475,7 @@ function MobileNavigation(props: Props) {onClick={() => {openNewFileDialog();setOpenCreateMenu(false);- if (hideDrawer) {- hideDrawer();- }+ hideDrawer?.();}}><ListItemIcon>@@ -532,9 +497,7 @@ function MobileNavigation(props: Props) {onClick={() => {openFileUpload(currentDirectoryPath);setOpenCreateMenu(false);- if (hideDrawer) {- hideDrawer();- }+ hideDrawer?.();}}><ListItemIcon>@@ -550,9 +513,7 @@ function MobileNavigation(props: Props) {onClick={() => {openDownloadUrl();setOpenCreateMenu(false);- if (hideDrawer) {- hideDrawer();- }+ hideDrawer?.();}}><ListItemIcon>@@ -570,9 +531,7 @@ function MobileNavigation(props: Props) {onClick={() => {openCreateDirectoryDialog();setOpenCreateMenu(false);- if (hideDrawer) {- hideDrawer();- }+ hideDrawer?.();}}><ListItemIcon>@@ -589,9 +548,7 @@ function MobileNavigation(props: Props) {setSelectedLocation(undefined);openCreateEditLocationDialog();setOpenCreateMenu(false);- if (hideDrawer) {- hideDrawer();- }+ hideDrawer?.();}}><ListItemIcon>@@ -612,9 +569,7 @@ function MobileNavigation(props: Props) {<ListItemIcon><OpenNewWindowIcon /></ListItemIcon>- <ListItemText- primary={t('core:newWindow')}- ></ListItemText>+ <ListItemText primary={t('core:newWindow')} /></MenuItem>)}</TsMenuList>@@ -638,10 +593,10 @@ function MobileNavigation(props: Props) {)}</Box><Box- style={{+ sx={{display: 'flex',flexDirection: 'column',- marginTop: desktopMode ? -10 : -25,+ marginTop: desktopMode ? '-10px' : '-25px',backgroundColor: theme.palette.background.default,}}>@@ -718,9 +673,7 @@ function MobileNavigation(props: Props) {tooltip={t('core:settings')}id="verticalNavButton"data-tid="settings"- onClick={() => {- openSettingsDialog();- }}+ onClick={() => openSettingsDialog()}sx={{marginLeft: '10px',backgroundColor: theme.palette.background.default,@@ -734,4 +687,5 @@ function MobileNavigation(props: Props) {</Box>);}+export default MobileNavigation;diff --git a/src/renderer/components/RenderHistory.tsx b/src/renderer/components/RenderHistory.tsxindex 4b9b4df5d..c8223a8e8 100644--- a/src/renderer/components/RenderHistory.tsx+++ b/src/renderer/components/RenderHistory.tsx@@ -34,6 +34,7 @@ import { Pro } from '-/pro';import { dataTidFormat } from '-/services/test';import { createNewInstance } from '-/services/utils-io';import { TS } from '-/tagspaces.namespace';+import { Box } from '@mui/material';import ListItem from '@mui/material/ListItem';import ListItemIcon from '@mui/material/ListItemIcon';import ListItemText from '@mui/material/ListItemText';@@ -43,7 +44,7 @@ import {extractDirectoryName,extractFileName,} from '@tagspaces/tagspaces-common/paths';-import { useContext, useState } from 'react';+import React, { useCallback, useContext, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';import TooltipTS from './Tooltip';import TsMenuList from './TsMenuList';@@ -52,45 +53,55 @@ interface Props {historyKey: string;items: Array<TS.HistoryItem> | Array<TS.BookmarkItem>;update: () => void;- maxItems?: number | undefined;+ maxItems?: number;showMenu?: boolean;}-function RenderHistory(props: Props) {++function RenderHistory({+ historyKey,+ items,+ update,+ maxItems,+ showMenu = true,+}: Props) {const { t } = useTranslation();const { openHistoryItem } = useBrowserHistoryContext();const { delHistory } = useHistoryContext();const bookmarksContext = Pro?.contextProviders?.BookmarksContext? useContext<TS.BookmarksContextData>(Pro.contextProviders.BookmarksContext): undefined;- const { historyKey, items, update, maxItems, showMenu = true } = props;const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);const [selectedItem, setSelectedItem] = useState<TS.HistoryItem | TS.BookmarkItem | null>(null);+const menuOpen = Boolean(anchorEl);- const handleMenuOpen = (- event: React.MouseEvent<HTMLElement>,- item: TS.HistoryItem | TS.BookmarkItem,- ) => {- setAnchorEl(event.currentTarget);- setSelectedItem(item);- };+ const handleMenuOpen = useCallback(+ (+ event: React.MouseEvent<HTMLElement>,+ item: TS.HistoryItem | TS.BookmarkItem,+ ) => {+ setAnchorEl(event.currentTarget);+ setSelectedItem(item);+ },+ [],+ );- const handleMenuClose = () => {+ const handleMenuClose = useCallback(() => {setAnchorEl(null);setSelectedItem(null);- };+ }, []);- const handleOpen = () => {+ const handleOpen = useCallback(() => {if (selectedItem) {openHistoryItem(selectedItem as TS.HistoryItem);}handleMenuClose();- };+ }, [selectedItem, openHistoryItem, handleMenuClose]);- const handleOpenInNewWindow = async () => {+ const handleOpenInNewWindow = useCallback(async () => {if (!selectedItem) {handleMenuClose();return;@@ -107,9 +118,9 @@ function RenderHistory(props: Props) {} finally {handleMenuClose();}- };+ }, [selectedItem, handleMenuClose]);- const handleCopyLink = async () => {+ const handleCopyLink = useCallback(async () => {if (!selectedItem) {handleMenuClose();return;@@ -123,98 +134,107 @@ function RenderHistory(props: Props) {} finally {handleMenuClose();}- };+ }, [selectedItem, handleMenuClose]);- const handleRemove = () => {+ const handleRemove = useCallback(() => {if (!selectedItem) {handleMenuClose();return;}if (historyKey === Pro?.keys.bookmarksKey) {- // del bookmarkbookmarksContext?.delBookmark(selectedItem.path);} else {- // del history entrydelHistory(historyKey, selectedItem.creationTimeStamp);}update();handleMenuClose();- };+ }, [+ selectedItem,+ historyKey,+ bookmarksContext,+ delHistory,+ update,+ handleMenuClose,+ ]);++ // Memoize the sliced items for performance+ const displayedItems = useMemo(+ () => items?.slice(0, maxItems ?? items.length) ?? [],+ [items, maxItems],+ );return (<>- {items &&- items.slice(0, maxItems || items.length).map((item) => {- const itemName = item.path.endsWith(AppConfig.dirSeparator)- ? extractDirectoryName(item.path, AppConfig.dirSeparator)- : extractFileName(item.path, AppConfig.dirSeparator);- return (- <ListItem- dense- style={{ paddingLeft: 0, height: 40 }}- key={item.creationTimeStamp}+ {displayedItems.map((item) => {+ const itemName = item.path.endsWith(AppConfig.dirSeparator)+ ? extractDirectoryName(item.path, AppConfig.dirSeparator)+ : extractFileName(item.path, AppConfig.dirSeparator);+ return (+ <ListItem+ dense+ sx={{ paddingLeft: 0, height: 40 }}+ key={item.creationTimeStamp}+ >+ <TsButton+ data-tid={historyKey + 'TID' + dataTidFormat(itemName)}+ variant="text"+ sx={{+ textTransform: 'none',+ fontWeight: 'normal',+ justifyContent: 'start',+ minWidth: 260,+ maxWidth: 260,+ }}+ onClick={() => openHistoryItem(item as TS.HistoryItem)}>- <TsButton- data-tid={historyKey + 'TID' + dataTidFormat(itemName)}- variant="text"- style={{- textTransform: 'none',- fontWeight: 'normal',- justifyContent: 'start',- minWidth: 270,- maxWidth: 270,- }}- onClick={() => openHistoryItem(item as TS.HistoryItem)}- >- <TooltipTS- title={- <span>- <b>{t('core:filePath')}:</b> {item.path}- <br />- <br />- {<b>{t('dateCreatedSearchTitle')}: </b>}- {new Date(item.creationTimeStamp)- .toISOString()- .substring(0, 19)- .split('T')- .join(' ')}- </span>- }- >- {historyKey === Pro?.keys.bookmarksKey ? (- <EntryBookmarkIcon />- ) : (- <HistoryIcon />- )}- </TooltipTS>- <TooltipTS title={itemName}>- <span- style={{- whiteSpace: 'nowrap',- textOverflow: 'ellipsis',- overflow: 'hidden',- maxWidth: 220,- marginLeft: 5,- }}- >- {itemName}+ <TooltipTS+ title={+ <span>+ <b>{t('core:filePath')}:</b> {item.path}+ <br />+ <br />+ <b>{t('dateCreatedSearchTitle')}: </b>+ {new Date(item.creationTimeStamp)+ .toISOString()+ .substring(0, 19)+ .replace('T', ' ')}</span>- </TooltipTS>- </TsButton>- {showMenu && (- <TsIconButton- tooltip={t('options')}- aria-label={t('options')}- onClick={(e) => handleMenuOpen(e, item)}- data-tid={'historyItemMenuTID' + dataTidFormat(itemName)}- size="small"+ }+ >+ {historyKey === Pro?.keys.bookmarksKey ? (+ <EntryBookmarkIcon />+ ) : (+ <HistoryIcon />+ )}+ </TooltipTS>+ <TooltipTS title={itemName}>+ <Box+ sx={{+ whiteSpace: 'nowrap',+ textOverflow: 'ellipsis',+ overflow: 'hidden',+ maxWidth: 220,+ marginLeft: '5px',+ }}>- <MoreMenuIcon />- </TsIconButton>- )}- </ListItem>- );- })}+ {itemName}+ </Box>+ </TooltipTS>+ </TsButton>+ {showMenu && (+ <TsIconButton+ tooltip={t('options')}+ aria-label={t('options')}+ onClick={(e) => handleMenuOpen(e, item)}+ data-tid={'historyItemMenuTID' + dataTidFormat(itemName)}+ size="small"+ >+ <MoreMenuIcon />+ </TsIconButton>+ )}+ </ListItem>+ );+ })}<MenuanchorEl={anchorEl}@@ -257,4 +277,4 @@ function RenderHistory(props: Props) {);}-export default RenderHistory;+export default React.memo(RenderHistory);diff --git a/src/renderer/components/StoredSearches.tsx b/src/renderer/components/StoredSearches.tsxindex 0257d9f4e..9176697c7 100644--- a/src/renderer/components/StoredSearches.tsx+++ b/src/renderer/components/StoredSearches.tsx@@ -138,18 +138,18 @@ function StoredSearches(props: Props) {return (<Boxdata-tid="quickAccessArea"- style={{+ sx={{display: 'flex',flexDirection: 'column',height: '100%',borderRadius: AppConfig.defaultCSSRadius,- marginLeft: 5,- marginRight: 5,+ marginLeft: '5px',+ marginRight: '5px',}}><SidePanelTitle title={t('core:quickAccess')} />- <div- style={{+ <Box+ sx={{paddingTop: 0,marginTop: 0,height: 'calc(100% - ' + reduceHeightBy + 'px)',@@ -159,14 +159,14 @@ function StoredSearches(props: Props) {}}><Grid container direction="row">- <Grid size={10} style={{ alignSelf: 'center' }}>+ <Grid size={10} sx={{ alignSelf: 'center' }}><TsIconButtondata-tid={props.storedSearchesVisible? 'storedSearchesVisibleTID': 'storedSearchesHiddenTID'}- style={{ minWidth: 'auto', padding: 7 }}+ sx={{ minWidth: 'auto', padding: '7px' }}onClick={() =>props.setStoredSearchesVisible(!props.storedSearchesVisible)}@@ -179,7 +179,7 @@ function StoredSearches(props: Props) {</TsIconButton><Typographyvariant="inherit"- style={{ display: 'inline' }}+ sx={{ display: 'inline' }}noWraponClick={() =>props.setStoredSearchesVisible(!props.storedSearchesVisible)@@ -188,7 +188,7 @@ function StoredSearches(props: Props) {{t('core:savedSearchesTitle')}</Typography></Grid>- <Grid size={2} style={{ textAlign: 'right' }}>+ <Grid size={2} sx={{ textAlign: 'right' }}><SearchMenuanchorEl={searchMenuAnchorEl}open={Boolean(searchMenuAnchorEl)}@@ -211,7 +211,7 @@ function StoredSearches(props: Props) {</Grid><Grid container direction="row">{props.storedSearchesVisible && noSearchesFound && (- <Grid size={12} style={{ textAlign: 'center' }}>+ <Grid size={12} sx={{ textAlign: 'center' }}><Typography variant="caption">{t('noSavedSearches')}</Typography></Grid>)}@@ -228,7 +228,7 @@ function StoredSearches(props: Props) {search.title.trim().replaceAll(/\s+/g, '-')}variant="text"- style={{+ sx={{textTransform: 'none',fontWeight: 'normal',justifyContent: 'start',@@ -237,8 +237,8 @@ function StoredSearches(props: Props) {><SearchIcon /> - <span- style={{+ <Box+ sx={{whiteSpace: 'nowrap',textOverflow: 'ellipsis',overflow: 'hidden',@@ -246,7 +246,7 @@ function StoredSearches(props: Props) {}}>{search.title}- </span>+ </Box></TsButton></Grid><Grid size={2}>@@ -263,10 +263,10 @@ function StoredSearches(props: Props) {))}</Grid><Grid container direction="row">- <Grid size={10} style={{ alignSelf: 'center' }}>+ <Grid size={10} sx={{ alignSelf: 'center' }}><TsIconButtondata-tid="BookmarksTID"- style={{ minWidth: 'auto', padding: 7 }}+ sx={{ minWidth: 'auto', padding: '7px' }}onClick={() => props.setShowBookmarks(!props.showBookmarks)}>{props.showBookmarks ? (@@ -277,14 +277,14 @@ function StoredSearches(props: Props) {</TsIconButton><Typographyvariant="inherit"- style={{ display: 'inline' }}+ sx={{ display: 'inline' }}noWraponClick={() => props.setShowBookmarks(!props.showBookmarks)}>{t('core:showBookmarks')}</Typography></Grid>- <Grid size={2} style={{ textAlign: 'right' }}>+ <Grid size={2} sx={{ textAlign: 'right' }}><TsIconButtondata-tid="BookmarksMenuTID"onClick={(event: any) => {@@ -299,7 +299,7 @@ function StoredSearches(props: Props) {</Grid><Grid container direction="row">{props.showBookmarks && !bookmarksAvailable && (- <Grid size={12} style={{ textAlign: 'center' }}>+ <Grid size={12} sx={{ textAlign: 'center' }}><Typography variant="caption">{t('noItems')}</Typography></Grid>)}@@ -312,14 +312,14 @@ function StoredSearches(props: Props) {/>)}<Grid container direction="row">- <Grid size={10} style={{ alignSelf: 'center' }}>+ <Grid size={10} sx={{ alignSelf: 'center' }}><TsIconButtondata-tid={props.fileOpenHistory? 'fileCloseHistoryTID': 'fileOpenHistoryTID'}- style={{ minWidth: 'auto', padding: 7 }}+ sx={{ minWidth: 'auto', padding: '7px' }}onClick={() => props.setFileOpenHistory(!props.fileOpenHistory)}>{props.fileOpenHistory ? (@@ -330,14 +330,14 @@ function StoredSearches(props: Props) {</TsIconButton><Typographyvariant="inherit"- style={{ display: 'inline' }}+ sx={{ display: 'inline' }}noWraponClick={() => props.setFileOpenHistory(!props.fileOpenHistory)}>{t('core:fileOpenHistory')}</Typography></Grid>- <Grid size={2} style={{ textAlign: 'right' }}>+ <Grid size={2} sx={{ textAlign: 'right' }}><TsIconButtondata-tid="fileOpenMenuTID"onClick={(event: any) => {@@ -352,7 +352,7 @@ function StoredSearches(props: Props) {</Grid><Grid container direction="row">{props.fileOpenHistory && !openedFilesAvailable && (- <Grid size={12} style={{ textAlign: 'center' }}>+ <Grid size={12} sx={{ textAlign: 'center' }}><Typography variant="caption">{t('noItems')}</Typography></Grid>)}@@ -365,10 +365,10 @@ function StoredSearches(props: Props) {/>)}<Grid container direction="row">- <Grid size={10} style={{ alignSelf: 'center' }}>+ <Grid size={10} sx={{ alignSelf: 'center' }}><TsIconButtondata-tid="fileEditHistoryTID"- style={{ minWidth: 'auto', padding: 7 }}+ sx={{ minWidth: 'auto', padding: '7px' }}onClick={() => props.setFileEditHistory(!props.fileEditHistory)}>{props.fileEditHistory ? (@@ -379,14 +379,14 @@ function StoredSearches(props: Props) {</TsIconButton><Typographyvariant="inherit"- style={{ display: 'inline' }}+ sx={{ display: 'inline' }}noWraponClick={() => props.setFileEditHistory(!props.fileEditHistory)}>{t('core:fileEditHistory')}</Typography></Grid>- <Grid size={2} style={{ textAlign: 'right' }}>+ <Grid size={2} sx={{ textAlign: 'right' }}><TsIconButtondata-tid="FileEditedMenuTID"onClick={(event: any) => {@@ -401,7 +401,7 @@ function StoredSearches(props: Props) {</Grid><Grid container direction="row">{props.fileEditHistory && !editedFilesAvailable && (- <Grid size={12} style={{ textAlign: 'center' }}>+ <Grid size={12} sx={{ textAlign: 'center' }}><Typography variant="caption">{t('noItems')}</Typography></Grid>)}@@ -414,14 +414,14 @@ function StoredSearches(props: Props) {/>)}<Grid container direction="row">- <Grid size={10} style={{ alignSelf: 'center' }}>+ <Grid size={10} sx={{ alignSelf: 'center' }}><TsIconButtondata-tid={props.folderOpenHistory? 'folderCloseHistoryTID': 'folderOpenHistoryTID'}- style={{ minWidth: 'auto', padding: 7 }}+ sx={{ minWidth: 'auto', padding: '7px' }}onClick={() =>props.setFolderOpenHistory(!props.folderOpenHistory)}@@ -434,7 +434,7 @@ function StoredSearches(props: Props) {</TsIconButton><Typographyvariant="inherit"- style={{ display: 'inline' }}+ sx={{ display: 'inline' }}noWraponClick={() =>props.setFolderOpenHistory(!props.folderOpenHistory)@@ -443,7 +443,7 @@ function StoredSearches(props: Props) {{t('core:folderOpenHistory')}</Typography></Grid>- <Grid size={2} style={{ textAlign: 'right' }}>+ <Grid size={2} sx={{ textAlign: 'right' }}><TsIconButtonsize="small"data-tid="FolderOpenMenuTID"@@ -480,7 +480,7 @@ function StoredSearches(props: Props) {/><Grid container direction="row">{props.folderOpenHistory && !openedFoldersAvailable && (- <Grid size={12} style={{ textAlign: 'center' }}>+ <Grid size={12} sx={{ textAlign: 'center' }}><Typography variant="caption">{t('noItems')}</Typography></Grid>)}@@ -492,7 +492,7 @@ function StoredSearches(props: Props) {update={forceUpdate}/>)}- </div>+ </Box><inputstyle={{ display: 'none' }}ref={fileInputRef}diff --git a/src/renderer/components/TagContainer.tsx b/src/renderer/components/TagContainer.tsxindex ecd47a2bc..0cdc47ee6 100644--- a/src/renderer/components/TagContainer.tsx+++ b/src/renderer/components/TagContainer.tsx@@ -16,8 +16,15 @@**/+import DateIcon from '@mui/icons-material/DateRange';+import PlaceIcon from '@mui/icons-material/Place';+import { Box } from '@mui/material';+import React, { useCallback, useMemo } from 'react';+import { useSelector } from 'react-redux';+import Tag from '-/components/Tag';import TagContainerMenu from '-/components/TagContainerMenu';+import { useEditedTagLibraryContext } from '-/hooks/useEditedTagLibraryContext';import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';import { getTagColor, getTagTextColor } from '-/reducers/settings';@@ -25,12 +32,7 @@ import { getTagColors } from '-/services/taglibrary-utils';import { TS } from '-/tagspaces.namespace';import { convertToTimestamp, isDateTimeTag } from '-/utils/dates';import { isGeoTag } from '-/utils/geo';-import DateIcon from '@mui/icons-material/DateRange';-import PlaceIcon from '@mui/icons-material/Place';import { formatDateTime } from '@tagspaces/tagspaces-common/misc';-import React, { useMemo } from 'react';-import { useSelector } from 'react-redux';-import { useEditedTagLibraryContext } from '-/hooks/useEditedTagLibraryContext';interface Props {tag: TS.Tag;@@ -40,7 +42,7 @@ interface Props {tag: TS.Tag,tagGroup: TS.TagGroup | TS.FileSystemEntry,haveSelectedEntries: boolean,- ) => void; // TODO refactor+ ) => void;handleRemoveTag?: (event: Object, tags: Array<TS.Tag>) => void;isDragging?: boolean;tagMode?: 'default' | 'display' | 'remove';@@ -54,188 +56,192 @@ interface Props {reorderTags?: boolean;}-function TagContainer(props: Props) {+function TagContainer({+ tag,+ tagGroup,+ entry,+ handleTagMenu,+ handleRemoveTag,+ deleteIcon,+ isDragging,+ tagMode,+}: Props) {const {- tag,- deleteIcon,- isDragging,- tagGroup,- entry,- handleRemoveTag,- handleTagMenu,- tagMode,- } = props;- let { title } = tag;-+ title: originalTitle,+ functionality,+ color,+ textcolor,+ description,+ } = tag;const { addTags } = useTaggingActionsContext();const { selectedEntries } = useSelectedEntriesContext();- const defaultBackgroundColor = useSelector(getTagColor);+ const { tagGroups } = useEditedTagLibraryContext();++ const defaultBgColor = useSelector(getTagColor);const defaultTextColor = useSelector(getTagTextColor);- let isDateSmartTag = false;- let isGeoSmartTag = false;- let textColor: string;- let backgroundColor: string;+ // Compute tag color once+ const { color: bgColor, textcolor: txtColor } = useMemo(+ () =>+ color && textcolor+ ? { color, textcolor }+ : getTagColors(+ originalTitle,+ tagGroup ? [tagGroup] : tagGroups,+ defaultTextColor,+ defaultBgColor,+ ),+ [+ color,+ textcolor,+ originalTitle,+ tagGroup,+ tagGroups,+ defaultTextColor,+ defaultBgColor,+ ],+ );++ // Create the getColor function once+ // const getColors = useCallback(+ // () =>+ // color && textcolor+ // ? { color, textcolor }+ // : getTagColors(+ // originalTitle,+ // tagGroup ? [tagGroup] : tagGroups,+ // defaultTextColor,+ // defaultBgColor,+ // ),+ // [+ // color,+ // textcolor,+ // originalTitle,+ // tagGroup,+ // tagGroups,+ // defaultTextColor,+ // defaultBgColor,+ // ],+ // );+ // const { color: bgColor, textcolor: txtColor } = getColors();++ // let txtColor;+ // let bgColor;+ // if (tag.color && tag.textcolor) {+ // txtColor = tag.textcolor;+ // bgColor = tag.color;+ // } else {+ // const tagColors = getTagColors(+ // originalTitle,+ // tagGroup ? [tagGroup] : undefined,+ // defaultTextColor,+ // defaultBgColor,+ // );+ // txtColor = tagColors.textcolor;+ // bgColor = tagColors.color;+ // }++ /** Detect tag type */const isTagGeo = useMemo(- () => !tagGroup && isGeoTag(title),- [title, tagGroup],+ () => !tagGroup && isGeoTag(originalTitle),+ [originalTitle, tagGroup],);const isTagDate = useMemo(- () => !isTagGeo && !tagGroup && isDateTimeTag(title),- [isTagGeo, title, tagGroup],+ () => !isTagGeo && !tagGroup && isDateTimeTag(originalTitle),+ [isTagGeo, originalTitle, tagGroup],);- if (tag.color && tag.textcolor) {- textColor = tag.textcolor;- backgroundColor = tag.color;- } else {- const tagColors = getTagColors(- title,- tagGroup ? [tagGroup] : undefined,- defaultTextColor,- defaultBackgroundColor,- );- textColor = tagColors.textcolor;- backgroundColor = tagColors.color;- }-- let tid = 'tagContainer_';- if (title && title.length > 0) {- tid += title.replace(/ /g, '_');- }-- if (tag.functionality && tag.functionality.length > 0) {- const tagFunc = tag.functionality;- if (- tagFunc === 'now' ||- tagFunc === 'today' ||- tagFunc === 'tomorrow' ||- tagFunc === 'yesterday' ||- tagFunc === 'currentMonth' ||- tagFunc === 'currentYear' ||- tagFunc === 'dateTagging'- ) {- isDateSmartTag = true;- } else if (tagFunc === 'geoTagging') {- isGeoSmartTag = true;- }- }-- let tagTitle = ''; // tag.title;- if (isTagDate) {- let date;- if (tag.title.includes('-')) {- const timeArr = tag.title.split('-');- if (parseInt(timeArr[0], 10) && parseInt(timeArr[1], 10)) {- const firstTime = convertToTimestamp(timeArr[0]);- const secondTime = convertToTimestamp(timeArr[1]);- const haveTime0 = timeArr[0].length > 8;- const haveTime1 = timeArr[1].length > 8;- tagTitle =- formatDateTime(firstTime, haveTime0) +- ' <-> ' +- formatDateTime(secondTime, haveTime1);- }- } else if (tag.title.length > 8) {- date = convertToTimestamp(tag.title); //new Date(convertToDateTime(tag.title)).getTime();- tagTitle = formatDateTime(date, true);+ const isGeoSmartTag = functionality === 'geoTagging';+ const isDateSmartTag = [+ 'now',+ 'today',+ 'tomorrow',+ 'yesterday',+ 'currentMonth',+ 'currentYear',+ 'dateTagging',+ ].includes(functionality || '');++ /** Compute readable tag title for date tags */+ const tagTitle = useMemo(() => {+ if (!isTagDate) return description ? `${originalTitle} ${description}` : '';+ const [first, second] = originalTitle.split('-');+ const format = (val: string) => {+ const ts = convertToTimestamp(val);+ return formatDateTime(ts, val.length > 8);+ };++ let titleText = '';+ if (second && !isNaN(+first) && !isNaN(+second)) {+ titleText = `${format(first)} <-> ${format(second)}`;} else {- date = convertToTimestamp(tag.title); //new Date(convertToDate(tag.title)).getTime();- tagTitle = formatDateTime(date, false);+ titleText = format(originalTitle);}- }- if (tag.description) {- tagTitle = tagTitle + ' ' + tag.description;- }+ return description ? `${titleText} ${description}` : titleText;+ }, [isTagDate, originalTitle, description]);- if (isTagDate && title.length > 8) {- title = title.substring(0, 8) + '...';- }+ /** Truncate long date titles for display */+ const displayTitle = useMemo(+ () =>+ isTagDate && originalTitle.length > 8+ ? `${originalTitle.slice(0, 8)}...`+ : originalTitle,+ [isTagDate, originalTitle],+ );++ const tid = useMemo(+ () => `tagContainer_${originalTitle.replace(/\s+/g, '_')}`,+ [originalTitle],+ );++ /** Unified menu handler */+ const handleMenu = useCallback(+ (event: any) => {+ if (!handleTagMenu) return;+ handleTagMenu(event, tag, entry || tagGroup, !!selectedEntries?.length);+ },+ [handleTagMenu, tag, entry, tagGroup, selectedEntries],+ );++ /** Ctrl+Click adds tag */+ const handleClick = useCallback(+ (event: any) => {+ if (event.ctrlKey && addTags) {+ addTags(selectedEntries, [tag]);+ } else {+ handleMenu(event);+ }+ },+ [addTags, selectedEntries, tag, handleMenu],+ );return (- <div+ <Boxrole="presentation"data-tid={tid}- key={tag.id || (tagGroup ? tagGroup.uuid : '') + tid} // don't set unique uuidv1() here - menu anchorEl needs to be the same for the same TagContainer key (or TagMenu will be displayed in top left corner)- onClick={(event) => {- if (event.ctrlKey && addTags) {- const selectedEntryPaths = [];- //selectedEntries.map((entry) => selectedEntryPaths.push(entry.path));- addTags(selectedEntries, [tag]);- // Removing tags doesn't seem to work correctly here, yet. Using sidecar tagging, but the removeTagsFromEntry function in tagging.actions.js- // doesn't recignize it correctly, thinking it's a plain tag and thus tries to rename the files- // } else if (event.shiftKey) {- // const selectedEntryPaths = [];- // selectedEntries.map(entry => selectedEntryPaths.push(entry.path));- // removeTags(selectedEntryPaths, [tag]);- } else if (handleTagMenu) {- handleTagMenu(- event,- tag,- entry || tagGroup,- selectedEntries && selectedEntries.length > 0,- );- }- }}- onContextMenu={(event) => {- if (handleTagMenu) {- handleTagMenu(- event,- tag,- entry || tagGroup,- selectedEntries && selectedEntries.length > 0,- );- }- }}- onDoubleClick={(event) => {- if (handleTagMenu) {- handleTagMenu(- event,- tag,- entry || tagGroup,- selectedEntries && selectedEntries.length > 0,- );- }- }}- style={{- backgroundColor: 'transparent',- display: 'inline-block',- }}+ key={tag.id || (tagGroup?.uuid ?? '') + tid}+ onClick={handleClick}+ onContextMenu={handleMenu}+ onDoubleClick={handleMenu}+ sx={{ display: 'inline-block' }}><TagisDragging={isDragging}tagTitle={tagTitle}- textColor={textColor}- backgroundColor={backgroundColor}+ textColor={txtColor}+ backgroundColor={bgColor}>- <span- style={{- flexGrow: 1,- display: 'flex',- alignItems: 'center',- }}- >+ <Box sx={{ flexGrow: 1, display: 'flex', alignItems: 'center' }}>{(isTagGeo || isGeoSmartTag) && (- <PlaceIcon- sx={{- color: textColor,- height: '16px',- marginLeft: '-5px',- }}- />+ <PlaceIcon sx={{ color: txtColor, height: 16, ml: '-5px' }} />)}{(isTagDate || isDateSmartTag) && (- <DateIcon- sx={{- color: textColor,- height: '16px',- marginLeft: '-5px',- }}- />+ <DateIcon sx={{ color: txtColor, height: 16, ml: '-5px' }} />)}- {!isTagGeo && <span>{title}</span>}- </span>+ {!isTagGeo && <span>{displayTitle}</span>}+ </Box>+<TagContainerMenuhandleRemoveTag={handleRemoveTag}tag={tag}@@ -243,7 +249,7 @@ function TagContainer(props: Props) {deleteIcon={deleteIcon}/></Tag>- </div>+ </Box>);}diff --git a/src/renderer/components/TagContainerMenu.tsx b/src/renderer/components/TagContainerMenu.tsxindex c299d67f7..bbacbcd00 100644--- a/src/renderer/components/TagContainerMenu.tsx+++ b/src/renderer/components/TagContainerMenu.tsx@@ -39,9 +39,9 @@ function TagContainerMenu(props: Props) {deleteIcon || (<RemoveTagIcondata-tid={'tagRemoveButton_' + tag.title?.replace(/ /g, '_')}- style={{+ sx={{color: tag.textcolor,- fontSize: 20,+ fontSize: '20px',}}onClick={(event) =>handleRemoveTag ? handleRemoveTag(event, [tag]) : false@@ -51,10 +51,10 @@ function TagContainerMenu(props: Props) {) : (<MoreMenuIcondata-tid={'tagMoreButton_' + tag.title?.replace(/ /g, '_')}- style={{+ sx={{color: tag.textcolor,- marginLeft: -5,- marginRight: -5,+ marginLeft: '-5px',+ marginRight: '-5px',height: 20,}}/>diff --git a/src/renderer/components/TagGroupContainer.tsx b/src/renderer/components/TagGroupContainer.tsxindex 3c734ac99..6d547a71c 100644--- a/src/renderer/components/TagGroupContainer.tsx+++ b/src/renderer/components/TagGroupContainer.tsx@@ -16,11 +16,12 @@**/-import React, { ReactNode, useRef } from 'react';+import { dataTidFormat } from '-/services/test';+import { TS } from '-/tagspaces.namespace';+import { Box } from '@mui/material';+import { ReactNode, useRef } from 'react';import { DropTargetMonitor, useDrop } from 'react-dnd';import DragItemTypes from './DragItemTypes';-import { TS } from '-/tagspaces.namespace';-import { dataTidFormat } from '-/services/test';interface Props {children: ReactNode;@@ -58,17 +59,16 @@ function TagGroupContainer(props: Props) {border = '2px solid #f7cf00';backgroundColor = '#d9d9d9b5';} else if (canDrop) {- // border = '2px solid gray';backgroundColor = '#d9d9d9b5';}return (- <div+ <Boxref={ref}- style={{+ sx={{margin: 0,padding: 0,- borderRadius: 5,+ borderRadius: '5px',minHeight: 20,border,backgroundColor,@@ -76,7 +76,7 @@ function TagGroupContainer(props: Props) {data-tid={'tagGroupContainer_' + dataTidFormat(props.taggroup.title)}>{props.children}- </div>+ </Box>);}diff --git a/src/renderer/components/TagGroupTitleDnD.tsx b/src/renderer/components/TagGroupTitleDnD.tsxindex 9a7820b3b..0d9e11793 100644--- a/src/renderer/components/TagGroupTitleDnD.tsx+++ b/src/renderer/components/TagGroupTitleDnD.tsx@@ -32,7 +32,7 @@ import { CommonLocation } from '-/utils/CommonLocation';import { Box } from '@mui/material';import Grid from '@mui/material/Grid';import Typography from '@mui/material/Typography';-import React, { useContext, useRef } from 'react';+import { useContext, useRef } from 'react';import { useDrag, useDrop } from 'react-dnd';import { useTranslation } from 'react-i18next';@@ -40,7 +40,7 @@ interface Props {index: number;tagGroup: TS.TagGroup;handleTagGroupMenu: (- event: React.ChangeEvent<HTMLInputElement>,+ event: React.MouseEvent<HTMLElement>,tagGroup: TS.TagGroup,) => void;toggleTagGroup: (uuid: string) => void;@@ -56,6 +56,7 @@ function TagGroupTitleDnD(props: Props) {handleTagGroupMenu,moveTagGroup,toggleTagGroup,+ tagGroupCollapsed,isReadOnly,} = props;const { findLocation } = useCurrentLocationContext();@@ -67,51 +68,47 @@ function TagGroupTitleDnD(props: Props) {): undefined;+ // Determine expanded state from tagGroupCollapsed prop+ const expanded = !(+ tagGroupCollapsed && tagGroupCollapsed.includes(tagGroup.uuid)+ );++ // Drag and drop logic for tag group reorderingconst [, drag] = useDrag({type: DragItemTypes.TAG_GROUP,item: { tagGroup: tagGroup, index: index },});+const dropHover = (dragItem, monitor) => {- // const dragItem = monitor.getItem();const dragIndex = dragItem.index;const hoverIndex = index;- // Don't replace items with themselvesif (dragIndex === hoverIndex) {return;}- // Determine rectangle on screenconst hoverBoundingRect =tagGroupRef && tagGroupRef.current? tagGroupRef.current.getBoundingClientRect()- : undefined; // findDOMNode(component).getBoundingClientRect(); // tagContainerRef.current.getBoundingClientRect();+ : undefined;- // Get vertical middle (bottom = right; top = left)- const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;+ const hoverMiddleY = hoverBoundingRect+ ? (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2+ : 0;- // Determine mouse positionconst clientOffset = monitor.getClientOffset();-- // Get pixels to the top- const hoverClientY = clientOffset.y - hoverBoundingRect.top;-- // Only perform the move when the mouse has crossed half of the items height- // When dragging downwards, only move when the cursor is below 50%- // When dragging upwards, only move when the cursor is above 50%+ const hoverClientY =+ clientOffset && hoverBoundingRect+ ? clientOffset.y - hoverBoundingRect.top+ : 0;// Dragging downwardsif (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) {return;}-// Dragging upwardsif (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) {return;}moveTagGroup(dragItem.tagGroup.uuid, hoverIndex);- // Note: we're mutating the monitor item here!- // Generally it's better to avoid mutations,- // but it's good here for the sake of performance- // to avoid expensive index searches.dragItem.index = hoverIndex;};@@ -150,7 +147,7 @@ function TagGroupTitleDnD(props: Props) {const tagGroupTitle = (<Boxdata-tid={'tagLibraryTagGroupTitle_' + tagGroup.title}- style={{+ sx={{padding: 0,height: '100%',borderRadius: AppConfig.defaultCSSRadius,@@ -161,24 +158,20 @@ function TagGroupTitleDnD(props: Props) {direction="row"alignItems="stretch"alignContent="center"- style={{ flexWrap: 'nowrap' }}+ sx={{ flexWrap: 'nowrap' }}>- <Grid size={2} style={{ maxWidth: 40 }}>+ <Grid size={2} sx={{ maxWidth: 40 }}><TsIconButton- style={{ minWidth: 'auto', padding: 7 }}+ sx={{ minWidth: 'auto', padding: '7px' }}onClick={(event: any) => handleTagGroupTitleClick(event, tagGroup)}size="large">- {tagGroup.expanded ? (- <SmallArrowDownIcon />- ) : (- <SmallArrowRightIcon />- )}+ {expanded ? <SmallArrowDownIcon /> : <SmallArrowRightIcon />}</TsIconButton></Grid>- <Grid size={9} style={{ alignSelf: 'center' }}>+ <Grid size={9} sx={{ alignSelf: 'center' }}><Typography- style={{ paddingLeft: 0 }}+ sx={{ paddingLeft: 0 }}data-tid="locationTitleElement"noWraponClick={(event: any) => handleTagGroupTitleClick(event, tagGroup)}@@ -194,38 +187,37 @@ function TagGroupTitleDnD(props: Props) {{tagGroup.title + getLocationName(tagGroup.locationId)}</TooltipTS>{taggroupWorkspace}- {!tagGroup.expanded && (- <span- style={{+ {!expanded && (+ <Box+ sx={{display: 'inline-block',minWidth: 10,padding: '3px 7px',- fontSize: 10,+ fontSize: '10px',fontWeight: 'normal',- marginLeft: 4,+ marginLeft: '4px',color: '#ffffff',lineHeight: 1,verticalAlign: 'middle',whiteSpace: 'nowrap',textAlign: 'center',backgroundColor: '#bbbbbb',- borderRadius: 10,+ borderRadius: '10px',}}>{tagGroup.children.length}- </span>+ </Box>)}</Typography></Grid>- <Grid size={1} style={{ textAlign: 'end' }}>+ <Grid size={1} sx={{ textAlign: 'end' }}>{!isReadOnly && (<TsIconButton- style={{ minWidth: 'auto', padding: 7 }}+ sx={{ minWidth: 'auto', padding: '7px' }}data-tid={'tagLibraryMoreButton_' + tagGroup.title.replace(/ /g, '_')}onClick={(event: any) => handleTagGroupMenu(event, tagGroup)}- size="large"><MoreMenuIcon /></TsIconButton>@@ -234,6 +226,7 @@ function TagGroupTitleDnD(props: Props) {</Grid></Box>);+if (tagGroup.readOnly) {return tagGroupTitle;}diff --git a/src/renderer/components/TagLibrary.tsx b/src/renderer/components/TagLibrary.tsxindex 6d447fcfd..c0de1da7c 100644--- a/src/renderer/components/TagLibrary.tsx+++ b/src/renderer/components/TagLibrary.tsx@@ -49,18 +49,22 @@ import SmartTags from '-/reducers/smart-tags';import { getAllTags } from '-/services/taglibrary-utils';import { TS } from '-/tagspaces.namespace';import { CommonLocation } from '-/utils/CommonLocation';-import { Box } from '@mui/material';-import Collapse from '@mui/material/Collapse';-import React, { useCallback, useContext, useEffect, useState } from 'react';+import { Box, Collapse } from '@mui/material';+import React, {+ useCallback,+ useContext,+ useEffect,+ useMemo,+ useState,+} from 'react';import { useTranslation } from 'react-i18next';import { useDispatch, useSelector } from 'react-redux';interface Props {- style?: any;reduceHeightBy: number;}-function TagLibrary(props: Props) {+function TagLibrary({ reduceHeightBy }: Props) {const { t } = useTranslation();const {createTagGroup,@@ -79,9 +83,8 @@ function TagLibrary(props: Props) {const tagBackgroundColor = useSelector(getTagColor);const tagTextColor = useSelector(getTagTextColor);const tagGroupCollapsed: Array<string> = useSelector(getTagGroupCollapsed);+ const saveTagInLocation: boolean = useSelector(getSaveTagInLocation);- const toggleTagGroupDispatch = (uuid) =>- dispatch(SettingsActions.toggleTagGroup(uuid));const [tagGroupMenuAnchorEl, setTagGroupMenuAnchorEl] =useState<null | HTMLElement>(null);const [tagMenuAnchorEl, setTagMenuAnchorEl] = useState<null | HTMLElement>(@@ -93,14 +96,11 @@ function TagLibrary(props: Props) {useState<TS.TagGroup>(null);const [selectedTag, setSelectedTag] = useState<TS.Tag>(null);const [isCreateTagGroupDialogOpened, setIsCreateTagGroupDialogOpened] =- useState<boolean>(false);+ useState(false);const [isEditTagGroupDialogOpened, setIsEditTagGroupDialogOpened] =- useState<boolean>(false);- const [isCreateTagDialogOpened, setIsCreateTagDialogOpened] =- useState<boolean>(false);- const [isEditTagDialogOpened, setIsEditTagDialogOpened] =- useState<boolean>(false);- const saveTagInLocation: boolean = useSelector(getSaveTagInLocation);+ useState(false);+ const [isCreateTagDialogOpened, setIsCreateTagDialogOpened] = useState(false);+ const [isEditTagDialogOpened, setIsEditTagDialogOpened] = useState(false);const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext? useContext<TS.WorkSpacesContextData>(@@ -108,119 +108,73 @@ function TagLibrary(props: Props) {): undefined;- const currentWorkSpace =- workSpacesContext && workSpacesContext.getCurrentWorkSpace- ? workSpacesContext?.getCurrentWorkSpace()- : undefined;+ const currentWorkSpace = workSpacesContext?.getCurrentWorkSpace?.();useEffect(() => {if (currentWorkSpace) {const workspaceTagGroups = tagGroups.filter((t) => t.workSpaceId === currentWorkSpace.uuid,);- if (workspaceTagGroups?.length) {- setWSpaceTagGroups(workspaceTagGroups);- } else {- setWSpaceTagGroups(tagGroups);- }+ setWSpaceTagGroups(+ workspaceTagGroups.length ? workspaceTagGroups : tagGroups,+ );} else {setWSpaceTagGroups(tagGroups);}}, [currentWorkSpace, tagGroups]);- /*const firstRender = useFirstRender();-- useEffect(() => {- if (Pro && saveTagInLocation && firstRender) {- refreshTagsFromLocation();- }- }, [saveTagInLocation]);-- function refreshTagsFromLocation() {- if (locations && locations.length > 0) {- for (const location of locations) {- getTagGroups(location).then((locationTagGroups) => {- if (locationTagGroups && locationTagGroups.length > 0) {- const oldGroups = getTagLibrary();- if (checkTagGroupModified(locationTagGroups, oldGroups)) {- importTagGroups(locationTagGroups, false, location);- // } else {- // // refresh if localStorage is changed - from new instance- // reflectTagLibraryChanged(oldGroups);- }- }- });- }- }- }- function checkTagGroupModified(- newGroups: Array<TS.TagGroup>,- oldGroups: Array<TS.TagGroup>,- ) {- return !newGroups.every((newGroup) =>- oldGroups.some(- (oldGroup) =>- newGroup.uuid === oldGroup.uuid &&- newGroup.modified_date <= oldGroup.modified_date,- ),- );- }*/+ const toggleTagGroupDispatch = useCallback(+ (uuid: string) => dispatch(SettingsActions.toggleTagGroup(uuid)),+ [dispatch],+ );- const handleTagGroupMenu = (- event: React.ChangeEvent<HTMLInputElement>,- tagGroup,- ) => {- setTagGroupMenuAnchorEl(event.currentTarget);- setSelectedTagGroupEntry(tagGroup);- };+ const handleTagGroupMenu = useCallback(+ (event: React.MouseEvent<HTMLElement>, tagGroup: TS.TagGroup) => {+ setTagGroupMenuAnchorEl(event.currentTarget);+ setSelectedTagGroupEntry(tagGroup);+ },+ [],+ );- const handleTagMenuCallback = useCallback(+ const handleTagMenu = useCallback((- event: React.ChangeEvent<HTMLInputElement>,- tag,+ event: React.MouseEvent<HTMLElement>,+ tag: TS.Tag,tagGroup: TS.TagGroup,haveSelectedEntries: boolean,) => {- handleTagMenu(event, tag, tagGroup, haveSelectedEntries);+ const isSmartTag = tag.functionality && tag.functionality.length > 0;+ if (!isSmartTag || haveSelectedEntries) {+ setTagMenuAnchorEl(event.currentTarget);+ setSelectedTagGroupEntry(tagGroup);+ setSelectedTag(tag);+ }},[],);- const handleTagMenu = (- event: React.ChangeEvent<HTMLInputElement>,- tag,- tagGroup: TS.TagGroup,- haveSelectedEntries: boolean,- ) => {- // if (!tagGroup.readOnly) { Smart Tags are readonly but needs to have TagMenu- const isSmartTag = tag.functionality && tag.functionality.length > 0;- if (!isSmartTag || haveSelectedEntries) {- setTagMenuAnchorEl(event.currentTarget);- setSelectedTagGroupEntry(tagGroup);- setSelectedTag(tag);- }- };-- const handleTagLibraryMenu = (event: any) => {- setTagLibraryMenuAnchorEl(event.currentTarget);- };+ const handleTagLibraryMenu = useCallback(+ (event: React.MouseEvent<HTMLElement>) => {+ setTagLibraryMenuAnchorEl(event.currentTarget);+ },+ [],+ );- const showCreateTagGroupDialog = () => {+ const showCreateTagGroupDialog = useCallback(() => {setIsCreateTagGroupDialogOpened(true);- // this.setState({ isCreateTagGroupDialogOpened: true });- };+ }, []);- const showCreateTagsDialog = () => {+ const showCreateTagsDialog = useCallback(() => {setIsCreateTagDialogOpened(true);setTagGroupMenuAnchorEl(null);- };+ }, []);- const showEditTagGroupDialog = () => {+ const showEditTagGroupDialog = useCallback(() => {setIsEditTagGroupDialogOpened(true);setTagGroupMenuAnchorEl(null);- };+ }, []);- const showDeleteTagGroupDialog = () => {+ const showDeleteTagGroupDialog = useCallback(() => {openConfirmDialog(t('core:deleteTagGroup'),t('core:deleteTagGroupContentConfirm', {@@ -235,74 +189,71 @@ function TagLibrary(props: Props) {'confirmDeleteTagGroupDialog',);setTagGroupMenuAnchorEl(null);- };-- const renderTagGroup = (tagGroup, index) => {- if (!saveTagInLocation && tagGroup.locationId) {- return null;- }- // eslint-disable-next-line no-param-reassign- tagGroup.expanded = !(- tagGroupCollapsed && tagGroupCollapsed.includes(tagGroup.uuid)- );+ }, [openConfirmDialog, removeTagGroup, selectedTagGroupEntry, t]);- return (- <div key={tagGroup.uuid}>- <TagGroupTitleDnD- index={index}- tagGroup={tagGroup}- moveTagGroup={(tagGroupUuid, position) => {- moveTagGroup(tagGroupUuid, position);- }}- handleTagGroupMenu={handleTagGroupMenu}- toggleTagGroup={toggleTagGroupDispatch}- tagGroupCollapsed={tagGroupCollapsed}- isReadOnly={tagGroup.readOnly}- />- <CustomDragLayer />- <Collapse in={tagGroup.expanded} unmountOnExit>- <TagGroupContainer taggroup={tagGroup}>- {tagGroup.children &&- tagGroup.children.map((tag: TS.Tag, idx) => {- const isSmartTag =- tag.functionality && tag.functionality.length > 0;- return (- <TagContainerDnd- key={tagGroup.uuid + tag.title}- // tagContainerRef={tagContainerRef}- index={idx}- tag={tag}- tagGroup={tagGroup}- tagMode={isSmartTag ? 'display' : 'default'}- handleTagMenu={handleTagMenuCallback}- moveTag={(- tagTitle: string,- fromTagGroupId: TS.Uuid,- toTagGroupId: TS.Uuid,- ) => moveTag(tagTitle, fromTagGroupId, toTagGroupId)}- changeTagOrder={(- tagGroupUuid: TS.Uuid,- fromIndex: number,- toIndex: number,- ) => changeTagOrder(tagGroupUuid, fromIndex, toIndex)}- selectedEntries={selectedEntries}- />- );- })}- </TagGroupContainer>- </Collapse>- </div>- );- };+ const renderTagGroup = useCallback(+ (tagGroup, index: number) => {+ if (!saveTagInLocation && tagGroup.locationId) return null;+ const expanded = !(+ tagGroupCollapsed && tagGroupCollapsed.includes(tagGroup.uuid)+ );+ return (+ <Box key={tagGroup.uuid}>+ <TagGroupTitleDnD+ index={index}+ tagGroup={tagGroup}+ moveTagGroup={moveTagGroup}+ handleTagGroupMenu={handleTagGroupMenu}+ toggleTagGroup={toggleTagGroupDispatch}+ tagGroupCollapsed={tagGroupCollapsed}+ isReadOnly={tagGroup.readOnly}+ />+ <CustomDragLayer />+ <Collapse in={expanded} unmountOnExit>+ <TagGroupContainer taggroup={tagGroup}>+ {tagGroup.children &&+ tagGroup.children.map((tag: TS.Tag, idx: number) => {+ const isSmartTag =+ tag.functionality && tag.functionality.length > 0;+ return (+ <TagContainerDnd+ key={tagGroup.uuid + tag.title}+ index={idx}+ tag={tag}+ tagGroup={tagGroup}+ tagMode={isSmartTag ? 'display' : 'default'}+ handleTagMenu={handleTagMenu}+ moveTag={moveTag}+ changeTagOrder={changeTagOrder}+ selectedEntries={selectedEntries}+ />+ );+ })}+ </TagGroupContainer>+ </Collapse>+ </Box>+ );+ },+ [+ saveTagInLocation,+ tagGroupCollapsed,+ moveTagGroup,+ handleTagGroupMenu,+ toggleTagGroupDispatch,+ handleTagMenu,+ moveTag,+ changeTagOrder,+ selectedEntries,+ ],+ );- const { reduceHeightBy } = props;+ const allTags = useMemo(() => getAllTags(wSpaceTagGroups), [wSpaceTagGroups]);- const allTags = getAllTags(wSpaceTagGroups);return (<Box- style={{+ sx={{height: '100%',- paddingLeft: 5,+ paddingLeft: '5px',paddingRight: 0,display: 'flex',flexDirection: 'column',@@ -310,15 +261,8 @@ function TagLibrary(props: Props) {><SidePanelTitletitle={t('core:tagLibrary')}- tooltip={- 'Your tag library contains ' +- allTags.length +- ' tags \ndistributed in ' +- wSpaceTagGroups.length +- ' tag groups'- }+ tooltip={`Your tag library contains ${allTags.length} tags \ndistributed in ${wSpaceTagGroups.length} tag groups`}menuButton={- // Display the menu button if there are editable tag groups or no tag groups exist (to allow creating new ones)(wSpaceTagGroups.some((tg) => !tg.readOnly) ||wSpaceTagGroups.length === 0) && (<TsIconButton@@ -380,7 +324,6 @@ function TagLibrary(props: Props) {/>{Boolean(tagMenuAnchorEl) && (<TagMenu- // key={'tag_' + selectedTag.path}anchorEl={tagMenuAnchorEl}open={Boolean(tagMenuAnchorEl)}onClose={() => setTagMenuAnchorEl(null)}@@ -397,12 +340,12 @@ function TagLibrary(props: Props) {selectedTag={selectedTag}/>)}- <div- style={{+ <Box+ sx={{paddingTop: 0,marginTop: 0,- borderRadius: 5,- height: 'calc(100% - ' + reduceHeightBy + 'px)',+ borderRadius: '5px',+ height: `calc(100% - ${reduceHeightBy}px)`,width: 310,overflowY: 'auto',overflowX: 'hidden',@@ -410,16 +353,14 @@ function TagLibrary(props: Props) {data-tid="tagLibraryTagGroupList">{AppConfig.showSmartTags && (- <div style={{ paddingTop: 0, paddingBottom: 0 }}>+ <Box sx={{ paddingTop: 0, paddingBottom: 0 }}>{SmartTags(t).map(renderTagGroup)}- </div>+ </Box>)}- <div style={{ paddingTop: 0 }}>- {wSpaceTagGroups.map(renderTagGroup)}- </div>- </div>+ <Box sx={{ paddingTop: 0 }}>{wSpaceTagGroups.map(renderTagGroup)}</Box>+ </Box></Box>);}-export default TagLibrary;+export default React.memo(TagLibrary);diff --git a/src/renderer/components/TagsPreview.tsx b/src/renderer/components/TagsPreview.tsxindex 1dd291681..1542fa363 100644--- a/src/renderer/components/TagsPreview.tsx+++ b/src/renderer/components/TagsPreview.tsx@@ -20,10 +20,11 @@ import Tooltip from '-/components/Tooltip';import { TS } from '-/tagspaces.namespace';import { useSelector } from 'react-redux';+import { useEditedTagLibraryContext } from '-/hooks/useEditedTagLibraryContext';import { getTagColor, getTagTextColor } from '-/reducers/settings';import { getTagColors } from '-/services/taglibrary-utils';+import { Box } from '@mui/material';import { useTranslation } from 'react-i18next';-import { useEditedTagLibraryContext } from '-/hooks/useEditedTagLibraryContext';interface Props {tags: Array<TS.Tag>;@@ -36,7 +37,7 @@ function TagsPreview(props: Props) {const defaultTextColor = useSelector(getTagTextColor);const { tags } = props;- // const allTags = useRef<Array<TS.Tag>>(getAllTags(getTagLibrary()));+if (!tags || tags.length < 1) {return <></>;}@@ -79,19 +80,19 @@ function TagsPreview(props: Props) {}return (<Tooltip title={tagNames}>- <span- style={{+ <Box+ sx={{display: 'inline-block',minWidth: 15,width: 18,height: 15,- marginLeft: 4,- marginRight: 4,- borderRadius: 7,+ marginLeft: '4px',+ marginRight: '4px',+ borderRadius: '7px',borderRight: moreThanOne ? 'white 1px solid' : 'initial',boxShadow: moreThanOne ? '4px 0px 0px 0px ' + secondTagColor : 'none',backgroundColor: firstTagColor,- fontSize: 11,+ fontSize: '11px',lineHeight: '16px',color: firstTagTextColor || defaultTextColor, //tag1Colors.textcolor ,textAlign: 'center',@@ -100,7 +101,7 @@ function TagsPreview(props: Props) {}}>{moreThanOne ? tags.length : '1'}- </span>+ </Box></Tooltip>);}diff --git a/src/renderer/components/TagsSelect.tsx b/src/renderer/components/TagsSelect.tsxindex 2a9963655..736efde35 100644--- a/src/renderer/components/TagsSelect.tsx+++ b/src/renderer/components/TagsSelect.tsx@@ -21,6 +21,8 @@ import TsTextField from '-/components/TsTextField';import AiGenTagsButton from '-/components/chat/AiGenTagsButton';import EntryTagMenu from '-/components/menus/EntryTagMenu';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';+import { useEditedTagLibraryContext } from '-/hooks/useEditedTagLibraryContext';+import { Pro } from '-/pro';import {getTagColor,getTagTextColor,@@ -43,8 +45,6 @@ import React, {} from 'react';import { useTranslation } from 'react-i18next';import { useSelector } from 'react-redux';-import { useEditedTagLibraryContext } from '-/hooks/useEditedTagLibraryContext';-import { Pro } from '-/pro';interface Props {dataTid?: string;@@ -237,11 +237,9 @@ function TagsSelect(props: Props) {{...params}label={label}placeholder={placeholderText}- margin="normal"autoFocus={autoFocus}error={tagsError.current}- style={{ marginTop: 0, marginBottom: 0, whiteSpace: 'nowrap' }}- fullWidth+ sx={{ marginTop: 0, marginBottom: 0, whiteSpace: 'nowrap' }}slotProps={{input: {...params.InputProps,diff --git a/src/renderer/components/Tooltip.tsx b/src/renderer/components/Tooltip.tsxindex 01328a558..13812320d 100644--- a/src/renderer/components/Tooltip.tsx+++ b/src/renderer/components/Tooltip.tsx@@ -45,8 +45,8 @@ function TooltipTS(props: Props) {title,placement = 'top',keyBinding,- children,placeCloser = false,+ ...restProps} = props;let tooltipText = title;if (keyBinding) {@@ -54,7 +54,6 @@ function TooltipTS(props: Props) {}return (<Tooltip- children={children}arrowtitle={tooltipText}disableInteractive@@ -71,6 +70,7 @@ function TooltipTS(props: Props) {],},}}+ {...restProps}/>);}diff --git a/src/renderer/components/TsButton.tsx b/src/renderer/components/TsButton.tsxindex 6e267a11f..acda4c2ff 100644--- a/src/renderer/components/TsButton.tsx+++ b/src/renderer/components/TsButton.tsx@@ -40,7 +40,7 @@ export type TSButtonProps = ButtonProps & {//function TsButton(props: TSButtonProps) {const TsButton = React.forwardRef<HTMLButtonElement, TSButtonProps>(function TsButton(props, ref) {- const { children, style, tooltip, loading, startIcon, ...rest } = props;+ const { children, sx, tooltip, loading, startIcon, ...rest } = props;const desktopMode = useSelector(isDesktopMode);const button = (<Button@@ -50,12 +50,12 @@ const TsButton = React.forwardRef<HTMLButtonElement, TSButtonProps>({...(startIcon && { startIcon: startIcon })}variant="outlined" // text outlined contained{...rest}- style={{+ sx={{borderRadius: AppConfig.defaultCSSRadius,textTransform: 'none', //'capitalize',- fontSize: 14,+ fontSize: '14px',fontWeight: 'normal',- ...style,+ ...sx,}}>{children}diff --git a/src/renderer/components/TsDatePicker.tsx b/src/renderer/components/TsDatePicker.tsxindex b6de12c7c..de17dd49a 100644--- a/src/renderer/components/TsDatePicker.tsx+++ b/src/renderer/components/TsDatePicker.tsx@@ -18,18 +18,19 @@import AppConfig from '-/AppConfig';import { isDesktopMode } from '-/reducers/settings';+import { Box } from '@mui/material';import FormHelperText from '@mui/material/FormHelperText';import { alpha, useTheme } from '@mui/material/styles';import { DatePicker } from '@mui/x-date-pickers';import { useSelector } from 'react-redux';function TsDatePicker(props) {- const { children, label } = props;+ const { label, ...restProps } = props;const theme = useTheme();const desktopMode = useSelector(isDesktopMode);return (- <div>+ <Box>{label && (<FormHelperText style={{ marginLeft: 5, marginTop: 0 }}>{label}@@ -37,7 +38,10 @@ function TsDatePicker(props) {)}<DatePickersx={{+ border: '0px transparent !important',+ borderRadius: AppConfig.defaultCSSRadius,backgroundColor: alpha(theme.palette.divider, 0.2),+ transition: '0.3s','&:hover': {backgroundColor: alpha(theme.palette.divider, 0.5),},@@ -45,28 +49,24 @@ function TsDatePicker(props) {backgroundColor: 'transparent !important',borderRadius: AppConfig.defaultCSSRadius,},- borderRadius: AppConfig.defaultCSSRadius,- transition: '0.3s',- '&:hover .MuiOutlinedInput-notchedOutline': {- border: '2px solid transparent !important',+ '& .MuiPickersOutlinedInput-root': {+ border: '0px solid transparent !important',borderRadius: AppConfig.defaultCSSRadius,},- '& .MuiOutlinedInput-notchedOutline': {- border: '2px solid transparent',+ '&:hover .MuiPickersOutlinedInput-root': {+ border: '0px transparent !important',borderRadius: AppConfig.defaultCSSRadius,},- '& .Mui-focused .MuiOutlinedInput-notchedOutline': {- border: `2px solid ${alpha(theme.palette.divider, 0.5)} !important`,+ '& .Mui-focused .MuiPickersOutlinedInput-root': {+ border: `0px solid ${alpha(theme.palette.divider, 0.5)} !important`,borderRadius: AppConfig.defaultCSSRadius,},}}format="yyyy-MM-dd"- {...props}+ {...restProps}label={undefined}- >- {children}- </DatePicker>- </div>+ />+ </Box>);}diff --git a/src/renderer/components/TsIconButton.tsx b/src/renderer/components/TsIconButton.tsxindex 6919bdb16..4339bba88 100644--- a/src/renderer/components/TsIconButton.tsx+++ b/src/renderer/components/TsIconButton.tsx@@ -20,6 +20,7 @@ import AppConfig from '-/AppConfig';import TooltipTS from '-/components/Tooltip';import { isDesktopMode } from '-/reducers/settings';import IconButton, { IconButtonProps } from '@mui/material/IconButton';+import React, { useMemo } from 'react';import { useSelector } from 'react-redux';export type TSIconButtonProps = IconButtonProps & {@@ -27,27 +28,39 @@ export type TSIconButtonProps = IconButtonProps & {keyBinding?: string;};-function TsIconButton(props: TSIconButtonProps) {- const { children, style, keyBinding, tooltip, disabled, ...restProps } =- props;+const TsIconButton: React.FC<TSIconButtonProps> = ({+ children,+ sx,+ keyBinding,+ tooltip,+ disabled,+ ...restProps+}) => {const desktopMode = useSelector(isDesktopMode);- const iconButton = (- <IconButton- size={desktopMode ? 'medium' : 'large'}- style={{ borderRadius: AppConfig.defaultCSSRadius, ...style }}- disabled={disabled}- {...restProps}- >- {children}- </IconButton>- );- return tooltip && !disabled ? (- <TooltipTS keyBinding={keyBinding} title={tooltip}>- {iconButton}- </TooltipTS>- ) : (- iconButton++ // Memoize the icon button for performance+ const iconButton = useMemo(+ () => (+ <IconButton+ size={desktopMode ? 'medium' : 'large'}+ sx={{ borderRadius: AppConfig.defaultCSSRadius, ...sx }}+ disabled={disabled}+ {...restProps}+ >+ {children}+ </IconButton>+ ),+ [desktopMode, sx, disabled, restProps, children],);-}-export default TsIconButton;+ if (tooltip && !disabled) {+ return (+ <TooltipTS keyBinding={keyBinding} title={tooltip}>+ {iconButton}+ </TooltipTS>+ );+ }+ return iconButton;+};++export default React.memo(TsIconButton);diff --git a/src/renderer/components/TsMenuList.tsx b/src/renderer/components/TsMenuList.tsxindex 5e2e4dbb4..aa3b2cb86 100644--- a/src/renderer/components/TsMenuList.tsx+++ b/src/renderer/components/TsMenuList.tsx@@ -16,26 +16,18 @@**/-import React from 'react';-import { useSelector } from 'react-redux';-import MenuList, { MenuListProps } from '@mui/material/MenuList';import { isDesktopMode } from '-/reducers/settings';-import AppConfig from '-/AppConfig';+import MenuList, { MenuListProps } from '@mui/material/MenuList';+import { useSelector } from 'react-redux';export type TSButtonProps = MenuListProps & {};function TsMenuList(props: TSButtonProps) {- const { children, style } = props;+ const { children } = props;const desktopMode = useSelector(isDesktopMode);return (- <MenuList- dense={desktopMode ? true : false}- {...props}- style={{- ...style,- }}- >+ <MenuList dense={desktopMode ? true : false} {...props}>{children}</MenuList>);diff --git a/src/renderer/components/TsSelect.tsx b/src/renderer/components/TsSelect.tsxindex d8439c263..56f74440b 100644--- a/src/renderer/components/TsSelect.tsx+++ b/src/renderer/components/TsSelect.tsx@@ -17,40 +17,36 @@*/import TsTextField from '-/components/TsTextField';-import { isDesktopMode } from '-/reducers/settings';+import { Box } from '@mui/material';import FormHelperText from '@mui/material/FormHelperText';import { TextFieldProps } from '@mui/material/TextField';-import { useTheme } from '@mui/material/styles';-import { useSelector } from 'react-redux';type TSSelectProps = TextFieldProps & {};function TsSelect(props: TSSelectProps) {- const { children, label, fullWidth = true } = props;- const theme = useTheme();- const desktopMode = useSelector(isDesktopMode);+ const { children, label, fullWidth = true, ...restProps } = props;return (- <div style={{ width: fullWidth ? '100%' : 'auto' }}>- <FormHelperText style={{ marginLeft: 5, marginTop: 0 }}>+ <Box sx={{ width: fullWidth ? '100%' : 'auto' }}>+ <FormHelperText sx={{ marginLeft: '5px', marginTop: 0 }}>{label}</FormHelperText><TsTextFieldslotProps={{select: { displayEmpty: true },}}- style={{+ sx={{cursor: 'context-menu',marginTop: 0,}}fullWidth={fullWidth}select- {...props}+ {...restProps}label={undefined}>{children}</TsTextField>- </div>+ </Box>);}diff --git a/src/renderer/components/TsTabPanel.tsx b/src/renderer/components/TsTabPanel.tsxindex dd2bd269a..bea751452 100644--- a/src/renderer/components/TsTabPanel.tsx+++ b/src/renderer/components/TsTabPanel.tsx@@ -16,6 +16,7 @@**/+import { Box } from '@mui/material';import React from 'react';interface TabPanelProps {@@ -28,23 +29,23 @@ function TsTabPanel(props: TabPanelProps) {const { children, value, index, ...other } = props;return (- <div+ <Boxrole="tabpanel"hidden={value !== index}id={`simple-tabpanel-${index}`}aria-labelledby={`simple-tab-${index}`}{...other}- style={{+ sx={{height: '100%',overflowY: 'auto',overflowX: 'hidden',- paddingTop: 5,- paddingLeft: 10,- paddingRight: 10,+ paddingTop: '5px',+ paddingLeft: '10px',+ paddingRight: '10px',}}>{children}- </div>+ </Box>);}diff --git a/src/renderer/components/TsTextField.tsx b/src/renderer/components/TsTextField.tsxindex ac6e3af1e..b2c35e766 100644--- a/src/renderer/components/TsTextField.tsx+++ b/src/renderer/components/TsTextField.tsx@@ -20,6 +20,7 @@ import AppConfig from '-/AppConfig';import TsMenuList from '-/components/TsMenuList';import MenuKeyBinding from '-/components/menus/MenuKeyBinding';import { isDesktopMode } from '-/reducers/settings';+import { Box } from '@mui/material';import FormHelperText from '@mui/material/FormHelperText';import ListItemText from '@mui/material/ListItemText';import Menu from '@mui/material/Menu';@@ -36,7 +37,8 @@ type TSTextFieldProps = TextFieldProps & {};function TsTextField(props: TSTextFieldProps) {- const { updateValue, retrieveValue, children, label, ...restProps } = props;+ const { updateValue, retrieveValue, children, sx, label, ...restProps } =+ props;const theme = useTheme();const { t } = useTranslation();const desktopMode = useSelector(isDesktopMode);@@ -98,7 +100,7 @@ function TsTextField(props: TSTextFieldProps) {}return (- <div>+ <Box>{label && (<FormHelperText sx={{ marginLeft: '5px', marginTop: 0 }}>{label}@@ -135,6 +137,7 @@ function TsTextField(props: TSTextFieldProps) {border: `2px solid ${alpha(theme.palette.divider, 0.5)} !important`,borderRadius: AppConfig.defaultCSSRadius,},+ ...sx,}}{...restProps}label={undefined}@@ -151,7 +154,7 @@ function TsTextField(props: TSTextFieldProps) {: undefined}>- <TsMenuList style={{ minWidth: 150 }}>+ <TsMenuList sx={{ minWidth: 150 }}><MenuItem onClick={handleCopy}><ListItemText primary={t('core:copy')} /><MenuKeyBinding keyBinding="command+c" />@@ -164,7 +167,7 @@ function TsTextField(props: TSTextFieldProps) {)}</TsMenuList></Menu>- </div>+ </Box>);}diff --git a/src/renderer/components/TsTimePicker.tsx b/src/renderer/components/TsTimePicker.tsxindex 7697825b0..b923e1d8f 100644--- a/src/renderer/components/TsTimePicker.tsx+++ b/src/renderer/components/TsTimePicker.tsx@@ -18,18 +18,19 @@import AppConfig from '-/AppConfig';import { isDesktopMode } from '-/reducers/settings';+import { Box } from '@mui/material';import FormHelperText from '@mui/material/FormHelperText';import { alpha, useTheme } from '@mui/material/styles';import { TimePicker } from '@mui/x-date-pickers';import { useSelector } from 'react-redux';function TsTimePicker(props) {- const { children, label } = props;+ const { label, ...restProps } = props;const theme = useTheme();const desktopMode = useSelector(isDesktopMode);return (- <div>+ <Box>{label && (<FormHelperText sx={{ marginLeft: '5px', marginTop: 0 }}>{label}@@ -37,7 +38,10 @@ function TsTimePicker(props) {)}<TimePickersx={{+ border: '0px transparent !important',+ borderRadius: AppConfig.defaultCSSRadius,backgroundColor: alpha(theme.palette.divider, 0.2),+ transition: '0.3s','&:hover': {backgroundColor: alpha(theme.palette.divider, 0.5),},@@ -45,27 +49,23 @@ function TsTimePicker(props) {backgroundColor: 'transparent !important',borderRadius: AppConfig.defaultCSSRadius,},- borderRadius: AppConfig.defaultCSSRadius,- transition: '0.3s',- '&:hover .MuiOutlinedInput-notchedOutline': {- border: '2px solid transparent !important',+ '& .MuiPickersOutlinedInput-root': {+ border: '0px solid transparent !important',borderRadius: AppConfig.defaultCSSRadius,},- '& .MuiOutlinedInput-notchedOutline': {- border: '2px solid transparent',+ '&:hover .MuiPickersOutlinedInput-root': {+ border: '0px transparent !important',borderRadius: AppConfig.defaultCSSRadius,},- '& .Mui-focused .MuiOutlinedInput-notchedOutline': {- border: `2px solid ${alpha(theme.palette.divider, 0.5)} !important`,+ '& .Mui-focused .MuiPickersOutlinedInput-root': {+ border: `0px solid ${alpha(theme.palette.divider, 0.5)} !important`,borderRadius: AppConfig.defaultCSSRadius,},}}- {...props}+ {...restProps}label={undefined}- >- {children}- </TimePicker>- </div>+ />+ </Box>);}diff --git a/src/renderer/components/TsToggleButton.tsx b/src/renderer/components/TsToggleButton.tsxindex 648611c7f..bbac79a00 100644--- a/src/renderer/components/TsToggleButton.tsx+++ b/src/renderer/components/TsToggleButton.tsx@@ -34,20 +34,20 @@ export type TSToggleButtonProps = ToggleButtonProps & {};function TsToggleButton(props: TSToggleButtonProps) {- const { children, style, tooltip, selected, ...rest } = props;+ const { children, sx, tooltip, selected, ...rest } = props;const desktopMode = useSelector(isDesktopMode);let button = (<ToggleButtonsize={desktopMode ? 'small' : 'medium'}variant="outlined" // text outlined contained{...rest}- style={{+ sx={{borderRadius: AppConfig.defaultCSSRadius,textTransform: 'none', //'capitalize',fontSize: 14,// fontWeight: selected ? 'bold' : 'normal',fontWeight: 'normal',- ...style,+ ...sx,}}>{children}diff --git a/src/renderer/components/chat/AiGenDescButton.tsx b/src/renderer/components/chat/AiGenDescButton.tsxindex ca99963de..1a9ebb5a4 100644--- a/src/renderer/components/chat/AiGenDescButton.tsx+++ b/src/renderer/components/chat/AiGenDescButton.tsx@@ -113,7 +113,7 @@ function AiGenDescButton(props: Props) {disabled={disabled}// tooltip={t('core:openGenSettings')}aria-label={t('core:openGenSettings')}- data-tid="fileContainerPrevFile"+ data-tid="openGenSettingsAIDesc"onClick={() => {openAiGenerationDialog('summary', [openedEntry]);}}diff --git a/src/renderer/components/chat/AiGenTagsButton.tsx b/src/renderer/components/chat/AiGenTagsButton.tsxindex 06a8270e8..d26ede6fb 100644--- a/src/renderer/components/chat/AiGenTagsButton.tsx+++ b/src/renderer/components/chat/AiGenTagsButton.tsx@@ -136,7 +136,7 @@ function AiGenTagsButton(props: Props) {disabled={disabled}// tooltip={t('core:openGenSettings')}aria-label={t('core:openGenSettings')}- data-tid="fileContainerPrevFile"+ data-tid="openGenSettingsAITags"onClick={() => {openAiGenerationDialog('tags');}}diff --git a/src/renderer/components/chat/ChatView.tsx b/src/renderer/components/chat/ChatView.tsxindex f52b62566..36bf17ca2 100644--- a/src/renderer/components/chat/ChatView.tsx+++ b/src/renderer/components/chat/ChatView.tsx@@ -16,7 +16,7 @@**/-import { CloseIcon, MoreMenuIcon } from '-/components/CommonIcons';+import { CloseIcon, MoreMenuIcon, OllamaIcon } from '-/components/CommonIcons';import DragItemTypes from '-/components/DragItemTypes';import Tooltip from '-/components/Tooltip';import TsIconButton from '-/components/TsIconButton';@@ -25,7 +25,6 @@ import ChatDndTargetFile from '-/components/chat/ChatDndTargetFile';import ChatMenu from '-/components/chat/ChatMenu';import { AIProvider, ChatMode } from '-/components/chat/ChatTypes';import SelectChatModel from '-/components/chat/SelectChatModel';-import { OllamaIcon } from '-/components/dialogs/components/Ollama';import ChatMdEditor from '-/components/md/ChatMdEditor';import { CrepeRef } from '-/components/md/useCrepeHandler';import { useChatContext } from '-/hooks/useChatContext';@@ -206,12 +205,7 @@ function ChatView() {overflow: 'hidden',}}>- <Grid- container- spacing={0}- direction="row"- style={{ flexFlow: 'nowrap' }}- >+ <Grid container spacing={0} direction="row" sx={{ flexFlow: 'nowrap' }}><Grid size={11.5}><SelectChatModelid="chatModelId"@@ -223,7 +217,7 @@ function ChatView() {</Grid><Grid><TsIconButton- style={{ marginTop: 20 }}+ sx={{ marginTop: '20px' }}tooltip={t('core:moreActions')}onClick={handleMoreClick}data-tid="moreActionsTID"@@ -268,7 +262,7 @@ function ChatView() {<Grid>{images.length > 0 &&images.map((image, index) => (- <Box position="relative" style={{ float: 'right' }}>+ <Box position="relative" sx={{ float: 'right' }}><imgsrc={'data:image/' +@@ -319,7 +313,7 @@ function ChatView() {slotProps={{input: {startAdornment: (- <InputAdornment position="start" style={{ height: 32 }}>+ <InputAdornment position="start" sx={{ height: 32 }}><Tooltiptitle={aiDefaultProvider?.name +@@ -327,12 +321,12 @@ function ChatView() {aiDefaultProvider?.engine}>- <OllamaIcon height={25} />+ <OllamaIcon /></Tooltip></InputAdornment>),endAdornment: (- <InputAdornment position="end" style={{ height: 32 }}>+ <InputAdornment position="end" sx={{ height: 32 }}>{isTyping && (<CircularProgress size={24} color="inherit" />)}diff --git a/src/renderer/components/dialogs/components/Ollama.tsx b/src/renderer/components/dialogs/components/Ollama.tsxdeleted file mode 100644index ef7b05c9c..000000000--- a/src/renderer/components/dialogs/components/Ollama.tsx+++ /dev/null@@ -1,21 +0,0 @@-import React from 'react';--export const OllamaIcon = React.forwardRef<- SVGSVGElement,- React.SVGProps<SVGSVGElement>->((props, ref) => {- return (- <svg- xmlns="http://www.w3.org/2000/svg"- fill="currentColor"- fillRule="evenodd"- viewBox="0 0 646 854"- ref={ref}- {...props}- >- <path d="M140.629.24c-7.969 1.287-17.532 5.456-24.275 10.605-20.413 15.51-36.229 48.428-42.91 89.438-2.514 15.509-4.23 37.026-4.23 53.455 0 19.371 2.268 44.136 5.517 61.239.736 3.801 1.103 7.173.797 7.418-.245.245-3.25 2.697-6.62 5.394-11.525 9.195-24.705 23.356-33.778 36.291-17.41 24.704-28.688 52.78-33.409 83.185-1.839 12.015-2.33 36.29-.858 48.305 3.25 27.708 11.586 51.125 25.87 72.581l4.658 6.927-1.349 2.268c-9.563 16.061-17.716 39.294-21.516 61.607-3.004 17.655-3.372 22.375-3.372 46.037 0 23.847.307 28.567 3.127 45.057 3.371 19.739 10.237 40.642 17.9 54.558 2.513 4.536 8.643 13.976 9.378 14.467.246.122-.49 2.39-1.655 5.026-8.827 19.31-16.367 44.995-19.493 66.635-2.207 14.834-2.514 19.616-2.514 35.248 0 19.922 1.104 29.608 5.272 45.485l.613 2.329h52.535l-1.716-3.249c-10.605-19.616-11.586-56.029-2.452-92.38 4.168-16.797 8.888-29.118 17.716-46.099l5.272-10.298v-6.314c0-5.885-.123-6.559-2.023-10.421-1.472-2.943-3.433-5.456-6.927-8.889-5.947-5.762-10.238-11.831-13.67-19.31-15.08-32.735-18.023-81.346-7.418-122.786 4.414-17.287 11.709-32.673 19.371-41.071 5.21-5.763 7.908-12.199 7.908-18.881 0-6.927-2.452-12.628-7.97-18.574-15.815-16.919-25.562-37.517-29.056-61.485-4.965-34.145 4.046-71.355 24.52-100.84 20.046-28.935 48.183-47.509 79.631-52.474 7.049-1.165 20.229-.981 27.585.368 8.031 1.41 13.057.98 18.207-1.472 6.375-3.003 9.563-6.743 13.302-15.325 3.31-7.662 5.885-11.831 12.812-20.474 8.337-10.36 16.367-17.41 29.24-25.931 14.713-9.624 31.448-16.612 48.122-19.984 6.068-1.226 8.888-1.41 20.229-1.41s14.161.184 20.229 1.41c24.459 4.966 48.735 17.594 68.106 35.493 4.168 3.862 14.16 16.245 17.348 21.395 1.226 2.022 3.372 6.314 4.72 9.501 3.739 8.582 6.927 12.322 13.302 15.325 4.966 2.391 10.176 2.882 17.9 1.594 12.199-2.084 21.578-1.9 33.532.552 40.704 8.214 76.136 41.746 91.829 86.68 13.67 39.416 9.808 80.672-10.544 112.18-3.433 5.334-6.866 9.625-11.831 14.897-10.728 11.463-10.728 25.685-.061 37.455 17.532 19.187 28.505 66.389 25.194 108.012-2.206 27.463-9.256 52.045-18.942 65.96-1.716 2.452-5.271 6.62-7.969 9.195-3.494 3.433-5.455 5.946-6.927 8.889-1.9 3.862-2.023 4.536-2.023 10.421v6.314l5.272 10.298c8.828 16.981 13.548 29.302 17.716 46.099 9.012 35.861 8.215 71.538-2.084 91.829-.858 1.716-1.594 3.31-1.594 3.494 0 .184 11.709.306 26.053.306h25.992l.674-2.636c.368-1.409.981-3.555 1.287-4.781.675-2.697 2.023-10.666 3.127-18.329 1.042-7.724 1.042-36.168 0-44.75-3.923-31.141-10.483-55.845-21.21-79.201-1.165-2.636-1.901-4.904-1.656-5.026.307-.184 2.023-2.636 3.862-5.395 13.364-20.229 21.578-45.669 25.747-79.262 1.103-9.257 1.103-49.041 0-57.93-2.943-22.926-6.498-38.497-12.383-54.251-2.452-6.559-8.95-20.413-11.708-24.888l-1.349-2.268 4.659-6.927c14.283-21.456 22.62-44.873 25.869-72.581 1.471-12.015.981-36.29-.858-48.305-4.782-30.467-16-58.42-33.409-83.185-9.073-12.935-22.253-27.096-33.777-36.291-3.372-2.697-6.376-5.149-6.621-5.394-.306-.245.062-3.617.797-7.418 7.418-38.681 7.172-86.924-.613-124.625-6.743-32.857-19.003-58.971-34.819-74.051C523.209 4.286 510.336-.864 494.888.117c-35.432 2.085-63.998 42.85-75.278 107.093-1.839 10.36-3.432 22.498-3.432 25.808 0 1.287-.246 2.329-.552 2.329-.307 0-2.697-1.226-5.272-2.758-27.34-16.184-57.746-24.827-87.354-24.827-29.608 0-60.014 8.643-87.354 24.827-2.575 1.532-4.965 2.758-5.272 2.758-.306 0-.552-1.042-.552-2.329 0-3.433-1.655-15.938-3.432-25.808-10.238-57.684-33.716-95.875-64.918-105.499C157.181.424 144.982-.434 140.629.24zm10.422 49.899c8.827 6.988 18.635 26.972 24.275 49.347 1.042 4.046 2.145 8.705 2.452 10.421.245 1.656.919 5.395 1.471 8.276 2.391 12.996 3.494 27.034 3.617 44.137l.061 16.858-4.23 6.252-4.229 6.314h-9.87c-11.524 0-22.988 1.472-33.961 4.414-3.923.981-7.724 1.962-8.459 2.146-1.165.245-1.349-.123-2.023-5.15-3.617-27.279-3.433-57.5.552-82.634 4.413-28.014 14.712-53.393 24.765-60.871 2.391-1.778 2.82-1.717 5.579.49zm349.538-.43c6.069 4.476 12.751 16.368 17.716 31.57 9.992 30.406 12.812 72.152 7.54 111.875-.674 5.027-.858 5.395-2.023 5.15-.735-.184-4.536-1.165-8.459-2.146-10.973-2.942-22.437-4.414-33.961-4.414h-9.87l-4.229-6.314-4.23-6.252.061-16.858c.123-23.785 2.33-42.359 7.601-63.018 5.579-22.19 15.448-42.175 24.214-49.163 2.759-2.207 3.188-2.268 5.64-.43z"></path>- <path d="M313.498 358.237c-13.303 1.288-16.919 1.778-23.295 3.066-10.36 2.145-24.214 6.927-33.838 11.647-33.47 16.367-56.519 43.646-63.569 75.216-1.41 6.253-1.594 8.337-1.594 18.881 0 10.421.184 12.689 1.533 18.635 9.379 41.256 47.385 71.723 96.549 77.301 10.666 1.165 56.765 1.165 67.431 0 39.478-4.475 73.439-25.869 88.703-55.907 4.045-8.03 6.007-13.241 7.846-21.394 1.349-5.946 1.533-8.214 1.533-18.635 0-10.544-.184-12.628-1.594-18.881-10.238-45.853-54.742-81.959-109.3-88.825-7.111-.858-25.746-1.594-30.405-1.104zm22.926 33.348c18.207 1.962 36.536 8.46 51.248 18.268 7.908 5.272 19.065 16.306 23.846 23.54 5.885 8.949 9.256 18.083 10.789 29.179.674 5.088.307 8.95-1.533 17.164-2.881 12.26-11.831 25.072-23.907 34.022-5.64 4.107-17.348 10.054-24.52 12.383-13.609 4.352-22.498 5.149-54.252 4.904-20.719-.184-24.398-.368-30.344-1.471-20.29-3.801-36.351-11.893-47.998-24.214-9.441-9.931-13.732-19.003-16.061-33.654-1.042-6.805.919-18.084 4.904-27.586 4.843-11.586 17.348-25.991 29.731-34.267 14.344-9.563 33.225-16.367 50.573-18.206 6.682-.736 20.842-.736 27.524-.062z"></path>- <path d="M299.584 436.336c-4.659 2.513-7.908 8.888-6.927 13.608 1.103 5.088 5.578 10.238 12.566 14.468 3.74 2.268 3.985 2.574 4.169 4.842.122 1.349-.368 5.211-1.042 8.644-.736 3.371-1.288 6.927-1.288 7.908.062 2.636 2.514 6.927 5.088 9.011 2.269 1.839 2.698 1.9 9.073 2.084 5.824.184 7.05.061 9.379-1.042 6.008-2.943 7.54-8.337 5.333-18.697-1.839-8.643-1.471-9.992 3.127-12.628 4.842-2.82 9.992-7.785 11.524-11.157 2.943-6.436.245-13.731-6.253-17.103-1.593-.797-3.555-1.164-6.436-1.164-4.475 0-7.356 1.042-12.628 4.413l-3.004 1.901-1.9-1.165c-7.785-4.598-9.195-5.149-13.916-5.088-3.371 0-5.21.306-6.865 1.165zM150.744 365.165c-10.85 3.433-18.942 11.402-23.11 22.743-2.023 5.395-3.004 13.916-2.146 18.513 2.023 10.973 11.034 20.965 21.272 23.724 12.873 3.371 22.497 1.164 31.018-7.295 4.965-4.843 7.663-9.073 10.36-15.939 1.961-4.842 2.084-5.7 2.084-12.566l.061-7.356-2.574-5.272c-4.108-8.337-11.525-14.529-20.107-16.797-4.843-1.226-12.628-1.164-16.858.245zM478.153 364.982c-8.398 2.268-15.877 8.52-19.862 16.735l-2.574 5.272.061 7.356c0 6.866.123 7.724 2.084 12.566 2.698 6.866 5.395 11.096 10.36 15.939 8.521 8.459 18.145 10.666 31.019 7.295 7.417-1.962 14.834-8.215 18.39-15.51 3.065-6.191 3.8-10.666 2.82-17.716-2.268-16.122-11.709-27.83-25.747-31.937-4.107-1.226-12.076-1.226-16.551 0z"></path>- </svg>- );-});diff --git a/src/renderer/components/dialogs/components/SettingsAI.tsx b/src/renderer/components/dialogs/components/SettingsAI.tsxindex d65cff0ae..4374a7e1f 100644--- a/src/renderer/components/dialogs/components/SettingsAI.tsx+++ b/src/renderer/components/dialogs/components/SettingsAI.tsx@@ -20,6 +20,7 @@ import AppConfig from '-/AppConfig';import {CreateFileIcon,ExpandIcon,+ OllamaIcon,ReloadIcon,RemoveIcon,} from '-/components/CommonIcons';@@ -31,7 +32,6 @@ import TsSelect from '-/components/TsSelect';import TsTextField from '-/components/TsTextField';import { AIProvider, AIProviders } from '-/components/chat/ChatTypes';import SelectChatModel from '-/components/chat/SelectChatModel';-import { OllamaIcon } from '-/components/dialogs/components/Ollama';import { useChatContext } from '-/hooks/useChatContext';import { Pro } from '-/pro';import { AppDispatch } from '-/reducers/app';@@ -190,7 +190,7 @@ function SettingsAI(props: Props) {const actionButtons = (key) => (<InputAdornmentposition="end"- style={{ flexDirection: 'column', marginTop: -70 }}+ sx={{ flexDirection: 'column', marginTop: '-70px' }}><TsButtonvariant="text"@@ -218,12 +218,12 @@ function SettingsAI(props: Props) {);return (- <div- style={{+ <Box+ sx={{overflowX: 'hidden',overflowY: 'auto',height: '100%',- padding: 10,+ padding: '10px',}}><Accordion defaultExpanded>@@ -232,7 +232,7 @@ function SettingsAI(props: Props) {id="ai-general-header"data-tid="aiGeneralTID">- <Box style={{ display: 'block' }}>+ <Box sx={{ display: 'block' }}><Typography>{t('core:aiSettings')}</Typography><br /><Typography variant="caption">@@ -240,8 +240,8 @@ function SettingsAI(props: Props) {entirely on external software like Ollama. If you don't haveOllama, you can download it for free from<TsButton- style={{- fontSize: 13,+ sx={{+ fontSize: '13px',textTransform: 'unset',fontWeight: 'normal',paddingTop: 0,@@ -270,7 +270,6 @@ function SettingsAI(props: Props) {}}><TsButton- //tooltip={t('core:createNew')}disabled={externalConfig}aria-controls={openedNewAIMenu ? 'split-button-menu' : undefined@@ -280,10 +279,10 @@ function SettingsAI(props: Props) {data-tid="createNewAIButtonTID"onClick={handleToggle}startIcon={<CreateFileIcon />}- style={{ marginBottom: AppConfig.defaultSpaceBetweenButtons }}+ sx={{ marginBottom: AppConfig.defaultSpaceBetweenButtons }}><Box- style={{+ sx={{textOverflow: 'ellipsis',whiteSpace: 'nowrap',overflow: 'hidden',@@ -322,7 +321,7 @@ function SettingsAI(props: Props) {}}><ListItemIcon>- <OllamaIcon height={30} />+ <OllamaIcon /></ListItemIcon><ListItemText primary="Ollama" /></MenuItem>@@ -344,8 +343,10 @@ function SettingsAI(props: Props) {.filter((p) => p.enable).map((provider) => (<MenuItem key={provider.id} value={provider.id}>- <OllamaIcon width={10} style={{ marginRight: 5 }} />- {provider.name}+ <OllamaIcon />+ <Box sx={{ display: 'inline-block', marginLeft: '5px' }}>+ {provider.name}+ </Box></MenuItem>))}</TsSelect>@@ -372,10 +373,8 @@ function SettingsAI(props: Props) {'& .MuiAccordionSummary-content': { alignItems: 'center' },}}>- <Typography>- <OllamaIcon width={15} style={{ marginRight: 5 }} />- {provider.name}- </Typography>+ <OllamaIcon />+ <Typography sx={{ marginLeft: '5px' }}>{provider.name}</Typography><TooltipTStitle={t('core:serviceStatus') +@@ -454,7 +453,7 @@ function SettingsAI(props: Props) {slotProps={{input: {endAdornment: (- <InputAdornment position="end" style={{ height: 32 }}>+ <InputAdornment position="end" sx={{ height: 32 }}><TsIconButtontooltip={t('core:refreshServiceStatus')}onClick={() => {@@ -499,7 +498,7 @@ function SettingsAI(props: Props) {/><FormControlLabellabelPlacement="start"- style={{ justifyContent: 'space-between', marginLeft: 0 }}+ sx={{ justifyContent: 'space-between', marginLeft: 0 }}control={<Switchdata-tid="locationIsDefault"@@ -724,7 +723,7 @@ function SettingsAI(props: Props) {</AccordionDetails></Accordion>)}- </div>+ </Box>);}diff --git a/src/renderer/components/dialogs/components/SettingsAdvanced.tsx b/src/renderer/components/dialogs/components/SettingsAdvanced.tsxindex 364e70203..8baad8ff0 100644--- a/src/renderer/components/dialogs/components/SettingsAdvanced.tsx+++ b/src/renderer/components/dialogs/components/SettingsAdvanced.tsx@@ -17,14 +17,13 @@*/import AppConfig from '-/AppConfig';-import { DeleteIcon, ReloadIcon } from '-/components/CommonIcons';+import { DeleteIcon } from '-/components/CommonIcons';import { ProLabel } from '-/components/HelperComponents';import InfoIcon from '-/components/InfoIcon';import TooltipTS from '-/components/Tooltip';import TsButton from '-/components/TsButton';import TsIconButton from '-/components/TsIconButton';import TsSelect from '-/components/TsSelect';-import TsTextField from '-/components/TsTextField';import MapTileServerDialog from '-/components/dialogs/MapTileServerDialog';import { historyKeys } from '-/hooks/HistoryContextProvider';import { useHistoryContext } from '-/hooks/useHistoryContext';@@ -34,7 +33,6 @@ import { AppDispatch } from '-/reducers/app';import {actions as SettingsActions,getMapTileServers,- getMaxCollectedTag,getSettings,isDevMode,} from '-/reducers/settings';@@ -43,20 +41,13 @@ import { TS } from '-/tagspaces.namespace';import { clearAllURLParams } from '-/utils/dom';import CheckIcon from '@mui/icons-material/Check';import EditIcon from '@mui/icons-material/Edit';-import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord';-import { CircularProgress, InputAdornment, ListItemIcon } from '@mui/material';+import { ListItemIcon } from '@mui/material';import List from '@mui/material/List';import ListItem from '@mui/material/ListItem';import ListItemText from '@mui/material/ListItemText';import MenuItem from '@mui/material/MenuItem';import Switch from '@mui/material/Switch';-import React, {- useContext,- useEffect,- useReducer,- useRef,- useState,-} from 'react';+import { useContext, useEffect, useReducer, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { useDispatch, useSelector } from 'react-redux';@@ -68,7 +59,6 @@ function SettingsAdvanced(props: Props) {const { openConfirmDialog } = useNotificationContext();const dispatch: AppDispatch = useDispatch();const settings = useSelector(getSettings);- const maxCollectedTag = useSelector(getMaxCollectedTag);const tileServers: Array<TS.MapTileServer> = useSelector(getMapTileServers);const devMode = useSelector(isDevMode);const [tileServerDialog, setTileServerDialog] = useState<any>(undefined);@@ -121,38 +111,14 @@ function SettingsAdvanced(props: Props) {const geoTaggingFormatDisabled = AppConfig.geoTaggingFormat !== undefined;- const setDesktopMode = (desktopMode) =>- dispatch(SettingsActions.setDesktopMode(desktopMode));-const setDevMode = (devMode) => dispatch(SettingsActions.setDevMode(devMode));- const setEnableWS = (enableWS) =>- dispatch(SettingsActions.setEnableWS(enableWS));-- const setWarningOpeningFilesExternally = (warningOpeningFilesExternally) =>- dispatch(- SettingsActions.setWarningOpeningFilesExternally(- warningOpeningFilesExternally,- ),- );-- const setSaveTagInLocation = (saveTagInLocation) =>- dispatch(SettingsActions.setSaveTagInLocation(saveTagInLocation));-- const setRevisionsEnabled = (enabled) =>- dispatch(SettingsActions.setRevisionsEnabled(enabled));-const setGeoTaggingFormat = (geoTaggingFormat) =>dispatch(SettingsActions.setGeoTaggingFormat(geoTaggingFormat));const setHistory = (key, value) =>dispatch(SettingsActions.setHistory(key, value));- const setPrefixTagContainer = (prefix) =>- dispatch(SettingsActions.setPrefixTagContainer(prefix));-- const setAuthor = (user: string) => dispatch(SettingsActions.setAuthor(user));-return (<List style={{ overflowX: 'hidden', overflowY: 'auto', height: '100%' }}><ListItem>@@ -199,132 +165,51 @@ function SettingsAdvanced(props: Props) {{t('core:reloadApplication')}</TsButton></ListItem>- <ListItem>- <ListItemText primary={t('enableMobileMode')} />- <Switch- data-tid="settingsSetDesktopMode"- disabled={!(typeof window.ExtDisplayMode === 'undefined')}- onClick={() => setDesktopMode(!settings.desktopMode)}- checked={!settings.desktopMode}- />- </ListItem>- <ListItem>- <ListItemText primary={t('enableWS')} />- {AppConfig.isElectron && (- <TooltipTS- title={- t('core:serviceStatus') +- ': ' +- (wsAlive.current ? t('core:available') : t('core:notAvailable'))- }- >- {wsAlive.current === null ? (- <CircularProgress size={12} />- ) : (- <FiberManualRecordIcon- sx={{- color: wsAlive.current ? 'green' : 'red',- fontSize: 19,- ml: 1,- }}- />- )}- </TooltipTS>- )}- <Switch- data-tid="settingsEnableWS"- disabled={!AppConfig.isElectron}- onClick={() => setEnableWS(!settings.enableWS)}- checked={settings.enableWS}- />- </ListItem>- <ListItem>- <ListItemText primary={t('warningOpeningFilesExternally')} />- <Switch- data-tid="warningOpeningFilesExternally"- onClick={() =>- setWarningOpeningFilesExternally(- !settings.warningOpeningFilesExternally,- )- }- checked={settings.warningOpeningFilesExternally}- />- </ListItem>- {devMode && (- <ListItem>- <ListItemText- primary={- <>- {t('core:tagDelimiter')}- <InfoIcon tooltip={t('core:tagDelimiterInfo')} />- </>- }- />- <TsSelect- data-tid="tagDelimiterTID"- fullWidth={false}- title={t('core:tagDelimiter')}- value={settings.tagDelimiter}- onChange={(event) =>- openConfirmDialog(- t('core:confirm'),- t('core:tagDelimiterChange'),- (result) => {- if (result) {- dispatch(- SettingsActions.setTagDelimiter(event.target.value),- );- }- },- 'cancelTagDelimiterChangeDialog',- 'confirmTagDelimiterChangeDialog',- 'confirmTagDelimiterChangeContent',- )- }- >- <MenuItem value=" ">{t('core:space')}</MenuItem>- <MenuItem value=",">,</MenuItem>- <MenuItem value="_">_</MenuItem>- </TsSelect>- </ListItem>- )}<ListItem><ListItemTextprimary={<>- {t('core:prefixTagContainer')}- <InfoIcon tooltip={t('core:prefixTagContainerInfo')} />+ {t('core:workspaces')}+ <ProLabel /></>}/>- <TsTextField- style={{ maxWidth: '100px' }}- data-tid="prefixTagContainerTID"- value={settings.prefixTagContainer}- onChange={(event) => setPrefixTagContainer(event.target.value)}- />+ <TsButton+ disabled={!Pro}+ onClick={(event) => editWorkSpacesClick(event)}+ >+ {t('createWorkspace')}+ </TsButton></ListItem>- <ListItem>- <ListItemText primary={t('core:maxCollectedTag')} />- <TsTextField- type="number"- slotProps={{- input: { inputMode: 'numeric', min: 0 },+ {workSpaces && workSpaces.length > 0 && (+ <List+ style={{+ padding: 5,+ paddingLeft: 10,+ backgroundColor: '#d3d3d34a',+ borderRadius: AppConfig.defaultCSSRadius,}}- style={{ maxWidth: '92px' }}- data-tid="prefixTagContainerTID"- value={maxCollectedTag}- onChange={(event: React.ChangeEvent<HTMLInputElement>) =>- dispatch(- SettingsActions.setMaxCollectedTag(- event.target.value === ''- ? undefined- : Number(event.target.value),- ),- )- }- />- </ListItem>+ dense+ >+ {workSpaces.map((workSpace, index) => (+ <ListItem key={workSpace.uuid}>+ <ListItemText+ primary={workSpace.fullName + ' - ' + workSpace.shortName}+ />+ <TsIconButton+ aria-label={'Edit workspace'}+ aria-haspopup="true"+ edge="end"+ disabled={!Pro}+ data-tid={'workSpaceEdit_' + workSpace.shortName}+ onClick={(event) => editWorkSpacesClick(event, workSpace)}+ >+ <EditIcon />+ </TsIconButton>+ </ListItem>+ ))}+ </List>+ )}<ListItem><ListItemText primary={t('core:fileOpenHistory')} /><ListItemIcon>@@ -433,53 +318,6 @@ function SettingsAdvanced(props: Props) {<MenuItem value={100}>100</MenuItem></TsSelect></ListItem>- <ListItem>- <ListItemText- primary={- <>- {t('setRevisionsEnabled')}- <InfoIcon tooltip={t('core:setRevisionsEnabledHelp')} />- <ProLabel />- </>- }- />- <Switch- data-tid="setRevisionsEnabledTID"- disabled={!Pro}- onClick={() => setRevisionsEnabled(!settings.isRevisionsEnabled)}- checked={settings.isRevisionsEnabled}- />- </ListItem>- <ListItem- title={- window.ExtUseLocationTags !== undefined- ? t('core:settingExternallyConfigured')- : ''- }- // disabled={!Pro}- >- <ListItemText- primary={- <>- {t('enableTagsFromLocation')}- <InfoIcon tooltip={t('core:enableTagsFromLocationHelp')} />- <ProLabel />- </>- }- />- <Switch- data-tid="saveTagInLocationTID"- disabled={window.ExtUseLocationTags !== undefined}- onClick={() => {- Pro && setSaveTagInLocation(!settings.saveTagInLocation);- }}- checked={- window.ExtUseLocationTags !== undefined- ? window.ExtUseLocationTags- : settings.saveTagInLocation- }- />- </ListItem><ListItem><ListItemText primary={t('core:geoTaggingFormat')} /><TsSelect@@ -567,92 +405,6 @@ function SettingsAdvanced(props: Props) {isDefault={tileServerDialog.isDefault}/>)}- <ListItem>- <ListItemText- primary={- <>- {t('core:workspaces')}- <ProLabel />- </>- }- />- <TsButton- disabled={!Pro}- onClick={(event) => editWorkSpacesClick(event)}- >- {t('createWorkspace')}- </TsButton>- </ListItem>- {workSpaces && workSpaces.length > 0 && (- <List- style={{- padding: 5,- paddingLeft: 10,- backgroundColor: '#d3d3d34a',- borderRadius: AppConfig.defaultCSSRadius,- }}- dense- >- {workSpaces.map((workSpace, index) => (- <ListItem key={workSpace.uuid}>- <ListItemText- primary={workSpace.fullName + ' - ' + workSpace.shortName}- />- <TsIconButton- aria-label={'Edit workspace'}- aria-haspopup="true"- edge="end"- disabled={!Pro}- data-tid={'workSpaceEdit_' + workSpace.shortName}- onClick={(event) => editWorkSpacesClick(event, workSpace)}- >- <EditIcon />- </TsIconButton>- </ListItem>- ))}- </List>- )}-- <ListItem>- <ListItemText- primary={- <>- {t('core:author')}- <InfoIcon- tooltip={- 'The value of this text box can be used for example in the templates as {author} variable. If you do not want this, just leave the text box empty.'- }- />- </>- }- />- <TsTextField- disabled={window.ExtAuthor !== undefined}- title={window.ExtAuthor ? t('core:settingExternallyConfigured') : ''}- data-tid="authorTID"- value={window.ExtAuthor ? window.ExtAuthor : settings.author}- onChange={(event) => setAuthor(event.target.value)}- slotProps={{- input: {- endAdornment: (- <InputAdornment position="end">- <TooltipTS title={t('loadDefaultAuthor')}>- <TsIconButton- data-tid="loadDefaultAuthorTID"- disabled={window.ExtAuthor !== undefined}- onClick={() =>- dispatch(SettingsActions.setAuthor(undefined))- }- >- <ReloadIcon />- </TsIconButton>- </TooltipTS>- </InputAdornment>- ),- },- }}- />- </ListItem><ListItem><ListItemTextprimary={diff --git a/src/renderer/components/dialogs/components/SettingsGeneral.tsx b/src/renderer/components/dialogs/components/SettingsGeneral.tsxindex c15030614..1c76fa4cb 100644--- a/src/renderer/components/dialogs/components/SettingsGeneral.tsx+++ b/src/renderer/components/dialogs/components/SettingsGeneral.tsx@@ -17,36 +17,57 @@*/import AppConfig from '-/AppConfig';-import { BetaLabel } from '-/components/HelperComponents';+import { CloseIcon, ReloadIcon } from '-/components/CommonIcons';+import { BetaLabel, ProLabel } from '-/components/HelperComponents';import InfoIcon from '-/components/InfoIcon';import PerspectiveSelector from '-/components/PerspectiveSelector';import TransparentBackground from '-/components/TransparentBackground';import TsButton from '-/components/TsButton';+import TsIconButton from '-/components/TsIconButton';import TsSelect from '-/components/TsSelect';import TsTextField from '-/components/TsTextField';import TsToggleButton from '-/components/TsToggleButton';import ColorPickerDialog from '-/components/dialogs/ColorPickerDialog';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';+import { useHistoryContext } from '-/hooks/useHistoryContext';+import { useNotificationContext } from '-/hooks/useNotificationContext';import { PerspectiveIDs } from '-/perspectives';+import { Pro } from '-/pro';import { AppDispatch } from '-/reducers/app';import {actions as SettingsActions,getFileNameTagPlace,+ getMapTileServers,+ getMaxCollectedTag,getPersistTagsInSidecarFile,getSettings,+ isDevMode,} from '-/reducers/settings';-import { setLanguage } from '-/services/utils-io';+import { isWorkerAvailable, setLanguage } from '-/services/utils-io';+import { TS } from '-/tagspaces.namespace';import CheckIcon from '@mui/icons-material/Check';+import FiberManualRecordIcon from '@mui/icons-material/FiberManualRecord';+import { Box, IconButton, InputAdornment } from '@mui/material';+import CircularProgress from '@mui/material/CircularProgress';import List from '@mui/material/List';import ListItem from '@mui/material/ListItem';import ListItemText from '@mui/material/ListItemText';import MenuItem from '@mui/material/MenuItem';import Switch from '@mui/material/Switch';import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';+import TooltipTS from '@mui/material/Tooltip';import Typography from '@mui/material/Typography';-import { useState } from 'react';+import {+ useContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+ useState,+} from 'react';import { useTranslation } from 'react-i18next';import { useDispatch, useSelector } from 'react-redux';+import MapTileServerDialog from '../MapTileServerDialog';function SettingsGeneral() {const { i18n, t } = useTranslation();@@ -54,11 +75,55 @@ function SettingsGeneral() {const [displayColorPicker, setDisplayColorPicker] = useState<boolean>(false);const [displayTextColorPicker, setDisplayTextColorPicker] =useState<boolean>(false);+ const [filterText, setFilterText] = useState<string>('');const dispatch: AppDispatch = useDispatch();const settings = useSelector(getSettings);const persistTagsInSidecarFile = useSelector(getPersistTagsInSidecarFile);const filenameTagPlacedAtEnd = useSelector(getFileNameTagPlace);+ // --- Advanced settings imports ---+ const maxCollectedTag = useSelector(getMaxCollectedTag);+ const tileServers: Array<TS.MapTileServer> = useSelector(getMapTileServers);+ const { delAllHistory } = useHistoryContext();+ const { openConfirmDialog } = useNotificationContext();+ const devMode = useSelector(isDevMode);+ const [tileServerDialog, setTileServerDialog] = useState<any>(undefined);+ const wsAlive = useRef<boolean>(null);+ const workSpacesContext = Pro?.contextProviders?.WorkSpacesContext+ ? useContext<TS.WorkSpacesContextData>(+ Pro.contextProviders.WorkSpacesContext,+ )+ : undefined;+ const workSpaces = workSpacesContext?.getWorkSpaces() ?? [];+ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ useEffect(() => {+ if (AppConfig.isElectron) {+ isWorkerAvailable().then((isWsAlive) => {+ wsAlive.current = isWsAlive;+ forceUpdate();+ });+ }+ }, [settings.enableWS]);++ // --- Advanced settings handlers ---+ function setConfirmDialogKey(key: string) {+ if (key) {+ openConfirmDialog(+ t('core:confirm'),+ t('core:confirm' + key + 'Deletion'),+ (result) => {+ if (result) {+ delAllHistory(key);+ }+ },+ 'cancelDelete' + key + 'Dialog',+ 'confirmDelete' + key + 'Dialog',+ 'confirmDelete' + key + 'DialogContent',+ );+ }+ }+const toggleDefaultTagBackgroundColorPicker = () => {setDisplayColorPicker(!displayColorPicker);};@@ -75,389 +140,847 @@ function SettingsGeneral() {const perspective = event.target.value;dispatch(SettingsActions.setDefaultPerspective(perspective));};-let defaultPerspective = PerspectiveIDs.UNSPECIFIED;if (settings.defaultPerspective) {defaultPerspective = settings.defaultPerspective;}- return (- <List style={{ overflowX: 'hidden', overflowY: 'auto', height: '100%' }}>- <ListItem>- <ListItemText primary={t('core:interfaceLanguage')} />- <TsSelect- data-tid="settingsSetLanguage"- fullWidth={false}- value={settings.interfaceLanguage}- onChange={(event: any) => {- return i18n.changeLanguage(event.target.value).then(() => {- dispatch(SettingsActions.setLanguage(event.target.value));- setLanguage(event.target.value);- return true;- });- }}- >- {settings.supportedLanguages.map((language) => (- <MenuItem key={language.iso} value={language.iso}>- {language.title}- </MenuItem>- ))}- </TsSelect>- </ListItem>- <ListItem>- <ListItemText primary={t('core:themeSelector')} />- <TsSelect- data-tid="settingsSetCurrentTheme"- fullWidth={false}- value={settings.currentTheme}- onChange={(event: any) =>- dispatch(SettingsActions.setCurrentTheme(event.target.value))- }- >- {settings.supportedThemes.map((theme) => (- <MenuItem key={theme} value={theme}>- {theme === 'light' && t('core:regularScheme')}- {theme === 'dark' && t('core:darkScheme')}- {theme === 'system' && t('core:systemScheme')}- </MenuItem>- ))}- </TsSelect>- </ListItem>- <ListItem>- <ListItemText primary={t('core:themeRegularSelector')} />- <TsSelect- data-tid="settingsCurrentRegularThemeTID"- fullWidth={false}- value={settings.currentRegularTheme}- onChange={(event: any) =>- dispatch(SettingsActions.setCurrentRegularTheme(event.target.value))- }- >- {settings.supportedRegularThemes.map((theme) => (- <MenuItem key={theme} value={theme}>- {theme.charAt(0).toUpperCase() + theme.slice(1)}- </MenuItem>- ))}- </TsSelect>- </ListItem>- <ListItem>- <ListItemText primary={t('core:themeDarkSelector')} />- <TsSelect- data-tid="settingsCurrentDarkThemeTID"- fullWidth={false}- value={settings.currentDarkTheme}- onChange={(event: any) =>- dispatch(SettingsActions.setCurrentDarkTheme(event.target.value))- }- >- {settings.supportedDarkThemes.map((theme) => (- <MenuItem key={theme} value={theme}>- {theme.charAt(0).toUpperCase() + theme.slice(1)}- </MenuItem>- ))}- </TsSelect>- </ListItem>- <ListItem>- <ListItemText primary={t('createLocationDefaultPerspective')} />- <PerspectiveSelector- fullWidth={false}- onChange={changePerspective}- defaultValue={defaultPerspective}- testId="changePerspectiveInSettingsTID"- />- </ListItem>- <ListItem- title={- AppConfig.useSidecarsForFileTaggingDisableSetting- ? t('core:settingExternallyConfigured')- : ''- }- >- <ListItemText primary={t('core:fileTaggingSetting')} />- {AppConfig.useSidecarsForFileTaggingDisableSetting ? (- <TsButton disabled>- {persistTagsInSidecarFile- ? t('core:useSidecarFile')- : t('core:renameFile')}- </TsButton>- ) : (- <ToggleButtonGroup- value={persistTagsInSidecarFile}- size="small"- exclusive- >- <TsToggleButton- value={false}- data-tid="settingsSetPersistTagsInFileName"- style={{- borderTopRightRadius: 0,- borderBottomRightRadius: 0,- }}- onClick={() =>- dispatch(SettingsActions.setPersistTagsInSidecarFile(false))+ const geoTaggingFormatDisabled = AppConfig.geoTaggingFormat !== undefined;++ const setDesktopMode = (desktopMode) =>+ dispatch(SettingsActions.setDesktopMode(desktopMode));++ const setDevMode = (devMode) => dispatch(SettingsActions.setDevMode(devMode));++ const setEnableWS = (enableWS) =>+ dispatch(SettingsActions.setEnableWS(enableWS));++ const setWarningOpeningFilesExternally = (warningOpeningFilesExternally) =>+ dispatch(+ SettingsActions.setWarningOpeningFilesExternally(+ warningOpeningFilesExternally,+ ),+ );++ const setSaveTagInLocation = (saveTagInLocation) =>+ dispatch(SettingsActions.setSaveTagInLocation(saveTagInLocation));++ const setRevisionsEnabled = (enabled) =>+ dispatch(SettingsActions.setRevisionsEnabled(enabled));++ const setGeoTaggingFormat = (geoTaggingFormat) =>+ dispatch(SettingsActions.setGeoTaggingFormat(geoTaggingFormat));++ const setHistory = (key, value) =>+ dispatch(SettingsActions.setHistory(key, value));++ const setPrefixTagContainer = (prefix) =>+ dispatch(SettingsActions.setPrefixTagContainer(prefix));++ const setAuthor = (user: string) => dispatch(SettingsActions.setAuthor(user));++ // --- Settings items ---+ const settingsItems = useMemo(+ () =>+ [+ {+ label: t('core:interfaceLanguage'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('core:interfaceLanguage')} />+ <TsSelect+ data-tid="settingsSetLanguage"+ fullWidth={false}+ value={settings.interfaceLanguage}+ onChange={(event: any) => {+ return i18n.changeLanguage(event.target.value).then(() => {+ dispatch(SettingsActions.setLanguage(event.target.value));+ setLanguage(event.target.value);+ return true;+ });+ }}+ >+ {settings.supportedLanguages.map((language) => (+ <MenuItem key={language.iso} value={language.iso}>+ {language.title}+ </MenuItem>+ ))}+ </TsSelect>+ </ListItem>+ ),+ },+ {+ label: t('core:themeSelector'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('core:themeSelector')} />+ <TsSelect+ data-tid="settingsSetCurrentTheme"+ fullWidth={false}+ value={settings.currentTheme}+ onChange={(event: any) =>+ dispatch(SettingsActions.setCurrentTheme(event.target.value))+ }+ >+ {settings.supportedThemes.map((theme) => (+ <MenuItem key={theme} value={theme}>+ {theme === 'light' && t('core:regularScheme')}+ {theme === 'dark' && t('core:darkScheme')}+ {theme === 'system' && t('core:systemScheme')}+ </MenuItem>+ ))}+ </TsSelect>+ </ListItem>+ ),+ },+ {+ label: t('core:themeRegularSelector'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('core:themeRegularSelector')} />+ <TsSelect+ data-tid="settingsCurrentRegularThemeTID"+ fullWidth={false}+ value={settings.currentRegularTheme}+ onChange={(event: any) =>+ dispatch(+ SettingsActions.setCurrentRegularTheme(event.target.value),+ )+ }+ >+ {settings.supportedRegularThemes.map((theme) => (+ <MenuItem key={theme} value={theme}>+ {theme.charAt(0).toUpperCase() + theme.slice(1)}+ </MenuItem>+ ))}+ </TsSelect>+ </ListItem>+ ),+ },+ {+ label: t('core:themeDarkSelector'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('core:themeDarkSelector')} />+ <TsSelect+ data-tid="settingsCurrentDarkThemeTID"+ fullWidth={false}+ value={settings.currentDarkTheme}+ onChange={(event: any) =>+ dispatch(+ SettingsActions.setCurrentDarkTheme(event.target.value),+ )+ }+ >+ {settings.supportedDarkThemes.map((theme) => (+ <MenuItem key={theme} value={theme}>+ {theme.charAt(0).toUpperCase() + theme.slice(1)}+ </MenuItem>+ ))}+ </TsSelect>+ </ListItem>+ ),+ },+ {+ label: t('createLocationDefaultPerspective'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('createLocationDefaultPerspective')} />+ <PerspectiveSelector+ fullWidth={false}+ onChange={changePerspective}+ defaultValue={defaultPerspective}+ testId="changePerspectiveInSettingsTID"+ />+ </ListItem>+ ),+ },+ {+ label: t('core:fileTaggingSetting'),+ jsx: (+ <ListItem+ title={+ AppConfig.useSidecarsForFileTaggingDisableSetting+ ? t('core:settingExternallyConfigured')+ : ''}>- <div style={{ display: 'flex', textTransform: 'unset' }}>- {!persistTagsInSidecarFile && <CheckIcon />}- {t('core:renameFile')} - <InfoIcon tooltip={t('core:tagsInFilenameExplanation')} />- </div>- </TsToggleButton>- <TsToggleButton- value={true}- data-tid="settingsSetPersistTagsInSidecarFile"- style={{- borderTopLeftRadius: 0,- borderBottomLeftRadius: 0,- }}- onClick={() =>- dispatch(SettingsActions.setPersistTagsInSidecarFile(true))+ <ListItemText primary={t('core:fileTaggingSetting')} />+ {AppConfig.useSidecarsForFileTaggingDisableSetting ? (+ <TsButton disabled>+ {persistTagsInSidecarFile+ ? t('core:useSidecarFile')+ : t('core:renameFile')}+ </TsButton>+ ) : (+ <ToggleButtonGroup+ value={persistTagsInSidecarFile}+ size="small"+ exclusive+ >+ <TsToggleButton+ value={false}+ data-tid="settingsSetPersistTagsInFileName"+ style={{+ borderTopRightRadius: 0,+ borderBottomRightRadius: 0,+ }}+ onClick={() =>+ dispatch(+ SettingsActions.setPersistTagsInSidecarFile(false),+ )+ }+ >+ <div style={{ display: 'flex', textTransform: 'unset' }}>+ {!persistTagsInSidecarFile && <CheckIcon />}+ {t('core:renameFile')} + <InfoIcon tooltip={t('core:tagsInFilenameExplanation')} />+ </div>+ </TsToggleButton>+ <TsToggleButton+ value={true}+ data-tid="settingsSetPersistTagsInSidecarFile"+ style={{+ borderTopLeftRadius: 0,+ borderBottomLeftRadius: 0,+ }}+ onClick={() =>+ dispatch(+ SettingsActions.setPersistTagsInSidecarFile(true),+ )+ }+ >+ <div style={{ display: 'flex' }}>+ {persistTagsInSidecarFile && <CheckIcon />}+ {t('core:useSidecarFile')} + <InfoIcon+ tooltip={t('core:tagsInSidecarFileExplanation')}+ />+ </div>+ </TsToggleButton>+ </ToggleButtonGroup>+ )}+ </ListItem>+ ),+ },+ !persistTagsInSidecarFile && {+ label: t('core:fileNameTagSetting'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('core:fileNameTagSetting')} />+ <ToggleButtonGroup+ value={filenameTagPlacedAtEnd}+ size="small"+ exclusive+ >+ <TsToggleButton+ value={false}+ data-tid="fileNameBeginningTagTID"+ style={{+ borderTopRightRadius: 0,+ borderBottomRightRadius: 0,+ }}+ onClick={() =>+ dispatch(SettingsActions.setFileNameTagPlace(false))+ }+ >+ <Box sx={{ display: 'flex' }}>+ {!filenameTagPlacedAtEnd && <CheckIcon />}+ {t('core:atTheBeginningOfFileName')} + <InfoIcon+ tooltip={t('core:fileNameBeginTagPlaceExplanation')}+ />+ </Box>+ </TsToggleButton>+ <TsToggleButton+ value={true}+ data-tid="fileNameEndTagTID"+ style={{+ borderTopLeftRadius: 0,+ borderBottomLeftRadius: 0,+ }}+ onClick={() =>+ dispatch(SettingsActions.setFileNameTagPlace(true))+ }+ >+ <Box sx={{ display: 'flex' }}>+ {filenameTagPlacedAtEnd && <CheckIcon />}+ {t('core:filenameTagPlacedAtEnd')} + <InfoIcon+ tooltip={t('core:fileNameEndTagPlaceExplanation')}+ />+ </Box>+ </TsToggleButton>+ </ToggleButtonGroup>+ </ListItem>+ ),+ },+ {+ label: t('core:checkForNewVersionOnStartup'),+ jsx: (+ <ListItem+ title={+ window.ExtCheckForUpdatesOnStartup !== undefined+ ? t('core:settingExternallyConfigured')+ : ''}>- <div style={{ display: 'flex' }}>- {persistTagsInSidecarFile && <CheckIcon />}- {t('core:useSidecarFile')} - <InfoIcon tooltip={t('core:tagsInSidecarFileExplanation')} />- </div>- </TsToggleButton>- </ToggleButtonGroup>- )}- </ListItem>- {!persistTagsInSidecarFile && (- <ListItem>- <ListItemText primary={t('core:fileNameTagSetting')} />- <ToggleButtonGroup- value={filenameTagPlacedAtEnd}- size="small"- exclusive- >- <TsToggleButton- value={false}- data-tid="fileNameBeginningTagTID"- style={{- borderTopRightRadius: 0,- borderBottomRightRadius: 0,- }}- onClick={() =>- dispatch(SettingsActions.setFileNameTagPlace(false))+ <ListItemText primary={t('core:checkForNewVersionOnStartup')} />+ <Switch+ disabled={window.ExtCheckForUpdatesOnStartup !== undefined}+ data-tid="settingsSetCheckForUpdates"+ onClick={() =>+ dispatch(+ SettingsActions.setCheckForUpdates(+ !settings.checkForUpdates,+ ),+ )+ }+ checked={+ window.ExtCheckForUpdatesOnStartup !== undefined+ ? window.ExtCheckForUpdatesOnStartup+ : settings.checkForUpdates+ }+ />+ </ListItem>+ ),+ },+ {+ label: t('core:reorderTags'),+ jsx: (+ <ListItem>+ <ListItemText+ primary={+ <>+ {t('core:reorderTags')}+ <BetaLabel />+ </>+ }+ />+ <Switch+ data-tid="reorderTagsTID"+ onClick={() =>+ dispatch(SettingsActions.reorderTags(!settings.reorderTags))+ }+ checked={settings.reorderTags}+ />+ </ListItem>+ ),+ },+ {+ label: t('core:addTagsToLibrary'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('core:addTagsToLibrary')} />+ <Switch+ data-tid="settingsSetAddTagsToLibrary"+ onClick={() =>+ dispatch(+ SettingsActions.setAddTagsToLibrary(+ !settings.addTagsToLibrary,+ ),+ )+ }+ checked={settings.addTagsToLibrary}+ />+ </ListItem>+ ),+ },+ {+ label: t('core:useOnlyTagsFromTagLibrary'),+ jsx: (+ <ListItem+ title={+ window.ExtUseOnlyTagsFromTagLibrary !== undefined+ ? t('core:settingExternallyConfigured')+ : ''}>- <div style={{ display: 'flex' }}>- {!filenameTagPlacedAtEnd && <CheckIcon />}- {t('core:atTheBeginningOfFileName')} - <InfoIcon- tooltip={t('core:fileNameBeginTagPlaceExplanation')}- />- </div>- </TsToggleButton>- <TsToggleButton- value={true}- data-tid="fileNameEndTagTID"- style={{- borderTopLeftRadius: 0,- borderBottomLeftRadius: 0,- }}- onClick={() =>- dispatch(SettingsActions.setFileNameTagPlace(true))+ <ListItemText primary={t('core:useOnlyTagsFromTagLibrary')} />+ <Switch+ disabled={window.ExtUseOnlyTagsFromTagLibrary !== undefined}+ data-tid="useOnlyTagsFromTagLibraryTID"+ onClick={() =>+ dispatch(+ SettingsActions.setUseOnlyTagsFromTagLibrary(+ !settings.useOnlyTagsFromTagLibrary,+ ),+ )+ }+ checked={+ window.ExtUseOnlyTagsFromTagLibrary !== undefined+ ? window.ExtUseOnlyTagsFromTagLibrary+ : settings.useOnlyTagsFromTagLibrary+ }+ />+ </ListItem>+ ),+ },+ {+ label: t('core:useGenerateThumbnails'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('core:useGenerateThumbnails')} />+ <Switch+ disabled={AppConfig.useGenerateThumbnails !== undefined}+ data-tid="settingsUseGenerateThumbnails"+ onClick={() =>+ dispatch(+ SettingsActions.setUseGenerateThumbnails(+ !settings.useGenerateThumbnails,+ ),+ )+ }+ checked={+ AppConfig.useGenerateThumbnails !== undefined+ ? AppConfig.useGenerateThumbnails+ : settings.useGenerateThumbnails+ }+ />+ </ListItem>+ ),+ },+ {+ label: t('core:tagBackgroundColor'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('core:tagBackgroundColor')} />+ <TransparentBackground>+ <TsButton+ data-tid="settingsToggleDefaultTagBackgroundColor"+ style={{+ backgroundColor: settings.tagBackgroundColor,+ border: '1px solid lightgray',+ }}+ onClick={toggleDefaultTagBackgroundColorPicker}+ >+ + </TsButton>+ </TransparentBackground>+ </ListItem>+ ),+ },+ {+ label: t('core:tagForegroundColor'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('core:tagForegroundColor')} />+ <TransparentBackground>+ <TsButton+ data-tid="settingsToggleDefaultTagForegroundColor"+ style={{+ border: '1px solid lightgray',+ backgroundColor: settings.tagTextColor,+ }}+ onClick={toggleDefaultTagTextColorPicker}+ >+ + </TsButton>+ </TransparentBackground>+ </ListItem>+ ),+ },+ AppConfig.isElectron && {+ label: t('core:useTrashCan'),+ jsx: (+ <ListItem>+ <ListItemText+ primary={+ <Typography>+ {t('core:useTrashCan')}+ <InfoIcon tooltip={t('core:useTrashCanInfo')} />+ </Typography>+ }+ />+ <Switch+ data-tid="settingsSetUseTrashCan"+ onClick={() =>+ dispatch(+ SettingsActions.setUseTrashCan(!settings.useTrashCan),+ )+ }+ checked={settings.useTrashCan}+ />+ </ListItem>+ ),+ },+ {+ label: t('core:showUnixHiddenFiles'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('core:showUnixHiddenFiles')} />+ <Switch+ data-tid="settingsSetShowUnixHiddenEntries"+ onClick={() => {+ dispatch(SettingsActions.toggleShowUnixHiddenEntries());+ openCurrentDirectory(!settings.showUnixHiddenEntries);+ }}+ checked={settings.showUnixHiddenEntries}+ />+ </ListItem>+ ),+ },+ {+ label: t('core:maxSearchResultChoose'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('core:maxSearchResultChoose')} />+ <TsTextField+ style={{ maxWidth: '100px' }}+ type="number"+ data-tid="settingsMaxSearchResult"+ value={settings.maxSearchResult}+ onChange={handleMaxSearchResult}+ />+ </ListItem>+ ),+ },+ {+ label: t('enableMobileMode'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('enableMobileMode')} />+ <Switch+ data-tid="settingsSetDesktopMode"+ disabled={!(typeof window.ExtDisplayMode === 'undefined')}+ onClick={() => setDesktopMode(!settings.desktopMode)}+ checked={!settings.desktopMode}+ />+ </ListItem>+ ),+ },+ {+ label: t('enableWS'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('enableWS')} />+ {AppConfig.isElectron && (+ <TooltipTS+ title={+ t('core:serviceStatus') ++ ': ' ++ (wsAlive.current+ ? t('core:available')+ : t('core:notAvailable'))+ }+ >+ {wsAlive.current === null ? (+ <CircularProgress size={12} />+ ) : (+ <FiberManualRecordIcon+ sx={{+ color: wsAlive.current ? 'green' : 'red',+ fontSize: 19,+ ml: 1,+ }}+ />+ )}+ </TooltipTS>+ )}+ <Switch+ data-tid="settingsEnableWS"+ disabled={!AppConfig.isElectron}+ onClick={() => setEnableWS(!settings.enableWS)}+ checked={settings.enableWS}+ />+ </ListItem>+ ),+ },+ {+ label: t('warningOpeningFilesExternally'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('warningOpeningFilesExternally')} />+ <Switch+ data-tid="warningOpeningFilesExternally"+ onClick={() =>+ setWarningOpeningFilesExternally(+ !settings.warningOpeningFilesExternally,+ )+ }+ checked={settings.warningOpeningFilesExternally}+ />+ </ListItem>+ ),+ },+ devMode && {+ label: t('core:tagDelimiter'),+ jsx: (+ <ListItem>+ <ListItemText+ primary={+ <>+ {t('core:tagDelimiter')}+ <InfoIcon tooltip={t('core:tagDelimiterInfo')} />+ </>+ }+ />+ <TsSelect+ data-tid="tagDelimiterTID"+ fullWidth={false}+ title={t('core:tagDelimiter')}+ value={settings.tagDelimiter}+ onChange={(event) =>+ openConfirmDialog(+ t('core:confirm'),+ t('core:tagDelimiterChange'),+ (result) => {+ if (result) {+ dispatch(+ SettingsActions.setTagDelimiter(event.target.value),+ );+ }+ },+ 'cancelTagDelimiterChangeDialog',+ 'confirmTagDelimiterChangeDialog',+ 'confirmTagDelimiterChangeContent',+ )+ }+ >+ <MenuItem value=" ">{t('core:space')}</MenuItem>+ <MenuItem value=",">,</MenuItem>+ <MenuItem value="_">_</MenuItem>+ </TsSelect>+ </ListItem>+ ),+ },+ {+ label: t('core:prefixTagContainer'),+ jsx: (+ <ListItem>+ <ListItemText+ primary={+ <>+ {t('core:prefixTagContainer')}+ <InfoIcon tooltip={t('core:prefixTagContainerInfo')} />+ </>+ }+ />+ <TsTextField+ style={{ maxWidth: '100px' }}+ data-tid="prefixTagContainerTID"+ value={settings.prefixTagContainer}+ onChange={(event) => setPrefixTagContainer(event.target.value)}+ />+ </ListItem>+ ),+ },+ {+ label: t('core:maxCollectedTag'),+ jsx: (+ <ListItem>+ <ListItemText primary={t('core:maxCollectedTag')} />+ <TsTextField+ type="number"+ slotProps={{+ input: { inputMode: 'numeric', min: 0 },+ }}+ style={{ maxWidth: '92px' }}+ data-tid="prefixTagContainerTID"+ value={maxCollectedTag}+ onChange={(event: React.ChangeEvent<HTMLInputElement>) =>+ dispatch(+ SettingsActions.setMaxCollectedTag(+ event.target.value === ''+ ? undefined+ : Number(event.target.value),+ ),+ )+ }+ />+ </ListItem>+ ),+ },+ {+ label: t('core:author'),+ jsx: (+ <ListItem>+ <ListItemText+ primary={+ <>+ {t('core:author')}+ <InfoIcon+ tooltip={+ 'The value of this text box can be used for example in the templates as {author} variable. If you do not want this, just leave the text box empty.'+ }+ />+ </>+ }+ />+ <TsTextField+ disabled={window.ExtAuthor !== undefined}+ title={+ window.ExtAuthor ? t('core:settingExternallyConfigured') : ''+ }+ data-tid="authorTID"+ value={window.ExtAuthor ? window.ExtAuthor : settings.author}+ onChange={(event) => setAuthor(event.target.value)}+ slotProps={{+ input: {+ endAdornment: (+ <InputAdornment position="end">+ <TooltipTS title={t('loadDefaultAuthor')}>+ <TsIconButton+ data-tid="loadDefaultAuthorTID"+ disabled={window.ExtAuthor !== undefined}+ onClick={() =>+ dispatch(SettingsActions.setAuthor(undefined))+ }+ >+ <ReloadIcon />+ </TsIconButton>+ </TooltipTS>+ </InputAdornment>+ ),+ },+ }}+ />+ </ListItem>+ ),+ },+ {+ label: t('core:setRevisionsEnabled'),+ jsx: (+ <ListItem>+ <ListItemText+ primary={+ <>+ {t('setRevisionsEnabled')}+ <InfoIcon tooltip={t('core:setRevisionsEnabledHelp')} />+ <ProLabel />+ </>+ }+ />+ <Switch+ data-tid="setRevisionsEnabledTID"+ disabled={!Pro}+ onClick={() =>+ setRevisionsEnabled(!settings.isRevisionsEnabled)+ }+ checked={settings.isRevisionsEnabled}+ />+ </ListItem>+ ),+ },+ {+ label: t('core:settingExternallyConfigured'),+ jsx: (+ <ListItem+ title={+ window.ExtUseLocationTags !== undefined+ ? t('core:settingExternallyConfigured')+ : ''}>- <div style={{ display: 'flex' }}>- {filenameTagPlacedAtEnd && <CheckIcon />}- {t('core:filenameTagPlacedAtEnd')} - <InfoIcon tooltip={t('core:fileNameEndTagPlaceExplanation')} />- </div>- </TsToggleButton>- </ToggleButtonGroup>- </ListItem>- )}+ <ListItemText+ primary={+ <>+ {t('enableTagsFromLocation')}+ <InfoIcon tooltip={t('core:enableTagsFromLocationHelp')} />+ <ProLabel />+ </>+ }+ />+ <Switch+ data-tid="saveTagInLocationTID"+ disabled={window.ExtUseLocationTags !== undefined}+ onClick={() => {+ Pro && setSaveTagInLocation(!settings.saveTagInLocation);+ }}+ checked={+ window.ExtUseLocationTags !== undefined+ ? window.ExtUseLocationTags+ : settings.saveTagInLocation+ }+ />+ </ListItem>+ ),+ },+ ].filter(Boolean),+ [+ t,+ settings,+ devMode,+ wsAlive.current,+ maxCollectedTag,+ dispatch,+ openConfirmDialog,+ ],+ );- <ListItem- title={- window.ExtCheckForUpdatesOnStartup !== undefined- ? t('core:settingExternallyConfigured')- : ''- }- >- <ListItemText primary={t('core:checkForNewVersionOnStartup')} />- <Switch- disabled={window.ExtCheckForUpdatesOnStartup !== undefined}- data-tid="settingsSetCheckForUpdates"- onClick={() =>- dispatch(- SettingsActions.setCheckForUpdates(!settings.checkForUpdates),- )- }- checked={- window.ExtCheckForUpdatesOnStartup !== undefined- ? window.ExtCheckForUpdatesOnStartup- : settings.checkForUpdates- }- />- </ListItem>- <ListItem>- <ListItemText- primary={- <>- {t('core:reorderTags')}- <BetaLabel />- </>- }- />- <Switch- data-tid="reorderTagsTID"- onClick={() =>- dispatch(SettingsActions.reorderTags(!settings.reorderTags))- }- checked={settings.reorderTags}- />- </ListItem>- <ListItem>- <ListItemText primary={t('core:addTagsToLibrary')} />- <Switch- data-tid="settingsSetAddTagsToLibrary"- onClick={() =>- dispatch(- SettingsActions.setAddTagsToLibrary(!settings.addTagsToLibrary),- )- }- checked={settings.addTagsToLibrary}- />- </ListItem>- <ListItem- title={- window.ExtUseOnlyTagsFromTagLibrary !== undefined- ? t('core:settingExternallyConfigured')- : ''- }- >- <ListItemText primary={t('core:useOnlyTagsFromTagLibrary')} />- <Switch- disabled={window.ExtUseOnlyTagsFromTagLibrary !== undefined}- data-tid="useOnlyTagsFromTagLibraryTID"- onClick={() =>- dispatch(- SettingsActions.setUseOnlyTagsFromTagLibrary(- !settings.useOnlyTagsFromTagLibrary,- ),- )- }- checked={- window.ExtUseOnlyTagsFromTagLibrary !== undefined- ? window.ExtUseOnlyTagsFromTagLibrary- : settings.useOnlyTagsFromTagLibrary- }- />- </ListItem>- <ListItem>- <ListItemText primary={t('core:useGenerateThumbnails')} />- <Switch- disabled={AppConfig.useGenerateThumbnails !== undefined}- data-tid="settingsUseGenerateThumbnails"- onClick={() =>- dispatch(- SettingsActions.setUseGenerateThumbnails(- !settings.useGenerateThumbnails,+ // Filter settings by label and description+ const filteredSettings = useMemo(() => {+ if (!filterText.trim()) return settingsItems;+ const lowerFilter = filterText.toLowerCase();+ return settingsItems.filter((item) =>+ item.label.toLowerCase().includes(lowerFilter),+ );+ }, [filterText, settingsItems]);++ return (+ <>+ <Box sx={{ padding: '8px 16px 0 16px' }}>+ <TsTextField+ data-tid="settingsFilterText"+ fullWidth+ placeholder={t('core:searchSettings')}+ value={filterText}+ onChange={(e) => setFilterText(e.target.value)}+ sx={{ marginBottom: 2 }}+ slotProps={{+ input: {+ endAdornment: filterText && (+ <InputAdornment position="end">+ <IconButton+ aria-label={t('core:clear')}+ size="small"+ onClick={() => setFilterText('')}+ edge="end"+ >+ <CloseIcon />+ </IconButton>+ </InputAdornment>),- )- }- checked={- AppConfig.useGenerateThumbnails !== undefined- ? AppConfig.useGenerateThumbnails- : settings.useGenerateThumbnails- }+ },+ }}/>- </ListItem>- <ListItem>- <ListItemText primary={t('core:tagBackgroundColor')} />- <TransparentBackground>- <TsButton- data-tid="settingsToggleDefaultTagBackgroundColor"- style={{- backgroundColor: settings.tagBackgroundColor,- border: '1px solid lightgray',- }}- onClick={toggleDefaultTagBackgroundColorPicker}- >- - </TsButton>- </TransparentBackground>+ </Box>+ <List+ style={{+ overflowX: 'hidden',+ overflowY: 'auto',+ height: 'calc( 100% - 80px )',+ }}+ >+ {filteredSettings.map((item) => item.jsx)}{displayColorPicker && (<ColorPickerDialogopen={displayColorPicker}- setColor={(color) => {- dispatch(SettingsActions.setTagColor(color));- }}- onClose={toggleDefaultTagBackgroundColorPicker}+ setColor={(color) => dispatch(SettingsActions.setTagColor(color))}+ onClose={() => setDisplayColorPicker(false)}color={settings.tagBackgroundColor}/>)}- </ListItem>- <ListItem>- <ListItemText primary={t('core:tagForegroundColor')} />- <TransparentBackground>- <TsButton- data-tid="settingsToggleDefaultTagForegroundColor"- style={{- border: '1px solid lightgray',- backgroundColor: settings.tagTextColor,- }}- onClick={toggleDefaultTagTextColorPicker}- >- - </TsButton>- </TransparentBackground>{displayTextColorPicker && (<ColorPickerDialogopen={displayTextColorPicker}- setColor={(color) => {- dispatch(SettingsActions.setTagTextColor(color));- }}- onClose={toggleDefaultTagTextColorPicker}+ setColor={(color) =>+ dispatch(SettingsActions.setTagTextColor(color))+ }+ onClose={() => setDisplayTextColorPicker(false)}color={settings.tagTextColor}/>)}- </ListItem>- {AppConfig.isElectron && (- <ListItem>- <ListItemText- primary={- <Typography>- {t('core:useTrashCan')}- <InfoIcon tooltip={t('core:useTrashCanInfo')} />- </Typography>- }+ {tileServerDialog && (+ <MapTileServerDialog+ open={tileServerDialog !== undefined}+ onClose={() => setTileServerDialog(undefined)}+ tileServer={tileServerDialog}+ isDefault={tileServerDialog.isDefault}/>- <Switch- data-tid="settingsSetUseTrashCan"- onClick={() =>- dispatch(SettingsActions.setUseTrashCan(!settings.useTrashCan))- }- checked={settings.useTrashCan}- />- </ListItem>- )}- <ListItem>- <ListItemText primary={t('core:showUnixHiddenFiles')} />- <Switch- data-tid="settingsSetShowUnixHiddenEntries"- onClick={() => {- dispatch(SettingsActions.toggleShowUnixHiddenEntries());- openCurrentDirectory(!settings.showUnixHiddenEntries);- }}- checked={settings.showUnixHiddenEntries}- />- </ListItem>- <ListItem>- <ListItemText primary={t('core:maxSearchResultChoose')} />- <TsTextField- style={{ maxWidth: '100px' }}- type="number"- data-tid="settingsMaxSearchResult"- value={settings.maxSearchResult}- onChange={handleMaxSearchResult}- />- </ListItem>- </List>+ )}+ </List>+ </>);}diff --git a/src/renderer/containers/App.tsx b/src/renderer/containers/App.tsxindex bffd9f2a2..872df6459 100644--- a/src/renderer/containers/App.tsx+++ b/src/renderer/containers/App.tsx@@ -28,27 +28,24 @@ import {createTheme,} from '@mui/material/styles';import useMediaQuery from '@mui/material/useMediaQuery';-import { useEffect } from 'react';-import { I18nextProvider, useTranslation } from 'react-i18next'; // as we build ourself via webpack+import { useEffect, useMemo } from 'react';+import { I18nextProvider, useTranslation } from 'react-i18next';import { useSelector } from 'react-redux';declare module '@mui/material/styles' {- interface Theme extends Record<string, any> {- // Any additional properties or overrides- }+ interface Theme extends Record<string, any> {}}+// Theme definitionsconst legacyTheme = createTheme({palette: {- mode: 'light', // Switching the dark mode on is a single property value change.+ mode: 'light',primary: {light: AppConfig.lightThemeLightColor,main: AppConfig.lightThemeMainColor,dark: AppConfig.lightThemeMainColor,},- secondary: {- main: '#777',- },+ secondary: { main: '#777' },divider: '#ddd',},});@@ -61,15 +58,11 @@ const newlightTheme = createTheme({main: '#3bc8ff',dark: '#3bc8ff',},- secondary: {- main: '#777',- },+ secondary: { main: '#777' },divider: '#ddd',},- // shape: { borderRadius: 10 },});-// https://mui.com/material-ui/customization/dark-mode/const darklegacyTheme = createTheme({palette: {mode: 'dark',@@ -78,9 +71,7 @@ const darklegacyTheme = createTheme({main: AppConfig.darkThemeMainColor,dark: AppConfig.darkThemeMainColor,},- secondary: {- main: '#bbb',- },+ secondary: { main: '#bbb' },divider: '#555',},});@@ -93,12 +84,8 @@ const darkblueTheme = createTheme({main: '#3bc8ff',dark: '#3bc8ff',},- secondary: {- main: '#bbb',- },- background: {- default: '#001E3C',- },+ secondary: { main: '#bbb' },+ background: { default: '#001E3C' },divider: '#555',},});@@ -111,87 +98,74 @@ const draculaTheme = createTheme({main: '#BD93F9',dark: '#BD93F9',},- secondary: {- main: '#bbb',- },+ secondary: { main: '#bbb' },divider: '#555',- background: {- default: '#282A36',- },- text: {- primary: '#f8f8f2',- },+ background: { default: '#282A36' },+ text: { primary: '#f8f8f2' },},});interface Props {- children: any;+ children: React.ReactNode;}-function App(props: Props) {- const { i18n } = useTranslation();- let theme = legacyTheme;- let regularTheme = legacyTheme;- let darkTheme = darklegacyTheme;+function App({ children }: Props) {+ const { i18n } = useTranslation();const currentTheme = useSelector(getCurrentTheme);const defaultDarkTheme = useSelector(getDefaultDarkTheme);const defaultRegularTheme = useSelector(getDefaultRegularTheme);+ const systemDarkMode = useMediaQuery('(prefers-color-scheme: dark)');- const systemDarkMode = useMediaQuery('(prefers-color-scheme: dark)'); // window.matchMedia().matches;- switch (defaultRegularTheme) {- case 'legacy': {- regularTheme = legacyTheme;- break;- }- case 'newlight': {- regularTheme = newlightTheme;- break;- }- }- switch (defaultDarkTheme) {- case 'darklegacy': {- darkTheme = darklegacyTheme;- break;- }- case 'darkblue': {- darkTheme = darkblueTheme;- break;- }- case 'dracula': {- darkTheme = draculaTheme;- break;- }- }- switch (currentTheme) {- case 'light': {- theme = regularTheme;- break;+ // Memoize theme selection for performance and clarity+ const theme = useMemo(() => {+ let regularTheme = legacyTheme;+ let darkTheme = darklegacyTheme;++ switch (defaultRegularTheme) {+ case 'newlight':+ regularTheme = newlightTheme;+ break;+ case 'legacy':+ default:+ regularTheme = legacyTheme;}- case 'dark': {- theme = darkTheme;- break;+ switch (defaultDarkTheme) {+ case 'darkblue':+ darkTheme = darkblueTheme;+ break;+ case 'dracula':+ darkTheme = draculaTheme;+ break;+ case 'darklegacy':+ default:+ darkTheme = darklegacyTheme;}- case 'system': {- theme = systemDarkMode ? darkTheme : regularTheme;- break;+ switch (currentTheme) {+ case 'light':+ return regularTheme;+ case 'dark':+ return darkTheme;+ case 'system':+ return systemDarkMode ? darkTheme : regularTheme;+ default:+ return regularTheme;}- }+ }, [currentTheme, defaultDarkTheme, defaultRegularTheme, systemDarkMode]);useEffect(() => {- const darkMode = currentTheme === 'dark';- // For Algolia DocSearch+ const darkMode = theme.palette.mode === 'dark';+ // For 3th party css like TailwindCSSdocument.documentElement.setAttribute('data-theme',darkMode ? 'dark' : 'light',);- // For TailwindCSSdocument.documentElement.classList.toggle('dark', darkMode);- }, [currentTheme]);+ }, [theme.palette.mode]);return (<StyledEngineProvider injectFirst><ThemeProvider theme={theme}>- <I18nextProvider i18n={i18n}>{props.children}</I18nextProvider>+ <I18nextProvider i18n={i18n}>{children}</I18nextProvider></ThemeProvider></StyledEngineProvider>);diff --git a/src/renderer/containers/MainPage.tsx b/src/renderer/containers/MainPage.tsxindex 351289d95..0d0cba023 100644--- a/src/renderer/containers/MainPage.tsx+++ b/src/renderer/containers/MainPage.tsx@@ -31,10 +31,16 @@ import SwipeableDrawer from '@mui/material/SwipeableDrawer';import { styled, useTheme } from '@mui/material/styles';import { buffer } from '@tagspaces/tagspaces-common/misc';import clsx from 'clsx';-import React, { useEffect, useReducer, useRef, useState } from 'react';+import React, {+ useCallback,+ useEffect,+ useMemo,+ useReducer,+ useRef,+ useState,+} from 'react';import { GlobalHotKeys } from 'react-hotkeys';-import { connect, useSelector } from 'react-redux';-import { bindActionCreators } from 'redux';+import { useDispatch, useSelector } from 'react-redux';import { Split } from 'ts-react-splitter';import EntryContainer from '../components/EntryContainer';import FolderContainer from '../components/FolderContainer';@@ -47,17 +53,14 @@ import {} from '../reducers/settings';const drawerWidth = 320;-const body = document.getElementsByTagName('body')[0];const bufferedLeftSplitResize = buffer({timeout: 300,id: 'buffered-leftsplit-resize',});-const PREFIX = 'MainPage';-const classes = {- content: `${PREFIX}-content`,- contentShift: `${PREFIX}-contentShift`,+ content: `MainPage-content`,+ contentShift: `MainPage-contentShift`,};const Root = styled('div')(({ theme }) => ({@@ -83,12 +86,8 @@ const Root = styled('div')(({ theme }) => ({},}));-interface Props {- toggleShowUnixHiddenEntries: () => void;- setMainVerticalSplitSize: (splitSize: string) => void;-}--function MainPage(props: Props) {+function MainPage() {+ const dispatch = useDispatch();const { openLink, openedEntry, isEntryInFullWidth, setEntryInFullWidth } =useOpenedEntryContext();@@ -104,16 +103,26 @@ function MainPage(props: Props) {const { showPanel } = usePanelsContext();const { isLoggedIn } = useUserContext();const percent = useRef<number | undefined>(undefined);- const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);+ const [, forceUpdate] = useReducer((x) => x + 1, 0);const [drawerOpened, setDrawerOpened] = useState<boolean>(true);const isDesktopMode: boolean = useSelector(getDesktopMode);const keyBindings = useSelector(getKeyBindingObject);const mainSplitSize = useSelector(getMainVerticalSplitSize);+ // Redux actions as callbacks+ const toggleShowUnixHiddenEntries = useCallback(+ () => dispatch(SettingsActions.toggleShowUnixHiddenEntries()),+ [dispatch],+ );+ const setMainVerticalSplitSize = useCallback(+ (splitSize: string) =>+ dispatch(SettingsActions.setMainVerticalSplitSize(splitSize)),+ [dispatch],+ );+useEventListener('message', (e) => {if (typeof e.data === 'string') {- // console.log(e.data);try {const data = JSON.parse(e.data);if (data.command === 'openLinkExternally') {@@ -132,16 +141,18 @@ function MainPage(props: Props) {if (!AppConfig.isCordova) {updateDimensions();}+ // eslint-disable-next-line}, []);useEffect(() => {if (isEntryInFullWidth) {- setDrawerOpened(false); // !props.isEntryInFullWidth);+ setDrawerOpened(false);}}, [isEntryInFullWidth]);useEffect(() => {updateDimensions();+ // eslint-disable-next-line}, [openedEntry]);useEventListener('resize', () => {@@ -150,18 +161,15 @@ function MainPage(props: Props) {}});- const updateDimensions = () => {+ const updateDimensions = useCallback(() => {const w =window.innerWidth ||document.documentElement.clientWidth ||- body.clientWidth;+ document.body.clientWidth;const h =window.innerHeight ||document.documentElement.clientHeight ||- body.clientHeight;-- // console.log('Width: ' + width + ' Height: ' + height);- //setDimensions({ width: w, height: h });+ document.body.clientHeight;if (openedEntry && !isEntryInFullWidth) {const isFillWidth = h > w;@@ -169,87 +177,101 @@ function MainPage(props: Props) {setEntryInFullWidth(isFillWidth);}}- };+ }, [openedEntry, isEntryInFullWidth, setEntryInFullWidth]);- const toggleDrawer = () => {+ const toggleDrawer = useCallback(() => {setDrawerOpened((prevOpen) => !prevOpen);- };+ }, []);- const keyBindingHandlers = {- openParentDirectory: loadParentDirectoryContent,- toggleShowHiddenEntries: props.toggleShowUnixHiddenEntries,- showLocationManager: () => {- showPanel('locationManagerPanel');- setDrawerOpened(true);- },- showTagLibrary: () => {- showPanel('tagLibraryPanel');- setDrawerOpened(true);- },- openSearch: () => {- if (!isEntryInFullWidth) {- enterSearchMode();- }- },- closeSearch: () => {- exitSearchMode();- openCurrentDirectory();- },- showHelp: () => {- showPanel('helpFeedbackPanel');- setDrawerOpened(true);- },- };+ const keyBindingHandlers = useMemo(+ () => ({+ openParentDirectory: loadParentDirectoryContent,+ toggleShowHiddenEntries: toggleShowUnixHiddenEntries,+ showLocationManager: () => {+ showPanel('locationManagerPanel');+ setDrawerOpened(true);+ },+ showTagLibrary: () => {+ showPanel('tagLibraryPanel');+ setDrawerOpened(true);+ },+ openSearch: () => {+ if (!isEntryInFullWidth) {+ enterSearchMode();+ }+ },+ closeSearch: () => {+ exitSearchMode();+ openCurrentDirectory();+ },+ showHelp: () => {+ showPanel('helpFeedbackPanel');+ setDrawerOpened(true);+ },+ }),+ [+ loadParentDirectoryContent,+ toggleShowUnixHiddenEntries,+ showPanel,+ setDrawerOpened,+ isEntryInFullWidth,+ enterSearchMode,+ exitSearchMode,+ openCurrentDirectory,+ ],+ );- const keyMap = {- openParentDirectory: keyBindings.openParentDirectory,- toggleShowHiddenEntries: keyBindings.toggleShowHiddenEntries,- showLocationManager: keyBindings.showLocationManager,- showTagLibrary: keyBindings.showTagLibrary,- openSearch: keyBindings.openSearch,- closeSearch: keyBindings.Escape,- showHelp: keyBindings.showHelp,- };+ const keyMap = useMemo(+ () => ({+ openParentDirectory: keyBindings.openParentDirectory,+ toggleShowHiddenEntries: keyBindings.toggleShowHiddenEntries,+ showLocationManager: keyBindings.showLocationManager,+ showTagLibrary: keyBindings.showTagLibrary,+ openSearch: keyBindings.openSearch,+ closeSearch: keyBindings.Escape,+ showHelp: keyBindings.showHelp,+ }),+ [keyBindings],+ );- const setPercent = (p: number | undefined) => {- percent.current = p;- if (p !== undefined) {- bufferedLeftSplitResize(() => {- if (mainSplitSize !== p + '%') {- props.setMainVerticalSplitSize(p + '%');- }- });- }- forceUpdate();- };+ const setPercent = useCallback(+ (p: number | undefined) => {+ percent.current = p;+ if (p !== undefined) {+ bufferedLeftSplitResize(() => {+ if (mainSplitSize !== p + '%') {+ setMainVerticalSplitSize(p + '%');+ }+ });+ }+ forceUpdate();+ },+ [mainSplitSize, setMainVerticalSplitSize],+ );function renderContainers() {let initialPrimarySize = mainSplitSize;let minPrimarySize = '250px';let minSecondarySize = '250px';- let renderSplitter;+ let renderSplitter: (() => React.ReactNode) | undefined;if (!openedEntry) {percent.current = undefined;initialPrimarySize = '100%';minSecondarySize = '0%';- renderSplitter = function () {- return null;- };+ renderSplitter = () => null;}if (isEntryInFullWidth) {percent.current = undefined;initialPrimarySize = '0%';minPrimarySize = '0%';- renderSplitter = function () {- return null;- };+ renderSplitter = () => null;}if (smallScreen && openedEntry) {return (<><FolderContainer- style={{ display: 'none' }}+ hiddentoggleDrawer={toggleDrawer}drawerOpened={drawerOpened}/>@@ -365,14 +387,4 @@ function MainPage(props: Props) {);}-function mapDispatchToProps(dispatch) {- return bindActionCreators(- {- toggleShowUnixHiddenEntries: SettingsActions.toggleShowUnixHiddenEntries,- setMainVerticalSplitSize: SettingsActions.setMainVerticalSplitSize,- },- dispatch,- );-}--export default connect(undefined, mapDispatchToProps)(React.memo(MainPage));+export default React.memo(MainPage);diff --git a/src/renderer/containers/withDnDContext.tsx b/src/renderer/containers/withDnDContext.tsxdeleted file mode 100644index 3c6c519df..000000000--- a/src/renderer/containers/withDnDContext.tsx+++ /dev/null@@ -1,12 +0,0 @@-/*import * as React from 'react';-import { DndProvider } from 'react-dnd';-import { HTML5Backend } from 'react-dnd-html5-backend';--export default (Component) =>- function (props) {- return (- <DndProvider backend={HTML5Backend}>- <Component {...props} />- </DndProvider>- );- };*/diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.jsonindex 36dceb108..f840dfeb4 100644--- a/src/renderer/locales/en/core.json+++ b/src/renderer/locales/en/core.json@@ -1106,5 +1106,6 @@"importCompletedWithErrors": "Import completed with errors","dateCreatedSearchTitle": "Date Created","toggleSidebar": "Toggle sidebar",+ "searchSettings": "Search settings","-": "-"}diff --git a/src/renderer/perspectives/grid/components/GridCell.tsx b/src/renderer/perspectives/grid/components/GridCell.tsxindex f1c130c8e..ed99a82a2 100644--- a/src/renderer/perspectives/grid/components/GridCell.tsx+++ b/src/renderer/perspectives/grid/components/GridCell.tsx@@ -68,7 +68,7 @@ import {extractTitle,getThumbFileLocationForFile,} from '@tagspaces/tagspaces-common/paths';-import { useEffect, useReducer, useRef } from 'react';+import { useCallback, useEffect, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';import { useSelector } from 'react-redux';import { defaultSettings } from '../index';@@ -77,43 +77,27 @@ export function urlGetDelim(url) {return url.indexOf('?') > 0 ? '&' : '?';}+// Centralize entry size config for maintainability+const ENTRY_SIZES = {+ tiny: 130,+ small: 160,+ big: 250,+ huge: 300,+ normal: 200,+} as const;+export function calculateEntryWidth(entrySize: TS.EntrySizes) {- let entryWidth = 200;- if (entrySize === 'tiny') {- entryWidth = 130;- } else if (entrySize === 'small') {- entryWidth = 160;- } else if (entrySize === 'normal') {- entryWidth = 200;- } else if (entrySize === 'big') {- entryWidth = 250;- } else if (entrySize === 'huge') {- entryWidth = 300;- }- return entryWidth;+ return ENTRY_SIZES[entrySize] ?? ENTRY_SIZES.normal;}export function calculateEntryHeight(entrySize: TS.EntrySizes) {- let entryHeight = 200;- if (entrySize === 'tiny') {- entryHeight = 130;- } else if (entrySize === 'small') {- entryHeight = 160;- } else if (entrySize === 'normal') {- entryHeight = 200;- } else if (entrySize === 'big') {- entryHeight = 250;- } else if (entrySize === 'huge') {- entryHeight = 300;- }- return entryHeight;+ return ENTRY_SIZES[entrySize] ?? ENTRY_SIZES.normal;}interface Props {selected: boolean;isLast?: boolean;fsEntry: TS.FileSystemEntry;- style?: any;selectionMode: boolean;handleTagMenu: (event: Object,@@ -148,69 +132,65 @@ function GridCell(props: Props) {const supportedFileTypes = useSelector(getSupportedFileTypes);const reorderTags: boolean = useSelector(isReorderTags);const tagDelimiter: string = useSelector(getTagDelimiter);- const thumbPath = useRef<string>(undefined);- const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);const firstRender = useFirstRender();- const fileSystemEntryColor = findColorForEntry(fsEntry, supportedFileTypes);+ const fileSystemEntryColor = useMemo(+ () => findColorForEntry(fsEntry, supportedFileTypes),+ [fsEntry, supportedFileTypes],+ );const maxHeight = calculateEntryHeight(entrySize);const entryPath = fsEntry.path;const isSmall = entrySize === 'tiny' || entrySize === 'small';const gridCellLocation = findLocation(fsEntry.locationID);- function getThumbUrl() {- if (gridCellLocation) {- return gridCellLocation- .getThumbPath(fsEntry.meta.thumbPath, fsEntry.meta?.lastUpdated)- .then((tmbPath) => {- if (tmbPath !== thumbPath.current) {- thumbPath.current = tmbPath;- return true;- }- return false;- });+ // Thumbnail state and helpers+ const [thumbSrc, setThumbSrc] = useState<string | undefined>(undefined);++ const getThumbUrl = useCallback(async (): Promise<string | undefined> => {+ if (!gridCellLocation) return undefined;+ try {+ const tmbPath = await gridCellLocation.getThumbPath(+ fsEntry.meta.thumbPath,+ fsEntry.meta?.lastUpdated,+ );+ return tmbPath ?? undefined;+ } catch {+ return undefined;}- return Promise.resolve(false);- }+ }, [gridCellLocation, fsEntry.meta?.thumbPath, fsEntry.meta?.lastUpdated]);- function setThumbPath(): Promise<boolean> {- if (gridCellLocation && fsEntry.meta) {- if (fsEntry.meta.thumbPath) {- if (gridCellLocation.encryptionKey) {- let thumbFilePath = getThumbFileLocationForFile(- fsEntry.path,- gridCellLocation.getDirSeparator(),- false,- );- return gridCellLocation- .getFileContentPromise(thumbFilePath, 'arraybuffer')- .then((arrayBuffer) => {- if (arrayBuffer) {- return arrayBufferToDataURL(arrayBuffer, 'image/jpeg').then(- (dataURL) => {- thumbPath.current = dataURL;- return true;- },- );- } else if (arrayBuffer === undefined) {- return getThumbUrl();- }- });- } else {- return getThumbUrl();+ const setThumbPath = useCallback(async () => {+ if (!gridCellLocation || !fsEntry.meta?.thumbPath) {+ setThumbSrc(undefined);+ return;+ }+ if (gridCellLocation.encryptionKey) {+ try {+ const thumbFilePath = getThumbFileLocationForFile(+ fsEntry.path,+ gridCellLocation.getDirSeparator(),+ false,+ );+ const arrayBuffer = await gridCellLocation.getFileContentPromise(+ thumbFilePath,+ 'arraybuffer',+ );+ if (arrayBuffer) {+ const dataUrl = await arrayBufferToDataURL(arrayBuffer, 'image/jpeg');+ setThumbSrc(dataUrl);+ return;}+ } catch {+ // fallback below}}- return Promise.resolve(false);- }+ const url = await getThumbUrl();+ setThumbSrc(url);+ }, [gridCellLocation, fsEntry.path, fsEntry.meta, getThumbUrl]);useEffect(() => {- setThumbPath().then((success) => {- if (success) {- forceUpdate();- }- });- }, [fsEntry]);+ setThumbPath();+ }, [setThumbPath]);useEffect(() => {if (!firstRender && metaActions && metaActions.length > 0) {@@ -220,100 +200,83 @@ function GridCell(props: Props) {cleanTrailingDirSeparator(cleanFrontDirSeparator(fsEntry.path)) ===cleanTrailingDirSeparator(cleanFrontDirSeparator(action.entry.path))) {+ fsEntry.meta = { ...action.entry.meta };if (action.action === 'thumbChange') {- fsEntry.meta = { ...action.entry.meta };- setThumbPath().then((success) => {- if (success) {- forceUpdate();- }- });+ setThumbSrc(undefined);+ setThumbPath();} else if (action.action === 'bgdColorChange' ||action.action === 'descriptionChange') {- fsEntry.meta = { ...action.entry.meta };- forceUpdate();+ setThumbPath();}}}}+ // eslint-disable-next-line react-hooks/exhaustive-deps}, [metaActions]);if (!gridCellLocation && fsEntry.locationID) {- // location not exist in locationManager (maybe removed)return null;}- const handleEditTag = (path: string, tag: TS.Tag, newTagTitle?: string) => {- editTagForEntry(path, tag, newTagTitle);- };-- const handleAddTag = (tag: TS.Tag, parentTagGroupUuid: TS.Uuid) => {- addTag([tag], parentTagGroupUuid);- };+ // Memoized callbacks and derived data+ const handleEditTag = useCallback(+ (path: string, tag: TS.Tag, newTagTitle?: string) => {+ editTagForEntry(path, tag, newTagTitle);+ },+ [editTagForEntry],+ );- // remove isNewFile on Cell click it will open file in editMode- /*const fSystemEntry: TS.FileSystemEntry = (({ isNewFile, ...o }) => o)(- fsEntry,- );*/+ const handleAddTag = useCallback(+ (tag: TS.Tag, parentTagGroupUuid: TS.Uuid) => {+ addTag([tag], parentTagGroupUuid);+ },+ [addTag],+ );- const entryTitle = extractTitle(- fsEntry.name,- !fsEntry.isFile,- gridCellLocation?.getDirSeparator(),+ const entryTitle = useMemo(+ () =>+ extractTitle(+ fsEntry.name,+ !fsEntry.isFile,+ gridCellLocation?.getDirSeparator(),+ ),+ [fsEntry.name, fsEntry.isFile, gridCellLocation],);- let description;- if (showEntriesDescription) {- description = fsEntry.meta?.description;- if (- description &&- description.length > defaultSettings.maxDescriptionPreviewLength- ) {- description = getDescriptionPreview(- description,+ const description = useMemo(() => {+ if (!showEntriesDescription) return undefined;+ let desc = fsEntry.meta?.description;+ if (desc && desc.length > defaultSettings.maxDescriptionPreviewLength) {+ desc = getDescriptionPreview(+ desc,defaultSettings.maxDescriptionPreviewLength,);}- }-- function generateCardHeader() {- return (- !isSmall &&- fsEntry.isFile &&- fsEntry.lmdt && (- <>- <Tooltip- title={- t('core:modifiedDate') + ': ' + formatDateTime(fsEntry.lmdt, true)- }- >- {formatDateTime(fsEntry.lmdt, false)}- </Tooltip>- <Tooltip title={fsEntry.size + ' ' + t('core:sizeInBytes')}>- <span>{' | ' + formatFileSize(fsEntry.size)}</span>- </Tooltip>- </>- )- );- }+ return desc;+ }, [showEntriesDescription, fsEntry.meta?.description]);- let fileNameTags = [];- if (fsEntry.isFile) {- fileNameTags = extractTagsAsObjects(+ const fileNameTags = useMemo(() => {+ if (!fsEntry.isFile) return [];+ return extractTagsAsObjects(fsEntry.name,tagDelimiter,gridCellLocation?.getDirSeparator(),);- }- const fileSystemEntryTags =- fsEntry.meta && fsEntry.meta.tags ? fsEntry.meta.tags : [];- const sideCarTagsTitles = fileSystemEntryTags.map((tag) => tag.title);- const entryTags = [- ...fileSystemEntryTags,- ...fileNameTags.filter((tag) => !sideCarTagsTitles.includes(tag.title)),- ];- const renderTags = () => {+ }, [fsEntry.isFile, fsEntry.name, tagDelimiter, gridCellLocation]);++ const fileSystemEntryTags: TS.Tag[] = fsEntry.meta?.tags ?? [];++ const entryTags = useMemo(() => {+ const sideCarTitles = new Set(fileSystemEntryTags.map((t) => t.title));+ return [+ ...fileSystemEntryTags,+ ...fileNameTags.filter((t) => !sideCarTitles.has(t.title)),+ ];+ }, [fileSystemEntryTags, fileNameTags]);++ const renderTags = useCallback(() => {let sideCarLength = 0;return entryTags.map((tag: TS.Tag, index) => {const tagContainer = gridCellLocation.isReadOnly ? (@@ -336,19 +299,74 @@ function GridCell(props: Props) {reorderTags={reorderTags}/>);-if (tag.type === 'sidecar') {sideCarLength = index + 1;}return tagContainer;});- };+ }, [+ entryTags,+ gridCellLocation,+ entryPath,+ fsEntry,+ handleTagMenu,+ handleAddTag,+ selectedEntries,+ handleEditTag,+ reorderTags,+ ]);++ // Memoized handlers for clarity and performance+ const handleCellClick = useCallback(+ (event: React.MouseEvent) => {+ event.stopPropagation();+ AppConfig.isCordovaiOS+ ? handleGridCellDblClick(event, fsEntry)+ : handleGridCellClick(event, fsEntry);+ },+ [fsEntry, handleGridCellDblClick, handleGridCellClick],+ );++ const handleContextMenu = useCallback(+ (event: React.MouseEvent) => {+ handleGridContextMenu(event, fsEntry);+ },+ [fsEntry, handleGridContextMenu],+ );++ const handleThumbError = useCallback(+ (event: React.SyntheticEvent<HTMLImageElement>) => {+ event.currentTarget.style.display = 'none';+ },+ [],+ );++ function generateCardHeader() {+ return (+ !isSmall &&+ fsEntry.isFile &&+ fsEntry.lmdt && (+ <>+ <Tooltip+ title={+ t('core:modifiedDate') + ': ' + formatDateTime(fsEntry.lmdt, true)+ }+ >+ {formatDateTime(fsEntry.lmdt, false)}+ </Tooltip>+ <Tooltip title={fsEntry.size + ' ' + t('core:sizeInBytes')}>+ <span>{' | ' + formatFileSize(fsEntry.size)}</span>+ </Tooltip>+ </>+ )+ );+ }function generateExtension() {return (<Tooltip title={i18n.t('clickToSelect') + ': ' + fsEntry.name}><FileExtBadge- style={{+ sx={{backgroundColor: fileSystemEntryColor,}}noWrap={true}@@ -356,11 +374,7 @@ function GridCell(props: Props) {onClick={(e) => {e.stopPropagation();if (selectionMode) {- if (selected) {- selectEntry(fsEntry, false);- } else {- selectEntry(fsEntry);- }+ selectEntry(fsEntry, !selected);} else {selectEntry(fsEntry);}@@ -385,68 +399,58 @@ function GridCell(props: Props) {return (<Carddata-entry-id={fsEntry.uuid}- data-tid={'fsEntryName_' + dataTidFormat(fsEntry.name)}+ data-tid={`fsEntryName_${dataTidFormat(fsEntry.name)}`}+ data-selected={selected}raised={selected}- style={{+ sx={{height: maxHeight,minHeight: maxHeight,- maxHeight: maxHeight,+ maxHeight,maxWidth: 400,- marginBottom: 'auto', // isLast ? 40 : 'auto',+ marginBottom: 'auto',borderRadius: AppConfig.defaultCSSRadius,backgroundColor: alpha(theme.palette.divider, 0.7),- border:- '2px solid ' +- (selected ? theme.palette.primary.main : 'transparent'), // theme.palette.divider+ border: `2px solid ${selected ? theme.palette.primary.main : 'transparent'}`,display: 'flex',boxShadow: 'none',flexDirection: 'column',}}- onContextMenu={(event) => handleGridContextMenu(event, fsEntry)}- onDoubleClick={(event) => {- handleGridCellDblClick(event, fsEntry);- }}- onClick={(event) => {- event.stopPropagation();- AppConfig.isCordovaiOS // TODO DoubleClick not fired in Cordova IOS- ? handleGridCellDblClick(event, fsEntry)- : handleGridCellClick(event, fsEntry);- }}- onDrag={(event) => {- handleGridCellClick(event, fsEntry);- }}+ onContextMenu={handleContextMenu}+ onDoubleClick={(event) => handleGridCellDblClick(event, fsEntry)}+ onClick={handleCellClick}+ onDrag={handleCellClick}><Box- style={{+ sx={{height: maxHeight - 70,position: 'relative',backgroundColor: findBackgroundColorForFolder(fsEntry),}}>- <Box style={{ position: 'absolute' }}>- {showTags && entryTags ? (+ <Box sx={{ position: 'absolute' }}>+ {showTags && entryTags.length > 0 ? (renderTags()) : (<TagsPreview tags={entryTags} />)}</Box>- {fsEntry.meta && fsEntry.meta.thumbPath && thumbPath.current ? (+ {fsEntry.meta?.thumbPath && thumbSrc ? (<CardMediacomponent="img"loading="lazy"- // @ts-ignore- onError={(i) => (i.target.style.display = 'none')}- alt="thumbnail image"+ onError={handleThumbError}+ alt={t('core:thumbnailImage')}+ data-tid="imageThumbnailTID"height="auto"- src={thumbPath.current.replace(/#/g, '%23')}- style={{+ src={thumbSrc.replace(/#/g, '%23')}+ sx={{height: maxHeight - 70,objectFit: thumbnailMode,}}/>) : (<Box- style={{+ sx={{width: '50%',height: 'auto',margin: '0 auto',@@ -463,8 +467,8 @@ function GridCell(props: Props) {<CardContent sx={{ padding: '1px 5px 0px 5px', flexGrow: 1 }}><Typographytitle={fsEntry.name}- style={{- paddingRight: 4,+ sx={{+ paddingRight: '4px',overflowX: 'clip',textWrap: 'nowrap',whiteSpace: 'nowrap',@@ -479,9 +483,9 @@ function GridCell(props: Props) {variant="caption"display="block"gutterBottom- style={{+ sx={{lineHeight: '12px',- paddingRight: 4,+ paddingRight: '4px',overflowX: 'clip',textWrap: 'nowrap',whiteSpace: 'nowrap',@@ -493,8 +497,8 @@ function GridCell(props: Props) {)}</CardContent><CardHeader- style={{ padding: 2 }}sx={{+ padding: '2px','.MuiCardHeader-avatar': {margin: 0,alignSelf: 'flex-start',@@ -508,15 +512,15 @@ function GridCell(props: Props) {<TsIconButtonaria-label="entry context menu"size="small"- style={{ marginRight: 5 }}- onClick={(event) => handleGridContextMenu(event, fsEntry)}+ sx={{ marginRight: '5px' }}+ onClick={handleContextMenu}><MoreMenuIcon /></TsIconButton>}subheader={generateCardHeader()}avatar={generateExtension()}- ></CardHeader>+ /></Card>);}diff --git a/src/renderer/perspectives/grid/components/GridPagination.tsx b/src/renderer/perspectives/grid/components/GridPagination.tsxindex 4c166ab63..ce07d0bb7 100644--- a/src/renderer/perspectives/grid/components/GridPagination.tsx+++ b/src/renderer/perspectives/grid/components/GridPagination.tsx@@ -31,6 +31,7 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';import { usePaginationContext } from '-/hooks/usePaginationContext';import { usePerspectiveSettingsContext } from '-/hooks/usePerspectiveSettingsContext';+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';import CellView from '-/perspectives/common/CellView';import { useSortedDirContext } from '-/perspectives/grid/hooks/useSortedDirContext';import { Pro } from '-/pro';@@ -45,10 +46,16 @@ import Pagination from '@mui/material/Pagination';import Typography from '@mui/material/Typography';import { useTheme } from '@mui/material/styles';import { extractDirectoryName } from '@tagspaces/tagspaces-common/paths';-import React, { useContext, useEffect, useReducer, useRef } from 'react';+import React, {+ useCallback,+ useContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+} from 'react';import { useTranslation } from 'react-i18next';import GridCellsContainer from './GridCellsContainer';-import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';interface Props {desktopMode: boolean;@@ -62,22 +69,15 @@ interface Props {isLast?: boolean,) => void;currentDirectoryPath: string;- //onContextMenu: (event: React.MouseEvent<HTMLDivElement>) => void;onClick: (event: React.MouseEvent<HTMLDivElement>) => void;- // eslint-disable-next-line react/no-unused-prop-types- //selectedEntries; // cache onlysetSelectedEntries: (selectedEntries: Array<TS.FileSystemEntry>) => void;clearSelection: () => void;}function GridPagination(props: Props) {const { t } = useTranslation();- const {- getCellContent,- currentDirectoryPath,- //selectedEntries,- setSelectedEntries,- } = props;+ const { getCellContent, currentDirectoryPath, setSelectedEntries, onClick } =+ props;const { selectedEntries } = useSelectedEntriesContext();const { openDirectoryMenu, openRenameEntryDialog } = useMenuContext();const {@@ -98,15 +98,21 @@ function GridPagination(props: Props) {Pro.contextProviders.ThumbDialogContext,): undefined;- const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);+ const [, forceUpdate] = useReducer((x) => x + 1, 0);const currentLocation = findLocation();-const theme = useTheme();const pageFiles = getResentPageFiles();- const showPagination = sortedDirContent.length !== pageFiles.length;- const paginationCount = showPagination- ? Math.ceil(sortedDirContent.length / gridPageLimit)- : 10;++ // Memoize derived values for performance+ const showPagination = useMemo(+ () => sortedDirContent.length !== pageFiles.length,+ [sortedDirContent.length, pageFiles.length],+ );+ const paginationCount = useMemo(+ () =>+ showPagination ? Math.ceil(sortedDirContent.length / gridPageLimit) : 10,+ [showPagination, sortedDirContent.length, gridPageLimit],+ );const backgroundImage = useRef<string>('none');const thumbImage = useRef<string>('none');@@ -120,7 +126,7 @@ function GridPagination(props: Props) {currentLocation.getFolderBgndPath(currentDirectoryPath, directoryMeta?.lastUpdated).then((bgPath) => {- const bgImage = 'url("' + bgPath + '")';+ const bgImage = `url("${bgPath}")`;if (bgImage !== backgroundImage.current) {backgroundImage.current = bgImage;forceUpdate();@@ -129,49 +135,51 @@ function GridPagination(props: Props) {currentLocation.getFolderThumbPath(currentDirectoryPath, directoryMeta?.lastUpdated).then((thumbPath) => {- const thbImage = 'url("' + thumbPath + '")';+ const thbImage = `url("${thumbPath}")`;if (thbImage !== thumbImage.current) {thumbImage.current = thbImage;forceUpdate();}});}- }, [currentDirectoryPath, containerEl.current, directoryMeta]);-- const handleChange = (event, value) => {- setCurrentPage(value);- if (containerEl && containerEl.current) {- containerEl.current.scrollTop = 0;- }- };+ }, [currentDirectoryPath, directoryMeta?.lastUpdated, currentLocation]);- const folderName = extractDirectoryName(props.currentDirectoryPath);+ const handleChange = useCallback(+ (event: React.ChangeEvent<unknown>, value: number) => {+ setCurrentPage(value);+ if (containerEl.current) {+ containerEl.current.scrollTop = 0;+ }+ },+ [setCurrentPage],+ );- const dirColor =- directoryMeta && directoryMeta.color ? directoryMeta.color : 'transparent';+ const folderName = useMemo(+ () => extractDirectoryName(currentDirectoryPath),+ [currentDirectoryPath],+ );- const files: TS.FileSystemEntry[] = [];- const dirs: TS.FileSystemEntry[] = [];+ const dirColor = directoryMeta?.color || 'transparent';- for (const entry of sortedDirContent) {- if (entry.isFile) {- files.push(entry);- } else {- dirs.push(entry);+ // Separate files and directories+ const { files, dirs } = useMemo(() => {+ const files: TS.FileSystemEntry[] = [];+ const dirs: TS.FileSystemEntry[] = [];+ for (const entry of sortedDirContent) {+ if (entry.isFile) files.push(entry);+ else dirs.push(entry);}- }+ return { files, dirs };+ }, [sortedDirContent]);- let folderSummary =- (dirs.length > 0 ? dirs.length + ' folder(s) and ' : '') +- files.length +- ' file(s) found';- if (selectedEntries && selectedEntries.length > 0) {- folderSummary = selectedEntries.length + ' entries selected';- }+ const folderSummary = useMemo(() => {+ if (selectedEntries && selectedEntries.length > 0) {+ return `${selectedEntries.length} entries selected`;+ }+ return `${dirs.length > 0 ? `${dirs.length} folder(s) and ` : ''}${files.length} file(s) found`;+ }, [selectedEntries, dirs.length, files.length]);- // **********************************************************************// Utility: Check if Two Rectangles Intersect- // **********************************************************************const rectIntersects = (r1: DOMRect, r2: DOMRect): boolean => {return !(r2.left > r1.right ||@@ -183,306 +191,245 @@ function GridPagination(props: Props) {// Called when a selection drag ends. We look for any item elements whose// bounding rectangle intersects the drag rectangle.- const handleSelect = (selectionRect: DOMRect) => {- const container = containerEl.current;- if (!container) return;+ const handleSelect = useCallback(+ (selectionRect: DOMRect) => {+ const container = containerEl.current;+ if (!container) return;- const newlySelected: string[] = [];- // Find all elements that represent items (we use the data-item attribute)- const itemElements = container.querySelectorAll('[data-entry-id]');- itemElements.forEach((el) => {- const itemRect = el.getBoundingClientRect();- if (rectIntersects(selectionRect, itemRect)) {- const id = el.getAttribute('data-entry-id');- newlySelected.push(id);+ const newlySelected: string[] = [];+ const itemElements = container.querySelectorAll('[data-entry-id]');+ itemElements.forEach((el) => {+ const itemRect = el.getBoundingClientRect();+ if (rectIntersects(selectionRect, itemRect)) {+ const id = el.getAttribute('data-entry-id');+ if (id) newlySelected.push(id);+ }+ });+ if (newlySelected.length > 0) {+ setSelectedEntries(+ pageFiles.filter((e) => newlySelected.includes(e.uuid)),+ );}- });- if (newlySelected.length > 0) {- setSelectedEntries(- pageFiles.filter((e) => newlySelected.includes(e.uuid)),- );- }- };+ },+ [pageFiles, setSelectedEntries],+ );++ // Render folder details and description+ const renderFolderDetails = () => (+ <Grid size={12} sx={{ position: 'relative' }}>+ <Box+ sx={{+ display: 'flex',+ alignItems: 'center',+ overflow: 'auto',+ padding: '10px',+ marginRight: '160px',+ width: 'fit-content',+ borderRadius: 8,+ color: theme.palette.text.primary,+ }}+ >+ <TooltipTS title={t('core:renameDirectory')}>+ <ButtonBase+ data-tid={`currentDir_${dataTidFormat(folderName)}`}+ sx={{+ fontSize: '1.5rem',+ filter: `drop-shadow(0px 0px 4px ${theme.palette.background.default})`,+ }}+ onClick={() => {+ setSelectedEntries([]);+ openRenameEntryDialog();+ }}+ >+ {folderName}+ </ButtonBase>+ </TooltipTS>+ {showTags ? (+ <Box sx={{ paddingLeft: '5px' }}>+ {directoryMeta?.tags?.map((tag) => (+ <TagContainer key={tag.title} tag={tag} tagMode="display" />+ ))}+ </Box>+ ) : (+ <TagsPreview tags={directoryMeta?.tags} />+ )}+ </Box>+ <Box+ data-tid={`allFilesCount${files.length}`}+ sx={{+ paddingBottom: '5px',+ marginTop: '10px',+ marginRight: '160px',+ padding: '10px',+ borderRadius: '10px',+ width: 'fit-content',+ color: theme.palette.text.primary,+ }}+ >+ <Typography+ sx={{+ fontSize: '0.9rem',+ filter: `drop-shadow(0px 0px 4px ${theme.palette.background.default})`,+ }}+ >+ {folderSummary}+ </Typography>+ {!showDescription && directoryMeta?.description && (+ <Typography+ sx={{+ fontSize: '0.8rem',+ wordBreak: 'break-all',+ filter: `drop-shadow(0px 0px 2px ${theme.palette.background.default})`,+ height: 45,+ overflowY: 'auto',+ }}+ >+ {getDescriptionPreview(directoryMeta.description, 200)}+ </Typography>+ )}+ </Box>+ <TooltipTS title={t('core:changeThumbnail')} placement="bottom">+ <Box+ style={{ backgroundImage: thumbImage.current }}+ sx={{+ ':hover': { border: '1px dashed gray !important' },+ borderRadius: AppConfig.defaultCSSRadius,+ border: '1px solid transparent',+ height: 100,+ width: 100,+ backgroundSize: 'cover',+ backgroundRepeat: 'no-repeat',+ backgroundPosition: 'center center',+ position: 'absolute',+ top: 0,+ right: 7,+ cursor: 'pointer',+ }}+ data-tid="folderThumbTID"+ onClick={() => {+ if (Pro) {+ getAllPropertiesPromise(currentDirectoryPath).then(+ (fsEntry: TS.FileSystemEntry) =>+ thumbDialogContext.openThumbsDialog(fsEntry),+ );+ }+ }}+ />+ </TooltipTS>+ </Grid>+ );++ // Render folder description in markdown editor+ const renderFolderDescription = () =>+ showDescription &&+ directoryMeta?.description && (+ <Grid+ title={`${t('core:folderDescription')} - ${t('core:doubleClickToEdit')}`}+ size={12}+ className="gridPagination"+ sx={{+ backgroundColor: theme.palette.background.default,+ borderBottom: `1px solid ${theme.palette.divider}`,+ marginTop: '10px',+ marginLeft: '8px',+ marginRight: '8px',+ marginBottom: '5px',+ borderRadius: AppConfig.defaultCSSRadius,+ }}+ onDoubleClick={() =>+ openEntry(currentDirectoryPath, TabNames.descriptionTab)+ }+ >+ <style>+ {`+ .gridPagination .milkdown .ProseMirror h1 { margin-top: 10px; }+ .gridPagination .milkdown { border-radius: ${AppConfig.defaultCSSRadius}; }+ .gridPagination .milkdown .ProseMirror { padding: 10px; }+ .gridPagination .milkdown .ProseMirror a { color: ${theme.palette.primary.main}; }+ .gridPagination .milkdown .ProseMirror img { max-width: 99%; }+ `}+ </style>+ <MilkdownProvider>+ <LightMdEditor+ defaultContent={directoryMeta.description}+ placeholder=""+ />+ </MilkdownProvider>+ </Grid>+ );++ // Render empty state+ const renderEmptyState = (message: string) => (+ <Box sx={{ textAlign: 'center' }}>+ {!showDescription && directoryMeta?.description && (+ <Box sx={{ position: 'relative', mx: 'auto', maxWidth: 150 }}>+ <EntryIcon isFile={false} />+ </Box>+ )}+ <Typography sx={{ padding: '15px', color: theme.palette.text.secondary }}>+ {message}+ </Typography>+ {!AppConfig.isCordova && (+ <Typography sx={{ color: theme.palette.text.secondary }}>+ {t('core:dragAndDropToImport')}+ </Typography>+ )}+ </Box>+ );return (- <div+ <Boxdata-tid="backgroundTID"- style={{+ sx={{height: '100%',- background: `${dirColor}`,+ background: dirColor,}}>- <div+ <Boxref={containerEl}onContextMenu={(event: React.MouseEvent<HTMLDivElement>) =>openDirectoryMenu(event, currentDirectoryPath)}- onClick={(event: React.MouseEvent<HTMLDivElement>) =>- props.onClick(event)- }+ onClick={onClick}style={{+ backgroundImage: backgroundImage.current,+ }}+ sx={{height: '100%',overflowY: 'auto',overflowX: 'hidden',- backgroundImage: backgroundImage.current,backgroundSize: 'cover',backgroundRepeat: 'no-repeat',}}><Grid container spacing={0}>- <Grid size={12} style={{ height: 60 }} />- {showDetails && (- <Grid size={12}>- <div- style={{- marginLeft: 8,- marginRight: 8,- marginTop: 0,- marginBottom: 0,- height:- !showDescription &&- directoryMeta &&- directoryMeta.description- ? 150- : 125,- position: 'relative',- }}- >- {((folderName && folderName.length > 0) ||- (directoryMeta &&- directoryMeta.tags &&- directoryMeta.tags.length > 0)) && (- <Box- style={{- display: 'flex',- alignItems: 'center',- overflow: 'auto',- padding: 10,- marginRight: 160,- width: 'fit-content',- borderRadius: 8,- color: theme.palette.text.primary,- }}- >- <TooltipTS title={t('core:renameDirectory')}>- <ButtonBase- data-tid={'currentDir_' + dataTidFormat(folderName)}- style={{- fontSize: '1.5rem',- filter: `drop-shadow(0px 0px 4px ${theme.palette.background.default})`,- }}- onClick={() => {- setSelectedEntries([]);- openRenameEntryDialog();- }}- >- {folderName}- </ButtonBase>- </TooltipTS>- {showTags ? (- <span style={{ paddingLeft: 5 }}>- {directoryMeta?.tags?.map((tag: TS.Tag) => {- return <TagContainer tag={tag} tagMode="display" />;- })}- </span>- ) : (- <TagsPreview tags={directoryMeta?.tags} />- )}- </Box>- )}- <Box- data-tid={'allFilesCount' + files.length}- style={{- paddingBottom: 5,- marginTop: 10,- marginRight: 160,- padding: 10,- borderRadius: 10,- width: 'fit-content',- color: theme.palette.text.primary,- }}- >- <Typography- style={{- fontSize: '0.9rem',- filter: `drop-shadow(0px 0px 4px ${theme.palette.background.default})`,- }}- >- {folderSummary}- </Typography>- {!showDescription &&- directoryMeta &&- directoryMeta.description && (- <Typography- style={{- fontSize: '0.8rem',- wordBreak: 'break-all',- filter: `drop-shadow(0px 0px 2px ${theme.palette.background.default})`,- height: 45,- overflowY: 'auto',- }}- >- {getDescriptionPreview(directoryMeta.description, 200)}- </Typography>- )}- </Box>- <TooltipTS title={t('core:changeThumbnail')} placement="bottom">- <Box- sx={{- ':hover': {- border: '1px dashed gray !important',- },- }}- data-tid="folderThumbTID"- style={{- borderRadius: AppConfig.defaultCSSRadius,- border: '1px solid transparent',- height: 100,- width: 100,- backgroundImage: thumbImage.current,- backgroundSize: 'cover', // cover contain- backgroundRepeat: 'no-repeat',- backgroundPosition: 'center center',- position: 'absolute',- top: 15,- right: 0,- cursor: 'pointer',- }}- onClick={() => {- if (Pro) {- getAllPropertiesPromise(currentDirectoryPath).then(- (fsEntry: TS.FileSystemEntry) =>- thumbDialogContext.openThumbsDialog(fsEntry),- );- }- }}- />- </TooltipTS>- </div>- </Grid>- )}- {showDescription && directoryMeta?.description && (- <Grid- title={- t('core:folderDescription') +- ' - ' +- t('core:doubleClickToEdit')- }- size={12}- className="gridPagination"- spacing={0}- style={{- backgroundColor: theme.palette.background.default,- borderBottom: '1px solid ' + theme.palette.divider,- marginTop: 10,- marginLeft: 8,- marginRight: 8,- marginBottom: 5,- borderRadius: AppConfig.defaultCSSRadius,- }}- onDoubleClick={() =>- openEntry(currentDirectoryPath, TabNames.descriptionTab)- }- >- <style>- {`- .gridPagination .milkdown .ProseMirror h1 {- margin-top: 10px;- }- .gridPagination .milkdown {- border-radius: ${AppConfig.defaultCSSRadius};- }- .gridPagination .milkdown .ProseMirror {- padding: 10px;- }- .gridPagination .milkdown .ProseMirror a {- color: ${theme.palette.primary.main};- }- .gridPagination .milkdown .ProseMirror img {- max-width: 99%;- }- `}- </style>- <MilkdownProvider>- <LightMdEditor- defaultContent={directoryMeta.description}- placeholder=""- />- </MilkdownProvider>- </Grid>- )}+ <Grid size={12} sx={{ height: 70 }} />+ {showDetails && renderFolderDetails()}+ {renderFolderDescription()}</Grid><SelectionDragLayer /><SelectionArea onSelect={handleSelect}><GridCellsContainer>- {pageFiles.map((entry, index, dArray) => (+ {pageFiles.map((entry, index) => (<CellViewkey={entry.uuid + index}fsEntry={entry}index={index}cellContent={getCellContent}- isLast={index === dArray.length - 1}+ isLast={index === pageFiles.length - 1}/>))}- {pageFiles.length < 1 && (- <div style={{ textAlign: 'center' }}>- {!showDescription &&- directoryMeta &&- directoryMeta.description && (- <div- style={{- position: 'relative',- margin: 'auto',- maxWidth: 150,- }}- >- <EntryIcon isFile={false} />- </div>- )}- <Typography- style={{ padding: 15, color: theme.palette.text.secondary }}- >- {t('core:noFileFolderFound')}- </Typography>- {!AppConfig.isCordova && (- <Typography style={{ color: theme.palette.text.secondary }}>- {t('core:dragAndDropToImport')}- </Typography>- )}- </div>- )}- {files.length < 1 && dirs.length >= 1 && !showDirectories && (- <div style={{ textAlign: 'center' }}>- {!showDescription &&- directoryMeta &&- directoryMeta.description && (- <div- style={{- position: 'relative',- margin: 'auto',- maxWidth: 150,- }}- >- <EntryIcon isFile={false} />- </div>- )}- <Typography- style={{ padding: 15, color: theme.palette.text.secondary }}- >- {t('core:noFileButFoldersFound')}- </Typography>- {!AppConfig.isCordova && (- <Typography style={{ color: theme.palette.text.secondary }}>- {t('core:dragAndDropToImport')}- </Typography>- )}- </div>- )}+ {pageFiles.length < 1 &&+ renderEmptyState(t('core:noFileFolderFound'))}+ {files.length < 1 &&+ dirs.length >= 1 &&+ !showDirectories &&+ renderEmptyState(t('core:noFileButFoldersFound'))}</GridCellsContainer>{showPagination && (<TooltipTS title={folderSummary}><Pagination- style={{+ sx={{left: 15,bottom: -35,zIndex: 1100,@@ -490,8 +437,8 @@ function GridPagination(props: Props) {backgroundColor: theme.palette.background.default,opacity: 0.97,border: '1px solid lightgray',- borderRadius: 5,- padding: 3,+ borderRadius: '5px',+ padding: '3px',}}count={paginationCount}page={page}@@ -500,9 +447,9 @@ function GridPagination(props: Props) {</TooltipTS>)}{!showDetails && !showPagination && pageFiles.length > 0 && (- <div style={{ padding: 15, bottom: 10 }}>+ <Box sx={{ padding: '15px', bottom: '10px' }}><Typography- style={{+ sx={{fontSize: '0.8rem',filter: `drop-shadow(0px 0px 4px ${theme.palette.background.default})`,color: theme.palette.text.primary,@@ -510,11 +457,11 @@ function GridPagination(props: Props) {>{folderSummary}</Typography>- </div>+ </Box>)}</SelectionArea>- </div>- </div>+ </Box>+ </Box>);}diff --git a/src/renderer/perspectives/list/components/MainContainer.tsx b/src/renderer/perspectives/list/components/MainContainer.tsxindex c617a8ce8..228a9f012 100644--- a/src/renderer/perspectives/list/components/MainContainer.tsx+++ b/src/renderer/perspectives/list/components/MainContainer.tsx@@ -26,11 +26,13 @@ import { TabNames } from '-/hooks/EntryPropsTabsContextProvider';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useIOActionsContext } from '-/hooks/useIOActionsContext';+import { useNotificationContext } from '-/hooks/useNotificationContext';import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';import { usePerspectiveSettingsContext } from '-/hooks/usePerspectiveSettingsContext';import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';import { fileOperationsEnabled } from '-/perspectives/common/main-container';+import { useReloadOnFocus } from '-/perspectives/common/useReloadOnFocus';import GridOptionsMenu from '-/perspectives/grid/components/GridOptionsMenu';import GridPagination from '-/perspectives/grid/components/GridPagination';import GridSettingsDialog from '-/perspectives/grid/components/GridSettingsDialog';@@ -43,13 +45,12 @@ import { getDesktopMode, getKeyBindingObject } from '-/reducers/settings';import { openURLExternally } from '-/services/utils-io';import { TS } from '-/tagspaces.namespace';import useFirstRender from '-/utils/useFirstRender';+import { Box } from '@mui/material';import Links from 'assets/links';-import React, { useCallback, useEffect, useRef, useState } from 'react';+import React, { useEffect, useRef, useState } from 'react';import { GlobalHotKeys } from 'react-hotkeys';import { useSelector } from 'react-redux';import { ListCellsStyleContextProvider } from '../hooks/ListCellsStyleProvider';-import { useReloadOnFocus } from '-/perspectives/common/useReloadOnFocus';-import { useNotificationContext } from '-/hooks/useNotificationContext';interface Props {}@@ -321,8 +322,8 @@ function ListPerspective(props: Props) {};return (- <div- style={{+ <Box+ sx={{height: '100%', // 'calc(100% - 47px)'}}data-tid="listPerspectiveContainer"@@ -395,7 +396,8 @@ function ListPerspective(props: Props) {openSettings={openSettings}/>)}- </div>+ </Box>);}+export default ListPerspective;diff --git a/src/renderer/perspectives/list/components/RowCell.tsx b/src/renderer/perspectives/list/components/RowCell.tsxindex be22dfcba..77a66f43b 100644--- a/src/renderer/perspectives/list/components/RowCell.tsx+++ b/src/renderer/perspectives/list/components/RowCell.tsx@@ -57,7 +57,7 @@ import {extractTagsAsObjects,extractTitle,} from '@tagspaces/tagspaces-common/paths';-import { useMemo } from 'react';+import React, { useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';import { useSelector } from 'react-redux';import { defaultSettings } from '../index';@@ -80,19 +80,20 @@ interface Props {}export function calculateEntryHeight(entrySize: TS.EntrySizes) {- let entryHeight = 200;- if (entrySize === 'tiny') {- entryHeight = 35;- } else if (entrySize === 'small') {- entryHeight = 55;- } else if (entrySize === 'normal') {- entryHeight = 75;- } else if (entrySize === 'big') {- entryHeight = 95;- } else if (entrySize === 'huge') {- entryHeight = 115;+ switch (entrySize) {+ case 'tiny':+ return 35;+ case 'small':+ return 55;+ case 'normal':+ return 75;+ case 'big':+ return 95;+ case 'huge':+ return 115;+ default:+ return 200;}- return entryHeight;}function RowCell(props: Props) {@@ -118,87 +119,76 @@ function RowCell(props: Props) {const supportedFileTypes = useSelector(getSupportedFileTypes);const reorderTags: boolean = useSelector(isReorderTags);const tagDelimiter: string = useSelector(getTagDelimiter);- //const rowCellLocation = findLocation(fsEntry.locationID);-- // You can use the dispatch function to dispatch actions- const handleEditTag = (path: string, tag: TS.Tag, newTagTitle?: string) => {- editTagForEntry(path, tag, newTagTitle);- };const handleAddTag = (tag: TS.Tag, parentTagGroupUuid: TS.Uuid) => {addTag([tag], parentTagGroupUuid);};- // remove isNewFile on Cell click it will open file in editMode- /*const fSystemEntry: TS.FileSystemEntry = (({ isNewFile, ...o }) => o)(- fsEntry,- );*/-- const entryTitle = extractTitle(- fsEntry.name,- !fsEntry.isFile,- currentLocation?.getDirSeparator(),+ const entryTitle = useMemo(+ () =>+ extractTitle(+ fsEntry.name,+ !fsEntry.isFile,+ currentLocation?.getDirSeparator(),+ ),+ [fsEntry.name, fsEntry.isFile, currentLocation],);- let description;- if (showEntriesDescription) {- description = fsEntry.meta?.description;- if (- description &&- description.length > defaultSettings.maxDescriptionPreviewLength- ) {- description = getDescriptionPreview(- description,+ const description = useMemo(() => {+ if (!showEntriesDescription) return '';+ let desc = fsEntry.meta?.description;+ if (desc && desc.length > defaultSettings.maxDescriptionPreviewLength) {+ desc = getDescriptionPreview(+ desc,defaultSettings.maxDescriptionPreviewLength,);}+ return desc && fsEntry.isFile ? ` | ${desc}` : desc || '';+ }, [showEntriesDescription, fsEntry.meta?.description, fsEntry.isFile]);- if (description && fsEntry.isFile) {- description = ' | ' + description;- }- }-- const fileSystemEntryColor = findColorForEntry(fsEntry, supportedFileTypes);- const fileSystemEntryBgColor = findBackgroundColorForFolder(fsEntry);+ const fileSystemEntryColor = useMemo(+ () => findColorForEntry(fsEntry, supportedFileTypes),+ [fsEntry, supportedFileTypes],+ );+ const fileSystemEntryBgColor = useMemo(+ () => findBackgroundColorForFolder(fsEntry),+ [fsEntry],+ );- let fileNameTags = [];- if (fsEntry.isFile) {- fileNameTags = extractTagsAsObjects(- fsEntry.name,- tagDelimiter,- currentLocation?.getDirSeparator(),- );- }+ const fileNameTags = useMemo(+ () =>+ fsEntry.isFile+ ? extractTagsAsObjects(+ fsEntry.name,+ tagDelimiter,+ currentLocation?.getDirSeparator(),+ )+ : [],+ [fsEntry.isFile, fsEntry.name, tagDelimiter, currentLocation],+ );- const fileSystemEntryTags =- fsEntry.meta && fsEntry.meta.tags ? fsEntry.meta.tags : [];- const sideCarTagsTitles = fileSystemEntryTags.map((tag) => tag.title);- const entryTags = [- ...fileSystemEntryTags,- ...fileNameTags.filter((tag) => !sideCarTagsTitles.includes(tag.title)),- ];+ const fileSystemEntryTags: TS.Tag[] = fsEntry.meta?.tags ?? [];+ const sideCarTagsTitles = useMemo(+ () => fileSystemEntryTags.map((tag) => tag.title),+ [fileSystemEntryTags],+ );+ const entryTags = useMemo(+ () => [+ ...fileSystemEntryTags,+ ...fileNameTags.filter((tag) => !sideCarTagsTitles.includes(tag.title)),+ ],+ [fileSystemEntryTags, fileNameTags, sideCarTagsTitles],+ );const entrySizeFormatted = fsEntry.isFile- ? formatFileSize(fsEntry.size) + ' | '+ ? `${formatFileSize(fsEntry.size)} | `: '';const entryLMDTFormatted =- fsEntry.isFile && fsEntry.lmdt && formatDateTime(fsEntry.lmdt, true);+ fsEntry.isFile && fsEntry.lmdt ? formatDateTime(fsEntry.lmdt, true) : '';- let tagTitles = '';- if (entryTags) {- entryTags.map((tag) => {- tagTitles += tag.title + ', ';- return true;- });- }- tagTitles = tagTitles.substring(0, tagTitles.length - 2);const tagPlaceholder = <TagsPreview tags={entryTags} />;- function urlGetDelim(url) {- return url.indexOf('?') > 0 ? '&' : '?';- }-const entryPath = fsEntry.path;const renderTags = useMemo(() => {@@ -220,60 +210,107 @@ function RowCell(props: Props) {addTag={handleAddTag}handleTagMenu={handleTagMenu}selectedEntries={selectedEntries}- editTagForEntry={handleEditTag}+ editTagForEntry={editTagForEntry}reorderTags={reorderTags}/>);-if (tag.type === 'sidecar') {sideCarLength = index + 1;}return tagContainer;});- }, [entryTags, currentLocation?.isReadOnly, reorderTags, entryPath]);+ }, [+ entryTags,+ currentLocation?.isReadOnly,+ entryPath,+ fsEntry,+ handleTagMenu,+ addTag,+ selectedEntries,+ editTagForEntry,+ reorderTags,+ ]);const entryHeight = calculateEntryHeight(entrySize);- const isSmall = entrySize === 'tiny'; // || entrySize === 'small';+ const isSmall = entrySize === 'tiny';- let entryBackgroundColor = fileSystemEntryBgColor;- if (entryBackgroundColor === 'transparent') {- entryBackgroundColor = theme.palette.background.default;- }+ const entryBackgroundColor =+ fileSystemEntryBgColor === 'transparent'+ ? theme.palette.background.default+ : fileSystemEntryBgColor;const backgroundColor = selected? theme.palette.primary.light: entryBackgroundColor;+ const handleBadgeClick = useCallback(+ (e: React.MouseEvent) => {+ e.stopPropagation();+ if (selectionMode) {+ selectEntry(fsEntry, !selected);+ } else {+ selectEntry(fsEntry);+ }+ },+ [selectionMode, selectEntry, fsEntry, selected],+ );++ const handlePaperClick = useCallback(+ (event: React.MouseEvent) => {+ event.stopPropagation();+ AppConfig.isCordovaiOS+ ? handleGridCellDblClick(event, fsEntry)+ : handleGridCellClick(event, fsEntry);+ },+ [handleGridCellClick, handleGridCellDblClick, fsEntry],+ );++ const handlePaperDoubleClick = useCallback(+ (event: React.MouseEvent) => {+ handleGridCellDblClick(event, fsEntry);+ },+ [handleGridCellDblClick, fsEntry],+ );++ const handlePaperContextMenu = useCallback(+ (event: React.MouseEvent) => {+ handleGridContextMenu(event, fsEntry);+ },+ [handleGridContextMenu, fsEntry],+ );++ const handlePaperDrag = useCallback(+ (event: React.DragEvent) => {+ handleGridCellClick(event, fsEntry);+ },+ [handleGridCellClick, fsEntry],+ );++ function urlGetDelim(url: string) {+ return url.indexOf('?') > 0 ? '&' : '?';+ }+return (<Paperdata-entry-id={fsEntry.uuid}- style={{+ sx={{boxShadow: 'none',borderRadius: 0,borderLeft: '1px solid transparent',borderRight: '1px solid transparent',borderTop: '1px solid transparent',- borderBottom: '1px solid ' + theme.palette.divider,+ borderBottom: `1px solid ${theme.palette.divider}`,background: 'transparent',margin: 0,- paddingBottom: 5,- marginLeft: 5,+ paddingBottom: '5px',+ marginLeft: '5px',minHeight: entryHeight,- marginBottom: isLast ? 40 : 'auto',- }}- onContextMenu={(event) => handleGridContextMenu(event, fsEntry)}- onDoubleClick={(event) => {- handleGridCellDblClick(event, fsEntry);- }}- onClick={(event) => {- event.stopPropagation();- AppConfig.isCordovaiOS // TODO DoubleClick not fired in Cordova IOS- ? handleGridCellDblClick(event, fsEntry)- : handleGridCellClick(event, fsEntry);- }}- onDrag={(event) => {- handleGridCellClick(event, fsEntry);+ marginBottom: isLast ? '40px' : 'auto',}}+ onContextMenu={handlePaperContextMenu}+ onDoubleClick={handlePaperDoubleClick}+ onClick={handlePaperClick}+ onDrag={handlePaperDrag}><Gridcontainer@@ -282,16 +319,16 @@ function RowCell(props: Props) {borderRadius: AppConfig.defaultCSSRadius,backgroundColor,'&:hover': {- backgroundColor: theme.palette.divider + ' !important',+ backgroundColor: `${theme.palette.divider} !important`,},}}><Grid- style={{+ sx={{minHeight: entryHeight,minWidth: 50,height: 30,- padding: 3,+ padding: '3px',textAlign: 'left',display: 'flex',alignSelf: 'center',@@ -299,23 +336,12 @@ function RowCell(props: Props) {><Tooltip title={i18n.t('clickToSelect') + ': ' + fsEntry.name}><FileExtBadge- style={{+ sx={{backgroundColor: fileSystemEntryColor,}}- noWrap={true}+ noWrapvariant="button"- onClick={(e) => {- e.stopPropagation();- if (selectionMode) {- if (selected) {- selectEntry(fsEntry, false);- } else {- selectEntry(fsEntry);- }- } else {- selectEntry(fsEntry);- }- }}+ onClick={handleBadgeClick}>{selectionMode ? (selected ? (@@ -333,19 +359,19 @@ function RowCell(props: Props) {</Grid>{isSmall ? (<Grid- style={{+ sx={{display: 'flex',width: '100%',- marginLeft: 5,+ marginLeft: '5px',}}><Typographyvariant="body2"- style={{+ sx={{overflowX: 'hidden',textWrap: 'nowrap',alignSelf: 'center',- marginRight: 5,+ marginRight: '5px',}}title={fsEntry.name +@@ -354,13 +380,13 @@ function RowCell(props: Props) {formatDateTime(fsEntry.lmdt, true)}>- <>{entryTitle}</>+ {entryTitle} - {showTags && entryTags ? renderTags : tagPlaceholder}+ {showTags && entryTags.length > 0 ? renderTags : tagPlaceholder}</Typography></Grid>) : (- <Grid sx={{ alignSelf: 'center', width: '100%', marginLeft: 5 }}>+ <Grid sx={{ alignSelf: 'center', width: '100%', marginLeft: '5px' }}><Typographyvariant="body1"title={fsEntry.path}@@ -370,9 +396,7 @@ function RowCell(props: Props) {</Typography><Typographydata-tid="gridCellDescription"- sx={{- color: 'gray',- }}+ sx={{ color: 'gray' }}variant="body2"><Tooltip title={fsEntry.size + ' ' + t('core:sizeInBytes')}>@@ -389,12 +413,12 @@ function RowCell(props: Props) {</Tooltip><span>{description}</span></Typography>- {showTags && entryTags ? renderTags : tagPlaceholder}+ {showTags && entryTags.length > 0 ? renderTags : tagPlaceholder}</Grid>)}- {fsEntry.meta && fsEntry.meta.thumbPath && (+ {fsEntry.meta?.thumbPath && (<Grid- style={{+ sx={{display: 'flex',width: entryHeight,alignItems: 'center',@@ -403,17 +427,16 @@ function RowCell(props: Props) {<imgalt="thumbnail"src={- fsEntry.meta?.thumbPath +- (fsEntry.meta &&- fsEntry.meta.thumbPath &&- !currentLocation.haveObjectStoreSupport() &&+ fsEntry.meta.thumbPath ++ (!currentLocation.haveObjectStoreSupport() &&!currentLocation.haveWebDavSupport()- ? urlGetDelim(fsEntry.meta?.thumbPath) ++ ? urlGetDelim(fsEntry.meta.thumbPath) +fsEntry.meta.lastUpdated: '')}- // @ts-ignore- onError={(i) => (i.target.style.display = 'none')}+ onError={(e) => {+ (e.target as HTMLImageElement).style.display = 'none';+ }}loading="lazy"style={{backgroundRepeat: 'no-repeat',@@ -435,7 +458,7 @@ function RowCell(props: Props) {><TsIconButtonaria-label="entry context menu"- onClick={(event) => handleGridContextMenu(event, fsEntry)}+ onClick={handlePaperContextMenu}><MoreMenuIcon /></TsIconButton>diff --git a/src/renderer/reducers/locations.ts b/src/renderer/reducers/locations.tsindex 0dd9f99d1..465d141ee 100644--- a/src/renderer/reducers/locations.ts+++ b/src/renderer/reducers/locations.ts@@ -16,10 +16,10 @@**/-import { immutablySwapItems } from '@tagspaces/tagspaces-common/misc';-import { CommonLocation } from '-/utils/CommonLocation';-import { TS } from '-/tagspaces.namespace';import { toTsLocation } from '-/services/utils-io';+import { TS } from '-/tagspaces.namespace';+import { CommonLocation } from '-/utils/CommonLocation';+import { immutablySwapItems } from '@tagspaces/tagspaces-common/misc';export const types = {ADD_LOCATION: 'APP/ADD_LOCATION',@@ -177,23 +177,3 @@ export const getDefaultLocationId = (state: any): string | undefined => {let foundLocation = state.locations.find((location) => location.isDefault);return foundLocation ? foundLocation.uuid : undefined;};-// state.locations.map((l) => new CommonLocation(l));-/*export const getLocation = (- state: any,- locationId: string,-): CommonLocation | null =>- state.locations.find((location) => location.uuid === locationId);-export const getLocationByPath = (- state: any,- path: string,-): CommonLocation | null =>- state.locations.find((location) => location.path === path);-export const getFirstRWLocation = (state: any): CommonLocation | undefined => {- let foundLocation = state.locations.find(- (location) => location.isDefault && !location.isReadOnly,- );- if (!foundLocation) {- foundLocation = state.locations.find((location) => !location.isReadOnly);- }- return foundLocation;-}; */diff --git a/src/renderer/reducers/searches.ts b/src/renderer/reducers/searches.tsindex 07b088d23..d41045018 100644--- a/src/renderer/reducers/searches.ts+++ b/src/renderer/reducers/searches.ts@@ -16,8 +16,8 @@**/-import { immutablySwapItems } from '@tagspaces/tagspaces-common/misc';import { TS } from '-/tagspaces.namespace';+import { immutablySwapItems } from '@tagspaces/tagspaces-common/misc';export const initialState = [];@@ -99,41 +99,6 @@ export default (state: Array<TS.SearchQuery> = initialState, action: any) => {}};-/*export const actions = {- addSearch: (search: TS.SearchQuery) => ({- type: types.ADD_SEARCH,- search,- }),- addSearches:- (arrSearches: Array<TS.SearchQuery>, override = true) =>- (dispatch: (actions: Object) => void, getState: () => any) => {- arrSearches.forEach((newSearch: TS.SearchQuery) => {- const { searches } = getState();- const searchExist: boolean = searches.some(- (location) => location.uuid === newSearch.uuid,- );- if (!searchExist) {- dispatch(actions.addSearch(newSearch));- } else if (override) {- dispatch(actions.editSearch(newSearch));- }- });- },- moveSearchUp: (uuid: string) => ({ type: types.MOVE_UP_SEARCH, uuid }),- moveSearchDown: (uuid: string) => ({- type: types.MOVE_DOWN_SEARCH,- uuid,- }),- editSearch: (search: TS.SearchQuery) => ({- type: types.EDIT_SEARCH,- search,- }),- removeSearch: (uuid: string) => ({- type: types.REMOVE_SEARCH,- uuid,- }),-};*/-// Selectorsexport const getSearches = (state: any): Array<TS.SearchQuery> =>state.searches;diff --git a/src/renderer/reducers/settings-default.ts b/src/renderer/reducers/settings-default.tsindex fd75c91b7..90ca07498 100644--- a/src/renderer/reducers/settings-default.ts+++ b/src/renderer/reducers/settings-default.ts@@ -103,7 +103,7 @@ export default {tagTextColor: 'white',tagBackgroundColor: '#61DD61',currentTheme: 'light',- currentLightTheme: 'legacy',+ currentRegularTheme: 'legacy',currentDarkTheme: 'darklegacy',geoTaggingFormat: 'pluscodes',defaultPerspective: PerspectiveIDs.GRID,diff --git a/tests/e2e/clearstorage.helpers.js b/tests/e2e/clearstorage.helpers.jsindex 24896cd95..d9cd2b745 100644--- a/tests/e2e/clearstorage.helpers.js+++ b/tests/e2e/clearstorage.helpers.js@@ -22,26 +22,4 @@ export async function clearStorage() {});});}- /*if (global.session) {- //await global.client.evaluate(() => window.localStorage.clear());- //await global.client.evaluate(() => window.sessionStorage.clear());- /!*await global.client.evaluate(() => {- window.history.pushState('', document.title, window.location.pathname);- window.localStorage.clear();- });*!/- await global.client.context().storageState({});- await global.session.send('Storage.clearDataForOrigin', {- origin: '*', //'app://',- storageTypes: 'all'- // 'appcache,cookies,filesystem,indexeddb,localstorage,serviceworkers,websql'- }); //, { origin: 'your-electron-app-url' });- await global.client.reload();- } else {*/- /*await clickOn('[data-tid=settings]', { timeout: 20000 });- await clickOn('[data-tid=advancedSettingsDialogTID]');- await global.client.waitForTimeout(500);- await clickOn('[data-tid=resetSettingsTID]');- await global.client.waitForTimeout(500);- await clickOn('[data-tid=confirmResetSettingsDialogTID]');*/- //}}diff --git a/tests/e2e/folder.pw.e2e.js b/tests/e2e/folder.pw.e2e.jsindex 893350eed..1394b0ca2 100644--- a/tests/e2e/folder.pw.e2e.js+++ b/tests/e2e/folder.pw.e2e.js@@ -1,40 +1,39 @@/** Copyright (c) 2016-present - TagSpaces GmbH. All rights reserved.*/-import { test, expect } from './fixtures';-import {- defaultLocationName,- createPwMinioLocation,- createPwLocation,- createS3Location,- deleteFileFromMenu,-} from './location.helpers';+import { AddRemovePropertiesTags } from './file.properties.helpers';+import { expect, test } from './fixtures';import {- reloadDirectory,+ clickOn,createNewDirectory,deleteDirectory,- clickOn,expectElementExist,- takeScreenshot,- selectorFile,- setInputKeys,- getGridFileSelector,+ getAttribute,getElementScreenshot,+ getGridFileSelector,openFolder,- waitUntilChanged,- getAttribute,+ reloadDirectory,+ selectorFile,+ setInputKeys,+ waitUntilChanged} from './general.helpers';-import { openContextEntryMenu, renameFolder } from './test-utils';import {- createLocalFile,createFileS3,+ createLocalFile,startTestingApp,stopApp,} from './hook';-import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';-import { emptyFolderName } from './search.helpers';-import { AddRemovePropertiesTags } from './file.properties.helpers';+import {+ createPwLocation,+ createPwMinioLocation,+ createS3Location,+ defaultLocationName,+ deleteFileFromMenu,+} from './location.helpers';import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';+import { emptyFolderName } from './search.helpers';+import { openContextEntryMenu, renameFolder } from './test-utils';+import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';test.beforeAll(async ({ isWeb, isS3, webServerPort }, testInfo) => {if (isS3) {diff --git a/tests/e2e/folderprops.pw.e2e.js b/tests/e2e/folderprops.pw.e2e.jsindex 7b1d25991..4495996b2 100644--- a/tests/e2e/folderprops.pw.e2e.js+++ b/tests/e2e/folderprops.pw.e2e.js@@ -1,43 +1,37 @@/** Copyright (c) 2016-present - TagSpaces GmbH. All rights reserved.*/-import { test, expect } from './fixtures';import {- defaultLocationName,- createPwMinioLocation,- createPwLocation,- createS3Location,-} from './location.helpers';+ AddRemovePropertiesTags,+ getPropertiesFileName,+ getPropertiesTags,+} from './file.properties.helpers';+import { expect, test } from './fixtures';import {+ addDescription,+ checkSettings,clickOn,- expectElementExist,- getGridFileSelector,- setInputValue,+ createLocation,createNewDirectory,dnd,+ expectElementExist,getAttribute,getElementScreenshot,- checkSettings,+ getGridFileSelector,openFolder,- waitUntilChanged,openFolderProp,- createLocation,- addDescription,+ setInputValue,+ waitUntilChanged,} from './general.helpers';-import { openContextEntryMenu } from './test-utils';import {- createLocalFile,createFileS3,+ createLocalFile,startTestingApp,stopApp,testDataRefresh,} from './hook';+import { openContextEntryMenu } from './test-utils';import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';-import {- AddRemovePropertiesTags,- getPropertiesFileName,- getPropertiesTags,-} from './file.properties.helpers';/*test.beforeAll(async ({ isWeb, isS3, webServerPort }, testInfo) => {if (isS3) {@@ -342,23 +336,24 @@ test.describe('TST02 - Folder properties', () => {const initScreenshot = await getElementScreenshot('[data-tid=perspectiveGridFileTable]',);- const initStyle = await getAttribute(targetSelector, 'style');+ const initStyle = await getAttribute(targetSelector, 'class');+ console.log('Init Style:', initStyle);await clickOn('[data-tid=changeBackgroundColorTID]');await clickOn('[data-tid=backgroundTID1]');await waitUntilChanged(targetSelector,initStyle, //'height: 100%; background: rgba(0, 0, 0, 0.267);',- 'style',+ 'class',15000,);const withBgnColorScreenshot = await getElementScreenshot('[data-tid=perspectiveGridFileTable]',);- const bgStyle = await getAttribute(targetSelector, 'style');+ const bgStyle = await getAttribute(targetSelector, 'class');expect(initScreenshot).not.toBe(withBgnColorScreenshot);-+ console.log('BG Style:', bgStyle);// remove backgroundawait clickOn('[data-tid=backgroundClearTID]');await clickOn('[data-tid=confirmConfirmResetColorDialog]');@@ -366,7 +361,7 @@ test.describe('TST02 - Folder properties', () => {await waitUntilChanged(targetSelector,bgStyle, //'height: 100%; background: transparent;',- 'style',+ 'class',15000,);diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.jsindex 7a43f85f2..6cf0e2dd9 100644--- a/tests/e2e/general.helpers.js+++ b/tests/e2e/general.helpers.js@@ -424,9 +424,8 @@ export async function expectAllFileSelected(isSelected = true) {for (let i = 0; i < filesList.length; i++) {let file = await filesList[i].$('div');file = await file.$('div');- const style = await file.getAttribute('style');- const selected =- style.indexOf('rgb(29') !== -1 && style.indexOf('transparent') === -1;+ const selectedAttr = await file.getAttribute('data-selected');+ const selected = selectedAttr === 'true';expect(selected).toBe(isSelected);}}@@ -445,10 +444,8 @@ export async function expectElementSelected(const startTime = Date.now();while (Date.now() - startTime < timeout) {- const finalStyle = await item.evaluate((el) => el.getAttribute('style'));- const selected =- finalStyle.includes('rgb(29') && !finalStyle.includes('transparent');-+ const selectionAttribute = await item.evaluate(el => el.getAttribute('data-selected'));+ const selected = selectionAttribute === 'true';if (selected === isSelected) {expect(selected).toBe(isSelected); // Pass the test if the condition is metreturn;diff --git a/tests/e2e/hook.js b/tests/e2e/hook.jsindex c0658ec7e..d33f2d027 100644--- a/tests/e2e/hook.js+++ b/tests/e2e/hook.js@@ -1,13 +1,16 @@/* Copyright (c) 2016-present - TagSpaces GmbH. All rights reserved. */-import pathLib from 'path';import fse from 'fs-extra';import os from 'os';+import pathLib from 'path';import {createDir,refreshS3testData,uploadFile,} from '../s3rver/S3DataRefresh';+const windowWidth = 1400;+const windowHeight = 800;+// Spectron API https://github.com/electron/spectron// Webdriver.io http://webdriver.io/api.html@@ -192,7 +195,7 @@ export async function startTestingApp('--no-sandbox','--disable-dev-shm-usage','--disable-extensions',- '--window-size=1920,1080',+ '--window-size=' + windowWidth + ',' + windowHeight,];if (process.env.HEADLESS_MODE === 'true') {chromeDriverArgs.push('--headless');@@ -206,7 +209,7 @@ export async function startTestingApp(}); //browserglobal.context = await global.app.newContext({- viewport: { width: 1920, height: 1080 },+ viewport: { width: windowWidth, height: windowHeight },});global.client = await global.context.newPage(); //page@@ -283,7 +286,7 @@ export async function startTestingApp(global.client = await global.app.firstWindow();// global.session = await global.client.context().newCDPSession(global.client);// Setting the viewport size helps keep test environments consistent.- await global.client.setViewportSize({ width: 1920, height: 1080 }); //{width: 1200,height: 800} ({ width: 800, height: 600 });+ await global.client.setViewportSize({ width: windowWidth, height: windowHeight }); //{width: 1200,height: 800} ({ width: 800, height: 600 });await global.client.waitForLoadState('load'); //'domcontentloaded'); //'networkidle');if (process.env.SHOW_CONSOLE) {diff --git a/tests/e2e/perspective-grid-right-button.pw.e2e.js b/tests/e2e/perspective-grid-right-button.pw.e2e.jsindex 213d1a26b..0851d20b0 100644--- a/tests/e2e/perspective-grid-right-button.pw.e2e.js+++ b/tests/e2e/perspective-grid-right-button.pw.e2e.js@@ -2,42 +2,41 @@* Copyright (c) 2016-present - TagSpaces GmbH. All rights reserved.*/-import { test, expect } from './fixtures';import { generateFileName } from '@tagspaces/tagspaces-common/paths';-import {- defaultLocationName,- renameFileFromMenu,- deleteFileFromMenu,- createPwMinioLocation,- createPwLocation,- createS3Location,-} from './location.helpers';import AppConfig from '../../src/renderer/AppConfig';-import { searchEngine } from './search.helpers';-import { openContextEntryMenu, toContainTID } from './test-utils';+import { expect, test } from './fixtures';import {clickOn,createNewDirectory,createTxtFile,expectElementExist,+ expectMetaFilesExist,+ frameLocator,getGridFileSelector,+ openFile,+ openFolder,reloadDirectory,removeTagFromTagMenu,selectorFile,selectorFolder,selectRowFiles,- setInputKeys,setGridOptions,- showFilesWithTag,- frameLocator,- takeScreenshot,- expectMetaFilesExist,+ setInputKeys,setSettings,- openFolder,- openFile,+ showFilesWithTag} from './general.helpers';-import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';import { startTestingApp, stopApp, testDataRefresh } from './hook';+import {+ createPwLocation,+ createPwMinioLocation,+ createS3Location,+ defaultLocationName,+ deleteFileFromMenu,+ renameFileFromMenu,+} from './location.helpers';+import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';+import { searchEngine } from './search.helpers';+import { openContextEntryMenu, toContainTID } from './test-utils';import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';const testTagName = 'testTag'; // TODO fix camelCase tag name@@ -482,21 +481,6 @@ test.describe('TST50** - Right button on a file', () => {});test('TST5039 - Changing the Perspective View [web,minio,s3,electron]', async () => {- // await isDisplayed('[data-tid=perspectiveGridFileTable]', true);- // await global.client.screenshot({ path: 'screenshotTST5039.png' });-- // const grid = await global.client.waitForSelector(- // '[data-tid=perspectiveGridFileTable]'- // );- // let gridStyle = await grid.getAttribute('style');- // expect(gridStyle).toContain(- // 'margin-top: 53px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));'- // );- // await clickOn('[data-tid=openListPerspective]');- // // check perspective view- // gridStyle = await grid.getAttribute('style');- // expect(gridStyle).toContain('grid-template-columns: none;');-await expectElementExist(// '[data-tid=' + gridDefaultSettings.testID + ']','[data-tid=gridPerspectiveContainer]',diff --git a/tests/e2e/perspective-grid.pw.e2e.js b/tests/e2e/perspective-grid.pw.e2e.jsindex 705b1f03c..d2747213f 100644--- a/tests/e2e/perspective-grid.pw.e2e.js+++ b/tests/e2e/perspective-grid.pw.e2e.js@@ -1,13 +1,11 @@/** Copyright (c) 2016-present - TagSpaces GmbH. All rights reserved.*/-import { test, expect } from './fixtures';import {- defaultLocationName,- createPwMinioLocation,- createPwLocation,- createS3Location,-} from './location.helpers';+ AddRemovePropertiesTags,+ getPropertiesFileName,+} from './file.properties.helpers';+import { expect, test } from './fixtures';import {clickOn,expectAllFileSelected,@@ -18,17 +16,17 @@ import {openFile,selectAllFiles,selectRowFiles,- setSettings,- takeScreenshot,+ setSettings} from './general.helpers';-import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';+import { startTestingApp, stopApp } from './hook';import {- AddRemovePropertiesTags,- getPropertiesFileName,-} from './file.properties.helpers';-import { createLocalFile, startTestingApp, stopApp } from './hook';+ createPwLocation,+ createPwMinioLocation,+ createS3Location,+ defaultLocationName,+} from './location.helpers';+import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';-import { openContextEntryMenu } from './test-utils';test.beforeAll(async ({ isWeb, isS3, webServerPort }, testInfo) => {if (isS3) {@@ -244,8 +242,8 @@ test.describe('TST50 - Perspective Grid', () => {test.skip('TST5015 - Tag file drag&drop in perspective [manual]', async () => {});test('TST5048 - prev/next button [web,minio,s3,electron]', async () => {- const fileName = 'sample.svg';- const nextFileName = 'sample.tga';+ const fileName = 'sample.avif';+ const nextFileName = 'sample.bmp';await clickOn(getGridFileSelector(fileName));//await expectElementExist('[data-tid=fileContainerNextFile]', true, 5000);await clickOn('[data-tid=fileContainerNextFile]');@@ -253,6 +251,7 @@ test.describe('TST50 - Perspective Grid', () => {await clickOn('[data-tid=fileContainerPrevFile]');await expectElementSelected(fileName, true);});+/* test('TST51** - Show/Hide directories in perspective view', async () => { //TODOawait global.client.waitForVisible('[data-tid=gridPerspectiveToggleShowDirectories]'diff --git a/tests/e2e/search.pw.e2e.js b/tests/e2e/search.pw.e2e.jsindex a00505aa8..01a349a0d 100644--- a/tests/e2e/search.pw.e2e.js+++ b/tests/e2e/search.pw.e2e.js@@ -1,4 +1,6 @@-import { test, expect } from './fixtures';+import { dataTidFormat } from '../../src/renderer/services/test';+import { AddRemovePropertiesTags } from './file.properties.helpers';+import { expect, test } from './fixtures';import {clickOn,expectElementExist,@@ -10,8 +12,8 @@ import {setSettings,} from './general.helpers';import {- createLocalFile,createFileS3,+ createLocalFile,startTestingApp,stopApp,} from './hook';@@ -23,19 +25,17 @@ import {createS3Location,defaultLocationName,} from './location.helpers';+import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';import {+ addRemoveTagsInSearchResults,+ addSearchCommand,+ createSavedSearch,emptyFolderName,searchEngine,testFilename,- addRemoveTagsInSearchResults,- createSavedSearch,- addSearchCommand,} from './search.helpers';-import { clearDataStorage } from './welcome.helpers';import { openContextEntryMenu } from './test-utils';-import { dataTidFormat } from '../../src/renderer/services/test';-import { AddRemoveTagsToSelectedFiles } from './perspective-grid.helpers';-import { AddRemovePropertiesTags } from './file.properties.helpers';+import { clearDataStorage } from './welcome.helpers';test.beforeAll(async ({ isWeb, isS3, webServerPort, testDataDir }, testInfo) => {@@ -150,16 +150,16 @@ test.describe('TST06 - Test Search in file structure:', () => {}) => {if (!isWin || !isWeb) {//todo on web windows only test not work- await global.client.waitForSelector('img[alt="thumbnail image"]', {+ await global.client.waitForSelector('img[data-tid="imageThumbnailTID"]', {visible: true,});const searchQuery = 'sample_exif.jpg'; //'jpg';await addSearchCommand(searchQuery, true);await expectElementExist('[data-tid=allFilesCount1]', true, 5000);- await global.client.waitForSelector('img[alt="thumbnail image"]', {+ await global.client.waitForSelector('img[data-tid="imageThumbnailTID"]', {visible: true,});- const imageLocator = global.client.locator('img[alt="thumbnail image"]');+ const imageLocator = global.client.locator('img[data-tid="imageThumbnailTID"]');const imageCount = await imageLocator.count();expect(imageCount).toBeGreaterThan(0);const images = await imageLocator; //.elements();diff --git a/tests/e2e/tag.pw.e2e.js b/tests/e2e/tag.pw.e2e.jsindex 80896f582..9bfa1f436 100644--- a/tests/e2e/tag.pw.e2e.js+++ b/tests/e2e/tag.pw.e2e.js@@ -1,6 +1,7 @@/* Copyright (c) 2016-present - TagSpaces GmbH. All rights reserved. */-import { test, expect } from './fixtures';import { formatDateTime4Tag } from '@tagspaces/tagspaces-common/misc';+import { dataTidFormat } from '../../src/renderer/services/test';+import { expect, test } from './fixtures';import {checkSettings,clickOn,@@ -12,12 +13,11 @@ import {setInputValue,} from './general.helpers';import {- createLocalFile,createFileS3,+ createLocalFile,startTestingApp,stopApp,} from './hook';-import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';import {createPwLocation,createPwMinioLocation,@@ -34,7 +34,7 @@ import {testGroup,testTagName,} from './tag.helpers';-import { dataTidFormat } from '../../src/renderer/services/test';+import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';const tslContent ='{"appName":"TagSpaces","appVersion":"5.3.6","description":"","lastUpdated":"2023-06-08T16:51:23.926Z","tagGroups":[{"uuid":"collected_tag_group_id","title":"Collected Tags","color":"#61DD61","textcolor":"white","children":[{"title":"Stanimir","color":"#61DD61","textcolor":"white","type":"sidecar"}],"created_date":1686119562860,"modified_date":1686243083871,"expanded":true,"locationId":"dc1ffaaeeb5747e39dd171c7e551afd6"}]}';@@ -290,7 +290,7 @@ test.describe('TST04 - Testing the tag library:', () => {await checkSettings('[data-tid=saveTagInLocationTID]',true,- '[data-tid=advancedSettingsDialogTID]',+ '[data-tid=generalSettingsDialog]',);await createTagGroup(testGroup, defaultLocationName);await clickOn('[data-tid=locationManager]');@@ -323,7 +323,7 @@ test.describe('TST04 - Testing the tag library:', () => {await checkSettings('[data-tid=saveTagInLocationTID]',true,- '[data-tid=advancedSettingsDialogTID]',+ '[data-tid=generalSettingsDialog]',);await clickOn('[data-tid=tagLibrary]');@@ -410,7 +410,7 @@ test.describe('TST04 - Testing the tag library:', () => {await checkSettings('[data-tid=saveTagInLocationTID]',true,- '[data-tid=advancedSettingsDialogTID]',+ '[data-tid=generalSettingsDialog]',);await clickOn('[data-tid=tagLibrary]');@@ -437,7 +437,7 @@ test.describe('TST04 - Testing the tag library:', () => {await checkSettings('[data-tid=saveTagInLocationTID]',true,- '[data-tid=advancedSettingsDialogTID]',+ '[data-tid=generalSettingsDialog]',);await clickOn('[data-tid=tagLibrary]');