✨ Auto refresh anchoring
This commit is contained in:
parent
e71516d4f3
commit
360386dd88
@ -37,6 +37,7 @@ type IPropsClass = IProps & {
|
||||
isAnchored: AnchorStatus;
|
||||
isLoading: boolean;
|
||||
selectedFolder: OfficeFolder | null;
|
||||
getAnchoringStatus: () => Promise<void>;
|
||||
};
|
||||
|
||||
type IState = {
|
||||
@ -314,7 +315,8 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
||||
|
||||
private async anchorFolder() {
|
||||
if (!this.props.selectedFolder?.uid) return;
|
||||
return await OfficeFolderAnchors.getInstance().post(this.props.selectedFolder.uid);
|
||||
await OfficeFolderAnchors.getInstance().post(this.props.selectedFolder.uid);
|
||||
this.props.getAnchoringStatus();
|
||||
}
|
||||
|
||||
private async downloadAnchoringProof(uid?: string) {
|
||||
@ -404,6 +406,16 @@ export default function FolderInformation(props: IProps) {
|
||||
let { folderUid } = router.query;
|
||||
folderUid = folderUid as string;
|
||||
|
||||
const getAnchoringStatus = useCallback(async () => {
|
||||
if (!folderUid) return;
|
||||
try {
|
||||
const anchorStatus = await OfficeFolderAnchors.getInstance().get(folderUid as string);
|
||||
setIsAnchored(anchorStatus.status === "VERIFIED_ON_CHAIN" ? AnchorStatus.VERIFIED_ON_CHAIN : AnchorStatus.ANCHORING);
|
||||
} catch (e) {
|
||||
setIsAnchored(AnchorStatus.NOT_ANCHORED);
|
||||
}
|
||||
}, [folderUid]);
|
||||
|
||||
const getFolder = useCallback(async () => {
|
||||
if (!folderUid) return;
|
||||
setIsLoading(true);
|
||||
@ -439,17 +451,11 @@ export default function FolderInformation(props: IProps) {
|
||||
const folder = await Folders.getInstance().getByUid(folderUid as string, query);
|
||||
if (folder) {
|
||||
setSelectedFolder(folder);
|
||||
|
||||
try {
|
||||
const anchorStatus = await OfficeFolderAnchors.getInstance().get(folderUid as string);
|
||||
setIsAnchored(anchorStatus.status === "VERIFIED_ON_CHAIN" ? AnchorStatus.VERIFIED_ON_CHAIN : AnchorStatus.ANCHORING);
|
||||
} catch (e) {
|
||||
setIsAnchored(AnchorStatus.NOT_ANCHORED);
|
||||
}
|
||||
getAnchoringStatus();
|
||||
}
|
||||
|
||||
setIsLoading(false);
|
||||
}, [folderUid]);
|
||||
}, [folderUid, getAnchoringStatus]);
|
||||
|
||||
useEffect(() => {
|
||||
setIsLoading(true);
|
||||
@ -464,6 +470,7 @@ export default function FolderInformation(props: IProps) {
|
||||
isAnchored={isAnchored}
|
||||
isLoading={isLoading}
|
||||
selectedFolder={selectedFolder}
|
||||
getAnchoringStatus={getAnchoringStatus}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user