diff --git a/common/ASC.Data.Storage/S3/S3Storage.cs b/common/ASC.Data.Storage/S3/S3Storage.cs index 96b1c6f1bc..7240e8ad3e 100644 --- a/common/ASC.Data.Storage/S3/S3Storage.cs +++ b/common/ASC.Data.Storage/S3/S3Storage.cs @@ -24,9 +24,9 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -using Amazon.S3.Internal; using Amazon.Extensions.S3.Encryption; using Amazon.Extensions.S3.Encryption.Primitives; +using Amazon.S3.Internal; namespace ASC.Data.Storage.S3; @@ -47,7 +47,7 @@ public class S3Storage : BaseStorage private string _serviceurl; private bool _forcepathstyle; private string _secretAccessKeyId = string.Empty; - private ServerSideEncryptionMethod _sse = ServerSideEncryptionMethod.AES256; + private readonly ServerSideEncryptionMethod _sse = ServerSideEncryptionMethod.AES256; private bool _useHttp = true; private bool _lowerCasing = true; private bool _revalidateCloudFront; @@ -55,7 +55,7 @@ public class S3Storage : BaseStorage private string _subDir = ""; private EncryptionMethod _encryptionMethod = EncryptionMethod.None; - private string _encryptionKey = null; + private string _encryptionKey; public S3Storage( TempStream tempStream, @@ -184,17 +184,17 @@ public class S3Storage : BaseStorage return SaveAsync(domain, path, stream, contentType, contentDisposition, ACL.Auto); } - private bool EnableQuotaCheck(string domain) - { - return (QuotaController != null) && !domain.EndsWith("_temp"); - } + private bool EnableQuotaCheck(string domain) + { + return (QuotaController != null) && !domain.EndsWith("_temp"); + } public async Task SaveAsync(string domain, string path, Stream stream, string contentType, string contentDisposition, ACL acl, string contentEncoding = null, int cacheDays = 5) { var buffered = _tempStream.GetBuffered(stream); - if (EnableQuotaCheck(domain)) + if (EnableQuotaCheck(domain)) { QuotaController.QuotaUsedCheck(buffered.Length); } diff --git a/common/ASC.EventBus/Serializers/ProtobufSerializer.cs b/common/ASC.EventBus/Serializers/ProtobufSerializer.cs index 3024d05136..4b6754b280 100644 --- a/common/ASC.EventBus/Serializers/ProtobufSerializer.cs +++ b/common/ASC.EventBus/Serializers/ProtobufSerializer.cs @@ -45,7 +45,11 @@ public class ProtobufSerializer : IIntegrationEventSerializer private void BuildTypeModelFromAssembly(Assembly assembly) { - if (!assembly.GetName().Name.StartsWith("ASC.")) return; + var name = assembly.GetName().Name; + if (name == null || !name.StartsWith("ASC.")) + { + return; + } var types = assembly.GetExportedTypes() .Where(t => t.GetCustomAttributes().Any()); @@ -64,7 +68,7 @@ public class ProtobufSerializer : IIntegrationEventSerializer { return Array.Empty(); } - + using var ms = new MemoryStream(); Serializer.Serialize(ms, item); @@ -74,7 +78,7 @@ public class ProtobufSerializer : IIntegrationEventSerializer /// public T Deserialize(byte[] serializedObject) - { + { using var ms = new MemoryStream(serializedObject); return Serializer.Deserialize(ms); @@ -107,7 +111,7 @@ public class ProtobufSerializer : IIntegrationEventSerializer if (!baseType.GetSubtypes().Any(s => s.DerivedType == itemType)) { baseType.AddSubType(_baseFieldNumber, protoType); - + _baseFieldNumber++; _processedProtoTypes.Add(protoType.FullName); diff --git a/packages/client/src/HOCs/withContent.js b/packages/client/src/HOCs/withContent.js index 64062d934b..87ff930f1b 100644 --- a/packages/client/src/HOCs/withContent.js +++ b/packages/client/src/HOCs/withContent.js @@ -120,7 +120,6 @@ export default function withContent(WrappedContent) { }, { item } ) => { - const { editCompleteAction } = filesActionsStore; const { createFile, createFolder, @@ -164,7 +163,6 @@ export default function withContent(WrappedContent) { createFile, createFolder, culture, - editCompleteAction, folderFormValidation, homepage: config.homepage, diff --git a/packages/client/src/HOCs/withFileActions.js b/packages/client/src/HOCs/withFileActions.js index 53fc855980..fd8605d678 100644 --- a/packages/client/src/HOCs/withFileActions.js +++ b/packages/client/src/HOCs/withFileActions.js @@ -331,7 +331,8 @@ export default function withFileActions(WrappedFileItem) { ) isActive = true; - const showHotkeyBorder = hotkeyCaret?.id === item.id; + const showHotkeyBorder = + hotkeyCaret?.id === item.id && hotkeyCaret?.isFolder === item.isFolder; return { t, diff --git a/packages/client/src/HOCs/withHotkeys.js b/packages/client/src/HOCs/withHotkeys.js index 3517fc14a3..cd9f046e19 100644 --- a/packages/client/src/HOCs/withHotkeys.js +++ b/packages/client/src/HOCs/withHotkeys.js @@ -1,9 +1,9 @@ import React, { useEffect } from "react"; import { useHotkeys } from "react-hotkeys-hook"; import { observer, inject } from "mobx-react"; -import { FileAction } from "@docspace/common/constants"; import { Events } from "@docspace/client/src/helpers/filesConstants"; import toastr from "client/toastr"; +import throttle from "lodash/throttle"; const withHotkeys = (Component) => { const WithHotkeys = (props) => { @@ -51,6 +51,7 @@ const withHotkeys = (Component) => { selection, setFavoriteAction, + filesIsLoading, } = props; const hotkeysFilter = { @@ -58,7 +59,11 @@ const withHotkeys = (Component) => { ev.target?.type === "checkbox" || ev.target?.tagName !== "INPUT", filterPreventDefault: false, enableOnTags: ["INPUT"], - enabled: !someDialogIsOpen && enabledHotkeys && !mediaViewerIsVisible, + enabled: + !someDialogIsOpen && + enabledHotkeys && + !mediaViewerIsVisible && + !filesIsLoading, // keyup: true, // keydown: false, }; @@ -87,9 +92,12 @@ const withHotkeys = (Component) => { }; useEffect(() => { - window.addEventListener("keydown", onKeyDown); + const throttledKeyDownEvent = throttle(onKeyDown, 300); - return () => window.removeEventListener("keypress", onKeyDown); + window.addEventListener("keydown", throttledKeyDownEvent); + + return () => + window.removeEventListener("keypress", throttledKeyDownEvent); }); //Select/deselect item @@ -322,9 +330,9 @@ const withHotkeys = (Component) => { setSelected, viewAs, setViewAs, - fileActionStore, enabledHotkeys, selection, + filesIsLoading, } = filesStore; const { @@ -413,6 +421,7 @@ const withHotkeys = (Component) => { selection, setFavoriteAction, + filesIsLoading, }; } )(observer(WithHotkeys)); diff --git a/packages/client/src/components/Article/Body/index.js b/packages/client/src/components/Article/Body/index.js index e4aab77d78..4b37d825b8 100644 --- a/packages/client/src/components/Article/Body/index.js +++ b/packages/client/src/components/Article/Body/index.js @@ -45,6 +45,7 @@ const ArticleBodyContent = (props) => { theme, toggleArticleOpen, categoryType, + filesIsLoading, } = props; const campaigns = (localStorage.getItem("campaigns") || "") @@ -67,6 +68,7 @@ const ArticleBodyContent = (props) => { archiveFolderId, } = props; + if (filesIsLoading) return; const filesSection = window.location.pathname.indexOf("/filter") > 0; if (filesSection) { @@ -191,6 +193,7 @@ export default inject( isLoading, isLoaded, categoryType, + filesIsLoading, } = filesStore; const { @@ -253,6 +256,7 @@ export default inject( archiveFolderId, categoryType, + filesIsLoading, }; } )( diff --git a/packages/client/src/components/GlobalEvents/CreateEvent.js b/packages/client/src/components/GlobalEvents/CreateEvent.js index 2b6acf0c9a..2b9a226cca 100644 --- a/packages/client/src/components/GlobalEvents/CreateEvent.js +++ b/packages/client/src/components/GlobalEvents/CreateEvent.js @@ -103,7 +103,7 @@ const CreateEvent = ({ addActiveItems(null, [folder.id]); setCreatedItem({ id: createdFolderId, type: "folder" }); }) - .then(() => editCompleteAction(id, item, false, type)) + .then(() => editCompleteAction(item, type, true)) .catch((e) => toastr.error(e)) .finally(() => { const folderIds = [+id]; @@ -123,7 +123,7 @@ const CreateEvent = ({ open && openDocEditor(file.id, file.providerKey, tab); }) - .then(() => editCompleteAction(id, item, false, type)) + .then(() => editCompleteAction(item, type)) .catch((err) => { if (err.indexOf("password") == -1) { toastr.error(err, t("Common:Warning")); @@ -173,7 +173,7 @@ const CreateEvent = ({ return open && openDocEditor(file.id, file.providerKey, tab); }) - .then(() => editCompleteAction(id, item, false, type)) + .then(() => editCompleteAction(item, type)) .catch((e) => toastr.error(e)) .finally(() => { const fileIds = [+id]; @@ -209,7 +209,7 @@ const CreateEvent = ({ return open && openDocEditor(file.id, file.providerKey, tab); }) - .then(() => editCompleteAction(id, item, false, type)) + .then(() => editCompleteAction(item, type)) .catch((e) => toastr.error(e)) .finally(() => { const fileIds = [+id]; diff --git a/packages/client/src/components/GlobalEvents/RenameEvent.js b/packages/client/src/components/GlobalEvents/RenameEvent.js index 86bfb51236..f670d2130b 100644 --- a/packages/client/src/components/GlobalEvents/RenameEvent.js +++ b/packages/client/src/components/GlobalEvents/RenameEvent.js @@ -48,7 +48,7 @@ const RenameEvent = ({ if (isSameTitle) { setStartValue(originalTitle); - return editCompleteAction(item.id, item, isSameTitle, type); + return editCompleteAction(item, type); } else { timerId = setTimeout(() => { isFile ? addActiveItems([item.id]) : addActiveItems(null, [item.id]); @@ -57,7 +57,7 @@ const RenameEvent = ({ isFile ? updateFile(item.id, value) - .then(() => editCompleteAction(item.id, item, false, type)) + .then(() => editCompleteAction(item, type)) .then(() => toastr.success( t("FileRenamed", { @@ -68,7 +68,7 @@ const RenameEvent = ({ ) .catch((err) => { toastr.error(err); - editCompleteAction(item.id, item, false, type); + editCompleteAction(item, type); }) .finally(() => { clearTimeout(timerId); @@ -79,7 +79,7 @@ const RenameEvent = ({ onClose(); }) : renameFolder(item.id, value) - .then(() => editCompleteAction(item.id, item, false, type)) + .then(() => editCompleteAction(item, type)) .then(() => toastr.success( t("FolderRenamed", { @@ -90,7 +90,7 @@ const RenameEvent = ({ ) .catch((err) => { toastr.error(err); - editCompleteAction(item.id, item, false, type); + editCompleteAction(item, type); }) .finally(() => { clearTimeout(timerId); diff --git a/packages/client/src/components/GlobalEvents/sub-components/Dialog.js b/packages/client/src/components/GlobalEvents/sub-components/Dialog.js index 8be0dddbd5..ee4a0b4bdd 100644 --- a/packages/client/src/components/GlobalEvents/sub-components/Dialog.js +++ b/packages/client/src/components/GlobalEvents/sub-components/Dialog.js @@ -86,7 +86,7 @@ const Dialog = ({