fix(web): file protected overlay not toggling off correctly (#1190)
This commit is contained in:
@@ -5,17 +5,27 @@ import FileViewWithoutProtection from './FileViewWithoutProtection'
|
|||||||
import { FileViewProps } from './FileViewProps'
|
import { FileViewProps } from './FileViewProps'
|
||||||
|
|
||||||
const FileView = ({ application, viewControllerManager, file }: FileViewProps) => {
|
const FileView = ({ application, viewControllerManager, file }: FileViewProps) => {
|
||||||
const [shouldShowProtectedOverlay, setShouldShowProtectedOverlay] = useState(
|
const [shouldShowProtectedOverlay, setShouldShowProtectedOverlay] = useState(false)
|
||||||
file.protected && !application.hasProtectionSources(),
|
|
||||||
)
|
useEffect(() => {
|
||||||
|
viewControllerManager.filesController.setShowProtectedOverlay(file.protected && !application.hasProtectionSources())
|
||||||
|
}, [application, file.protected, viewControllerManager.filesController])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setShouldShowProtectedOverlay(viewControllerManager.filesController.showProtectedOverlay)
|
setShouldShowProtectedOverlay(viewControllerManager.filesController.showProtectedOverlay)
|
||||||
}, [viewControllerManager.filesController.showProtectedOverlay])
|
}, [viewControllerManager.filesController.showProtectedOverlay])
|
||||||
|
|
||||||
const dismissProtectedWarning = useCallback(() => {
|
const dismissProtectedOverlay = useCallback(async () => {
|
||||||
void viewControllerManager.filesController.toggleFileProtection(file)
|
let showFileContents = true
|
||||||
}, [file, viewControllerManager.filesController])
|
|
||||||
|
if (application.hasProtectionSources()) {
|
||||||
|
showFileContents = await application.protections.authorizeItemAccess(file)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showFileContents) {
|
||||||
|
setShouldShowProtectedOverlay(false)
|
||||||
|
}
|
||||||
|
}, [application, file])
|
||||||
|
|
||||||
return shouldShowProtectedOverlay ? (
|
return shouldShowProtectedOverlay ? (
|
||||||
<div aria-label="Note" className="section editor sn-component">
|
<div aria-label="Note" className="section editor sn-component">
|
||||||
@@ -23,7 +33,7 @@ const FileView = ({ application, viewControllerManager, file }: FileViewProps) =
|
|||||||
<ProtectedItemOverlay
|
<ProtectedItemOverlay
|
||||||
viewControllerManager={viewControllerManager}
|
viewControllerManager={viewControllerManager}
|
||||||
hasProtectionSources={application.hasProtectionSources()}
|
hasProtectionSources={application.hasProtectionSources()}
|
||||||
onViewItem={dismissProtectedWarning}
|
onViewItem={dismissProtectedOverlay}
|
||||||
itemType={'note'}
|
itemType={'note'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -423,6 +423,7 @@ export class FilesController extends AbstractViewController {
|
|||||||
this.setShowProtectedOverlay(false)
|
this.setShowProtectedOverlay(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void this.application.sync.sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadFiles = async (files: FileItem[]) => {
|
downloadFiles = async (files: FileItem[]) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user