Skip to content

Commit 8a9253b

Browse files
committed
Show loading when opening default files
1 parent 416e08a commit 8a9253b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libs/remix-ui/home-tab/src/lib/components/homeTabFile.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
1313
}>({
1414
recentWorkspaces: [],
1515
})
16+
const [loadingWorkspace, setLoadingWorkspace] = useState<string>(null)
1617
const theme = useContext(ThemeContext)
1718
const isDark = theme.name === 'dark'
1819

@@ -60,6 +61,7 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
6061

6162
const handleSwitchToRecentWorkspace = async (e, workspaceName) => {
6263
e.preventDefault()
64+
setLoadingWorkspace(workspaceName)
6365
plugin.call('sidePanel', 'showContent', 'filePanel')
6466
plugin.verticalIcons.select('filePanel')
6567
_paq.push(['trackEvent', 'hometab', 'filesSection', 'loadRecentWorkspace'])
@@ -89,6 +91,7 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
8991
} else if (workspaceFiles['README.md'] && !workspaceFiles['README.md'].isDirectory) {
9092
await plugin.call('fileManager', 'open', '/README.md')
9193
}
94+
setLoadingWorkspace(null)
9295
}
9396

9497
return (
@@ -103,7 +106,8 @@ function HomeTabFile({ plugin }: HomeTabFileProps) {
103106
Array.isArray(state.recentWorkspaces) && state.recentWorkspaces.map((workspace, index) => {
104107
return index < 3 ? (
105108
<a className="cursor-pointer mb-1 text-decoration-none" href="#" onClick={(e) => handleSwitchToRecentWorkspace(e, workspace)}>
106-
<i className="fas fa-folder-tree mr-2"></i> <span style={{ color: isDark ? 'white' : 'black' }}>{workspace}</span>
109+
{ loadingWorkspace === workspace ? <i className="fad fa-spinner fa-spin mr-2"></i> : <i className="fas fa-folder-tree mr-2"></i> }
110+
<span style={{ color: isDark ? 'white' : 'black' }}>{workspace}</span>
107111
</a>
108112
) : null
109113
})

0 commit comments

Comments
 (0)