Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix space likes dialog loading

Anand Baburajan9374373abfa2
diff --git a/web/apps/space/src/components/SpaceFileViewer.tsx b/web/apps/space/src/components/SpaceFileViewer.tsx
index 7fa28a7bfd..2651b3bac0 100644
--- a/web/apps/space/src/components/SpaceFileViewer.tsx
+++ b/web/apps/space/src/components/SpaceFileViewer.tsx
@@ -33,6 +33,7 @@ import type { SpaceImageCropArea } from "utils/spacePostImage";
const green = "#08C225";
const avatarSkeletonBackground = "#E6E6E6";
const textBase = "#F4F4F4";
+const viewerLikeCountText = "#D8D8D8";
const textSecondary = "#A6A6A6";
const textTertiary = "rgba(244, 244, 244, 0.52)";
const viewerBackground = "#000000";
@@ -1788,7 +1789,7 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
bgcolor: "transparent",
border: 0,
borderRadius: "8px",
- color: textBase,
+ color: viewerLikeCountText,
cursor:
activePhoto.postId && onLoadPostLikers
? "pointer"
@@ -1872,7 +1873,6 @@ export const SpaceFileViewer: React.FC<SpaceFileViewerProps> = ({
)}
<SpacePostLikersDialog
errorMessage={postLikersError}
- likeCount={activePhoto.likeCount ?? 0}
likers={postLikers}
loading={postLikersLoading}
open={postLikersOpen}
diff --git a/web/apps/space/src/components/SpacePostLikersDialog.tsx b/web/apps/space/src/components/SpacePostLikersDialog.tsx
index 3da0b7a4a2..f7e212d776 100644
--- a/web/apps/space/src/components/SpacePostLikersDialog.tsx
+++ b/web/apps/space/src/components/SpacePostLikersDialog.tsx
@@ -1,4 +1,4 @@
-import { Box, Dialog, useMediaQuery } from "@mui/material";
+import { Box, CircularProgress, Dialog, useMediaQuery } from "@mui/material";
import { SpaceBottomSheetTransition } from "components/SpaceBottomSheetTransition";
import React from "react";
import type { SpacePostLiker } from "services/space";
@@ -8,19 +8,18 @@ const textSecondary = "#A6A6A6";
const lightTextBase = "#000000";
const lightTextSecondary = "#777777";
const dangerColor = "#F63A3A";
+const green = "#1DB954";
const sheetBackground = "#1E1E1E";
const lightSheetBackground = "#F2F2F2";
const avatarBackground = "#333333";
const lightAvatarBackground = "#E6E6E6";
-const skeletonFill = "#3A3A3A";
-const lightSkeletonFill = "#D7D7D7";
const darkBackdropBackground = "rgba(0, 0, 0, 0.86)";
const lightBackdropBackground = "rgba(255, 255, 255, 0.72)";
+const likersPanelHeight = "min(200px, 36vh)";
interface SpacePostLikersDialogProps {
appearance?: "dark" | "light";
errorMessage?: string | null;
- likeCount: number;
likers: SpacePostLiker[];
loading: boolean;
open: boolean;
@@ -30,7 +29,6 @@ interface SpacePostLikersDialogProps {
export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({
appearance = "dark",
errorMessage,
- likeCount,
likers,
loading,
open,
@@ -42,7 +40,6 @@ export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({
const primaryText = isLight ? lightTextBase : textBase;
const secondaryText = isLight ? lightTextSecondary : textSecondary;
const avatarFill = isLight ? lightAvatarBackground : avatarBackground;
- const loadingFill = isLight ? lightSkeletonFill : skeletonFill;
const backdropBackground = isLight
? lightBackdropBackground
: darkBackdropBackground;
@@ -101,23 +98,37 @@ export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({
}}
>
<Box sx={{ width: "100%" }}>
- <Box sx={{ maxHeight: "min(420px, 62vh)", overflowY: "auto" }}>
+ <Box sx={{ height: likersPanelHeight, overflowY: "auto" }}>
{loading ? (
- <SpacePostLikerSkeletonRows
- rowCount={likeCount}
- skeletonFill={loadingFill}
- />
+ <Box
+ sx={{
+ alignItems: "center",
+ display: "flex",
+ height: "100%",
+ justifyContent: "center",
+ }}
+ >
+ <CircularProgress
+ aria-label="Loading likes"
+ size={24}
+ thickness={4}
+ sx={{ color: green }}
+ />
+ </Box>
) : errorMessage ? (
<Box
role="alert"
sx={{
+ alignItems: "center",
color: dangerColor,
+ display: "flex",
fontFamily:
'"Inter Variable", Inter, sans-serif',
fontSize: 13,
fontWeight: 650,
+ justifyContent: "center",
lineHeight: "18px",
- py: "20px",
+ minHeight: "100%",
textAlign: "center",
}}
>
@@ -126,13 +137,16 @@ export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({
) : likers.length == 0 ? (
<Box
sx={{
+ alignItems: "center",
color: secondaryText,
+ display: "flex",
fontFamily:
'"Inter Variable", Inter, sans-serif',
fontSize: 14,
fontWeight: 600,
+ justifyContent: "center",
lineHeight: "20px",
- py: "20px",
+ minHeight: "100%",
textAlign: "center",
}}
>
@@ -166,65 +180,6 @@ export const SpacePostLikersDialog: React.FC<SpacePostLikersDialogProps> = ({
);
};
-const SpacePostLikerSkeletonRows: React.FC<{
- rowCount: number;
- skeletonFill: string;
-}> = ({ rowCount, skeletonFill }) => (
- <Box
- component="ul"
- sx={{
- display: "flex",
- flexDirection: "column",
- gap: "8px",
- listStyle: "none",
- m: 0,
- p: 0,
- }}
- >
- {Array.from({ length: rowCount }, (_, index) => (
- <Box
- component="li"
- key={index}
- sx={{
- alignItems: "center",
- display: "grid",
- gap: "8px",
- gridTemplateColumns: "28px minmax(0, 1fr) 24px",
- minHeight: 38,
- py: "4px",
- }}
- >
- <Box
- sx={{
- bgcolor: skeletonFill,
- borderRadius: "50%",
- height: 28,
- width: 28,
- }}
- />
- <Box
- sx={{
- bgcolor: skeletonFill,
- borderRadius: "999px",
- height: 12,
- opacity: 0.9,
- width: "42%",
- }}
- />
- <Box
- sx={{
- bgcolor: skeletonFill,
- borderRadius: "50%",
- height: 18,
- justifySelf: "center",
- width: 18,
- }}
- />
- </Box>
- ))}
- </Box>
-);
-
const SpacePostLikerRow: React.FC<{
avatarFill: string;
liker: SpacePostLiker;
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index a7eee24775..9e046c6bbc 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -1289,7 +1289,7 @@ const FeedOwnPostLikeButton: React.FC<{
bgcolor: "transparent",
border: 0,
borderRadius: "8px",
- color: textBase,
+ color: textSecondary,
cursor: onLoadPostLikers ? "pointer" : "default",
display: "inline-flex",
fontFamily: '"Inter Variable", Inter, sans-serif',
@@ -1338,7 +1338,6 @@ const FeedOwnPostLikeButton: React.FC<{
<SpacePostLikersDialog
appearance="light"
errorMessage={postLikersError}
- likeCount={likeCount}
likers={postLikers}
loading={postLikersLoading}
open={postLikersOpen}