feat: sync and update with all changes from solar-punk-ltd fork (#730)
* fix: swap error caused by invalid id and batchcount * fix: enhance creation messages for admin drive and user drives * fix: identity and wallet creation * fix: asset preview types * fix: fm search unicode text * fix: feed identity and stamp usage * fix: ui display changes * fix: stamp buy and dilute * fix: vite polyfill warning for stream * fix: standard mode postage stamp purchase reserves incorrect size and duration * fix: add syncing message for Bee node and update page state handling * refactor: stamp depth and amount validation --------- Co-authored-by: Balint Ujvari <balint.ujvari@solarpunk.buzz> Co-authored-by: Bálint Ujvári <58116288+bosi95@users.noreply.github.com> Co-authored-by: rolandlor <33499567+rolandlor@users.noreply.github.com>
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
import { DriveInfo, FileManagerBase } from '@solarpunkltd/file-manager-lib'
|
||||
import { ReactElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'
|
||||
|
||||
import { AdminStatusBar } from '../../modules/filemanager/components/AdminStatusBar/AdminStatusBar'
|
||||
import { Button } from '../../modules/filemanager/components/Button/Button'
|
||||
import { ConfirmModal } from '../../modules/filemanager/components/ConfirmModal/ConfirmModal'
|
||||
import { ErrorModal } from '../../modules/filemanager/components/ErrorModal/ErrorModal'
|
||||
import { FileBrowser } from '../../modules/filemanager/components/FileBrowser/FileBrowser'
|
||||
import { FormbricksIntegration } from '../../modules/filemanager/components/FormbricksIntegration/FormbricksIntegration'
|
||||
import { Header } from '../../modules/filemanager/components/Header/Header'
|
||||
import { InitialModal } from '../../modules/filemanager/components/InitialModal/InitialModal'
|
||||
import { PrivateKeyModal } from '../../modules/filemanager/components/PrivateKeyModal/PrivateKeyModal'
|
||||
import { Sidebar } from '../../modules/filemanager/components/Sidebar/Sidebar'
|
||||
import { getSignerPk, removeSignerPk } from '../../modules/filemanager/utils/common'
|
||||
import { CheckState, Context as BeeContext } from '../../providers/Bee'
|
||||
import { Context as FMContext } from '../../providers/FileManager'
|
||||
import { BrowserPlatform, cacheClearUrls, detectBrowser } from '../../providers/Platform'
|
||||
|
||||
import { SearchProvider } from './SearchContext'
|
||||
import { ViewProvider } from './ViewContext'
|
||||
|
||||
import './FileManager.scss'
|
||||
|
||||
import { AdminStatusBar } from '@/modules/filemanager/components/AdminStatusBar/AdminStatusBar'
|
||||
import { Button } from '@/modules/filemanager/components/Button/Button'
|
||||
import { ConfirmModal } from '@/modules/filemanager/components/ConfirmModal/ConfirmModal'
|
||||
import { ErrorModal } from '@/modules/filemanager/components/ErrorModal/ErrorModal'
|
||||
import { FileBrowser } from '@/modules/filemanager/components/FileBrowser/FileBrowser'
|
||||
import { FormbricksIntegration } from '@/modules/filemanager/components/FormbricksIntegration/FormbricksIntegration'
|
||||
import { Header } from '@/modules/filemanager/components/Header/Header'
|
||||
import { InitialModal } from '@/modules/filemanager/components/InitialModal/InitialModal'
|
||||
import { PrivateKeyModal } from '@/modules/filemanager/components/PrivateKeyModal/PrivateKeyModal'
|
||||
import { Sidebar } from '@/modules/filemanager/components/Sidebar/Sidebar'
|
||||
import { getSignerPk, removeSignerPk } from '@/modules/filemanager/utils/common'
|
||||
import { CheckState, Context as BeeContext } from '@/providers/Bee'
|
||||
import { Context as FMContext } from '@/providers/FileManager'
|
||||
import { BrowserPlatform, cacheClearUrls, detectBrowser } from '@/providers/Platform'
|
||||
|
||||
function PrivateKeyModalBlock({ onSaved }: { onSaved: () => void }) {
|
||||
return (
|
||||
<div className="fm-main">
|
||||
@@ -95,6 +95,22 @@ function LoadingBlock() {
|
||||
)
|
||||
}
|
||||
|
||||
function ChainSyncingBlock() {
|
||||
return (
|
||||
<div className="fm-main">
|
||||
<div className="fm-loading" aria-live="polite">
|
||||
<div className="fm-spinner" aria-hidden="true" />
|
||||
<div className="fm-loading-title">Bee node is syncing…</div>
|
||||
<div className="fm-loading-subtitle">
|
||||
Your Bee node is still syncing the postage batch state from the chain.
|
||||
<br />
|
||||
File Manager will be available once the sync is complete.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ErrorModalBlock({ onClick, label }: { onClick: () => void; label: string }) {
|
||||
return <ErrorModal label={label} onClick={onClick} />
|
||||
}
|
||||
@@ -157,6 +173,7 @@ enum PageState {
|
||||
Loading = 'loading', // bee ready, pk present, FM init in progress
|
||||
Reset = 'reset', // STATE_INVALID emitted and user has not yet acknowledged
|
||||
InitError = 'init-error', // FM init completed with an error (non-reset case)
|
||||
ChainSyncing = 'chain-syncing', // bee node is still syncing postage batch state from chain
|
||||
Initial = 'initial', // FM ready but no admin stamp/drive → show InitialModal
|
||||
AdminError = 'admin-error', // drive creation failed
|
||||
Ready = 'ready', // fully operational
|
||||
@@ -172,7 +189,7 @@ export function FileManagerPage(): ReactElement {
|
||||
const [connectionErrorDismissed, setConnectionErrorDismissed] = useState<boolean>(false)
|
||||
const [cacheHelpUrl, setCacheHelpUrl] = useState<string>(cacheClearUrls[BrowserPlatform.Chrome])
|
||||
|
||||
const { status } = useContext(BeeContext)
|
||||
const { status, chainState } = useContext(BeeContext)
|
||||
const { fm, initDone, shallReset, adminDrive, initializationError, notifyPkSaved } = useContext(FMContext)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -207,6 +224,8 @@ export function FileManagerPage(): ReactElement {
|
||||
}, [isConnectionError])
|
||||
|
||||
const pageState = useMemo((): PageState => {
|
||||
const isChainSyncing = chainState === null
|
||||
|
||||
if (!isBeeReady && !initDone) return PageState.Connecting
|
||||
|
||||
if (!hasPk) return PageState.NoPrivateKey
|
||||
@@ -217,12 +236,15 @@ export function FileManagerPage(): ReactElement {
|
||||
|
||||
if (initializationError && !shallReset) return PageState.InitError
|
||||
|
||||
if (showAdminErrorModal) return PageState.AdminError
|
||||
|
||||
const hasAdminStamp = Boolean(fm?.adminStamp)
|
||||
const hasAdminDrive = Boolean(adminDrive)
|
||||
const setupIncomplete = !hasAdminStamp && !hasAdminDrive
|
||||
|
||||
if (!hasAdminStamp && !hasAdminDrive && !isCreationInProgress) return PageState.Initial
|
||||
if (setupIncomplete && isChainSyncing) return PageState.ChainSyncing
|
||||
|
||||
if (showAdminErrorModal) return PageState.AdminError
|
||||
|
||||
if (setupIncomplete && !isCreationInProgress) return PageState.Initial
|
||||
|
||||
return PageState.Ready
|
||||
}, [
|
||||
@@ -236,6 +258,7 @@ export function FileManagerPage(): ReactElement {
|
||||
fm,
|
||||
adminDrive,
|
||||
isCreationInProgress,
|
||||
chainState,
|
||||
])
|
||||
|
||||
const handlePrivateKeySaved = useCallback(() => {
|
||||
@@ -255,6 +278,10 @@ export function FileManagerPage(): ReactElement {
|
||||
return <LoadingBlock />
|
||||
}
|
||||
|
||||
if (pageState === PageState.ChainSyncing) {
|
||||
return <ChainSyncingBlock />
|
||||
}
|
||||
|
||||
if (pageState === PageState.NoPrivateKey) {
|
||||
return <PrivateKeyModalBlock onSaved={handlePrivateKeySaved} />
|
||||
}
|
||||
@@ -289,12 +316,15 @@ export function FileManagerPage(): ReactElement {
|
||||
}
|
||||
|
||||
if (pageState === PageState.AdminError) {
|
||||
const adminErrorLabel =
|
||||
chainState === null
|
||||
? 'Your Bee node is still syncing the postage batch state from the chain. Please wait for the sync to complete and try again.'
|
||||
: errorMessage ||
|
||||
'Error creating Admin Drive. Please try again. Possible causes include insufficient xDAI balance or a lost connection to the RPC.'
|
||||
|
||||
return (
|
||||
<ErrorModalBlock
|
||||
label={
|
||||
errorMessage ||
|
||||
'Error creating Admin Drive. Please try again. Possible causes include insufficient xDAI balance or a lost connection to the RPC.'
|
||||
}
|
||||
label={adminErrorLabel}
|
||||
onClick={() => {
|
||||
setAdminShowErrorModal(false)
|
||||
setErrorMessage('')
|
||||
|
||||
Reference in New Issue
Block a user