Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove fake social action waits

Anand Baburajan208ceb5946cf
diff --git a/web/apps/social/src/components/SocialActionFeedback.tsx b/web/apps/social/src/components/SocialActionFeedback.tsx
index 5361f5e2e5..4e95f08c66 100644
--- a/web/apps/social/src/components/SocialActionFeedback.tsx
+++ b/web/apps/social/src/components/SocialActionFeedback.tsx
@@ -4,7 +4,6 @@ import { Box } from "@mui/material";
import { keyframes } from "@mui/material/styles";
import React from "react";
-export const socialActionBusyDurationMs = 2000;
export const socialActionDoneDurationMs = 2400;
export const socialActionTransition = "220ms cubic-bezier(0.4, 0, 0.2, 1)";
diff --git a/web/apps/social/src/components/SocialFileViewer.tsx b/web/apps/social/src/components/SocialFileViewer.tsx
index cb06fb4bbf..39dfc96e3c 100644
--- a/web/apps/social/src/components/SocialFileViewer.tsx
+++ b/web/apps/social/src/components/SocialFileViewer.tsx
@@ -12,7 +12,6 @@ import { Box, Menu, MenuItem } from "@mui/material";
import { keyframes } from "@mui/material/styles";
import { ConfirmationActionSheet } from "components/ConfirmationActionSheet";
import {
- socialActionBusyDurationMs,
socialActionDoneDurationMs,
type SocialActionPhase,
} from "components/SocialActionFeedback";
@@ -235,9 +234,6 @@ const resizeCaptionInput = (
input.scrollHeight > captionInputMaxHeight ? "auto" : "hidden";
};
-const wait = (durationMs: number) =>
- new Promise((resolve) => window.setTimeout(resolve, durationMs));
-
export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
focusReplyOnOpen = false,
initialScreen = "photo",
@@ -457,10 +453,7 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
setDeleteActionPhase("busy");
void (async () => {
try {
- await Promise.all([
- Promise.resolve(onDeletePost?.()),
- wait(socialActionBusyDurationMs),
- ]);
+ await Promise.resolve(onDeletePost?.());
setDeleteActionPhase("done");
} catch (error) {
console.error("Failed to delete social post", error);
@@ -481,10 +474,7 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
setDraftPostActionPhase("busy");
void (async () => {
try {
- await Promise.all([
- onPublishDraftPost(caption),
- wait(socialActionBusyDurationMs),
- ]);
+ await onPublishDraftPost(caption);
setDraftPostActionPhase("done");
} catch (error) {
console.error("Failed to publish social post", error);
@@ -500,10 +490,7 @@ export const SocialFileViewer: React.FC<SocialFileViewerProps> = ({
setReplyActionPhase("busy");
void (async () => {
try {
- await Promise.all([
- onReplyToPost(photo.postId!, text),
- wait(socialActionBusyDurationMs),
- ]);
+ await onReplyToPost(photo.postId!, text);
setReplyText("");
setReplyActionPhase("done");
} catch (error) {
diff --git a/web/apps/social/src/screens/FriendsScreen.tsx b/web/apps/social/src/screens/FriendsScreen.tsx
index b49323dca8..6935ed5a94 100644
--- a/web/apps/social/src/screens/FriendsScreen.tsx
+++ b/web/apps/social/src/screens/FriendsScreen.tsx
@@ -7,7 +7,6 @@ import { HugeiconsIcon } from "@hugeicons/react";
import { Box, Menu, MenuItem } from "@mui/material";
import { ConfirmationActionSheet } from "components/ConfirmationActionSheet";
import {
- socialActionBusyDurationMs,
socialActionDoneDurationMs,
type SocialActionPhase,
} from "components/SocialActionFeedback";
@@ -294,29 +293,19 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({
const confirmUnfriend = () => {
if (!friendToUnfriend || isUnfriendActionRunning) return;
- setUnfriendActionPhase("busy");
+ onUnfriend?.(friendToUnfriend.id);
+ setUnfriendActionPhase("done");
};
React.useEffect(() => {
- if (!unfriendActionPhase) return;
-
- const timeoutID = window.setTimeout(
- () => {
- if (unfriendActionPhase == "busy") {
- setUnfriendActionPhase("done");
- return;
- }
+ if (unfriendActionPhase != "done") return;
- if (friendToUnfriend) onUnfriend?.(friendToUnfriend.id);
- setFriendToUnfriend(null);
- },
- unfriendActionPhase == "busy"
- ? socialActionBusyDurationMs
- : socialActionDoneDurationMs,
- );
+ const timeoutID = window.setTimeout(() => {
+ setFriendToUnfriend(null);
+ }, socialActionDoneDurationMs);
return () => window.clearTimeout(timeoutID);
- }, [friendToUnfriend, onUnfriend, unfriendActionPhase]);
+ }, [unfriendActionPhase]);
const handleUnfriendSheetExited = () => {
if (!unfriendActionPhase) return;