diff --git a/packages/shared-components/src/room/RoomStatusBar/RoomStatusBarView.stories.tsx b/packages/shared-components/src/room/RoomStatusBar/RoomStatusBarView.stories.tsx
index c25201bb9a..534963d5b1 100644
--- a/packages/shared-components/src/room/RoomStatusBar/RoomStatusBarView.stories.tsx
+++ b/packages/shared-components/src/room/RoomStatusBar/RoomStatusBarView.stories.tsx
@@ -110,7 +110,6 @@ WithLocalRoomRetry.args = {
export const WithMessageRejected = Template.bind({});
WithMessageRejected.args = {
state: RoomStatusBarState.MessageRejected,
- onResendAllClick: undefined,
harms: ["org.matrix.msc4387.harassment"],
};
@@ -123,6 +122,7 @@ WithMessageRejectedCanRetryInTime.args = {
onResendAllClick: undefined,
canRetryInSeconds: 5,
harms: [],
+ isResending: false,
};
/**
@@ -132,6 +132,7 @@ export const WithMessageRejectedCanRetry = Template.bind({});
WithMessageRejectedCanRetry.args = {
state: RoomStatusBarState.MessageRejected,
harms: [],
+ isResending: false,
};
/**
@@ -151,15 +152,7 @@ export const WithMessageRejectedWithKnownHarm = Template.bind({});
WithMessageRejectedWithKnownHarm.args = {
state: RoomStatusBarState.MessageRejected,
harms: ["org.matrix.msc4387.spam"],
-};
-
-/**
- * Rendered when a message was rejected by the server, and we use the generic message.
- */
-export const WithMessageRejectedWithUnknownHarm = Template.bind({});
-WithMessageRejectedWithUnknownHarm.args = {
- state: RoomStatusBarState.MessageRejected,
- harms: ["any.old.harm"],
+ isResending: false,
};
/**
@@ -170,4 +163,5 @@ WithMessageRejectedWithServerMessage.args = {
state: RoomStatusBarState.MessageRejected,
harms: ["any.old.harm"],
serverError: "OurServer rejects this content",
+ isResending: false,
};
diff --git a/packages/shared-components/src/room/RoomStatusBar/RoomStatusBarView.tsx b/packages/shared-components/src/room/RoomStatusBar/RoomStatusBarView.tsx
index 71e2f52e06..2532623d1c 100644
--- a/packages/shared-components/src/room/RoomStatusBar/RoomStatusBarView.tsx
+++ b/packages/shared-components/src/room/RoomStatusBar/RoomStatusBarView.tsx
@@ -18,22 +18,22 @@ export interface RoomStatusBarViewActions {
/**
* Called when the user clicks on the 'resend all' button in the 'unsent messages' bar.
*/
- onResendAllClick?: () => void;
+ onResendAllClick: () => void;
/**
* Called when the user clicks on the 'cancel all' button in the 'unsent messages' bar.
*/
- onDeleteAllClick?: () => void;
+ onDeleteAllClick: () => void;
/**
* Called when the user clicks on the 'Retry' button in the 'failed to start chat' bar.
*/
- onRetryRoomCreationClick?: () => void;
+ onRetryRoomCreationClick: () => void;
/**
* Called when the user clicks on the 'Review Terms and Conditions' button.
*/
- onTermsAndConditionsClicked?: () => void;
+ onTermsAndConditionsClicked: () => void;
}
export enum RoomStatusBarState {
@@ -72,13 +72,20 @@ export interface RoomStatusBarLocalRoomError {
state: RoomStatusBarState.LocalRoomFailed;
}
-export interface RoomStatusBarMessageRejected {
+export interface RoomStatusBarMessageRejectedRetryable {
state: RoomStatusBarState.MessageRejected;
canRetryInSeconds?: number;
isResending: boolean;
harms: string[];
serverError?: string;
}
+export interface RoomStatusBarMessageRejectedUnretryable {
+ state: RoomStatusBarState.MessageRejected;
+ harms: string[];
+ serverError?: string;
+}
+
+type RoomStatusBarMessageRejected = RoomStatusBarMessageRejectedRetryable | RoomStatusBarMessageRejectedUnretryable;
export type RoomStatusBarViewSnapshot =
| RoomStatusBarNoConnection
@@ -197,10 +204,14 @@ function RoomStatusBarViewMessageRejected({
);
let subtitleText: string;
- if (onResendAllClick) {
- subtitleText = _t("room|status_bar|select_messages_to_retry");
- } else if (!onResendAllClick && snapshot.canRetryInSeconds !== undefined) {
- subtitleText = _t("room|status_bar|message_rejected|can_retry_in", { count: snapshot.canRetryInSeconds });
+ const canRetry = "isResending" in snapshot;
+ const isResending = "isResending" in snapshot && snapshot.isResending;
+ if (canRetry) {
+ if (snapshot.canRetryInSeconds !== undefined) {
+ subtitleText = _t("room|status_bar|message_rejected|can_retry_in", { count: snapshot.canRetryInSeconds });
+ } else {
+ subtitleText = _t("room|status_bar|select_messages_to_retry");
+ }
} else {
subtitleText = _t("room|status_bar|message_rejected|cannot_retry");
}
@@ -210,30 +221,25 @@ function RoomStatusBarViewMessageRejected({
role="status"
type="critical"
actions={
- snapshot.isResending ? (
+ isResending ? (
) : (
<>
- {onDeleteAllClick && (
-
- )}
- {(onResendAllClick || snapshot.canRetryInSeconds) && (
+
+ {canRetry && (