Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6aac574ee |
@@ -20,12 +20,7 @@ import { IContent } from 'matrix-js-sdk';
|
||||
import { useTimestampFormatter } from '../../hooks/useTimestampFormatter';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { stopPropagation } from '../../utils/keyboard';
|
||||
import {
|
||||
describeScheduleError,
|
||||
MAX_SCHEDULE_AHEAD_MS,
|
||||
scheduleMessage,
|
||||
SCHEDULE_TOO_FAR_TEXT,
|
||||
} from '../../utils/scheduledMessages';
|
||||
import { scheduleMessage } from '../../utils/scheduledMessages';
|
||||
import { useModalStyle } from '../../hooks/useModalStyle';
|
||||
import {
|
||||
toLocalDate,
|
||||
@@ -126,13 +121,7 @@ export function ScheduleMessageModal({
|
||||
return;
|
||||
}
|
||||
const diffMs = sendAt.getTime() - Date.now();
|
||||
// [Gitea #275] Say so as soon as a too-late time is picked, not on submit.
|
||||
const tooFar = diffMs > MAX_SCHEDULE_AHEAD_MS;
|
||||
setError((e) => {
|
||||
if (tooFar) return SCHEDULE_TOO_FAR_TEXT;
|
||||
return e === SCHEDULE_TOO_FAR_TEXT ? null : e;
|
||||
});
|
||||
if (diffMs < 60_000 || tooFar) {
|
||||
if (diffMs < 60_000) {
|
||||
setPreview(null);
|
||||
return;
|
||||
}
|
||||
@@ -160,10 +149,6 @@ export function ScheduleMessageModal({
|
||||
setError('Scheduled time must be at least 1 minute in the future.');
|
||||
return;
|
||||
}
|
||||
if (diffMs > MAX_SCHEDULE_AHEAD_MS) {
|
||||
setError(SCHEDULE_TOO_FAR_TEXT);
|
||||
return;
|
||||
}
|
||||
if (!messageText.trim()) {
|
||||
setError('Please enter a message to schedule.');
|
||||
return;
|
||||
@@ -177,7 +162,7 @@ export function ScheduleMessageModal({
|
||||
onScheduled(delayId, sendAt.getTime(), content);
|
||||
onClose();
|
||||
} catch (err) {
|
||||
setError(describeScheduleError(err));
|
||||
setError(err instanceof Error ? err.message : 'Failed to schedule message.');
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
@@ -262,8 +247,6 @@ export function ScheduleMessageModal({
|
||||
<input
|
||||
id="schedule-date"
|
||||
type="date"
|
||||
min={toLocalDate(new Date())}
|
||||
max={toLocalDate(new Date(Date.now() + MAX_SCHEDULE_AHEAD_MS))}
|
||||
value={dateValue}
|
||||
onChange={(e) => setDateValue(e.target.value)}
|
||||
style={pickerInputStyle(color, config)}
|
||||
@@ -311,8 +294,7 @@ export function ScheduleMessageModal({
|
||||
</Box>
|
||||
</Box>
|
||||
) : (
|
||||
(dateValue || timeValue) &&
|
||||
error !== SCHEDULE_TOO_FAR_TEXT && (
|
||||
(dateValue || timeValue) && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
Must be at least 1 minute in the future
|
||||
</Text>
|
||||
|
||||
@@ -65,12 +65,12 @@ export function SyncStatus({ mx }: SyncStatusProps) {
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
(stateData.current === SyncState.Prepared ||
|
||||
stateData.current === SyncState.Syncing ||
|
||||
stateData.current === SyncState.Catchup) &&
|
||||
stateData.previous !== SyncState.Syncing
|
||||
) {
|
||||
// [Gitea #274] Only while catching up after a drop. Upstream also showed it
|
||||
// for PREPARED and for the first SYNCING after PREPARED/RECONNECTING, i.e.
|
||||
// until the NEXT /sync returned: on a quiet account that long-polls ~30 s
|
||||
// while the app already works (a SYNCING means a sync just succeeded).
|
||||
// A real failure still surfaces as Reconnecting / Connection lost.
|
||||
if (stateData.current === SyncState.Catchup) {
|
||||
return (
|
||||
<Box direction="Column" shrink="No">
|
||||
<Box
|
||||
|
||||
@@ -179,15 +179,3 @@ test('groupScheduledByRoom: groups and sorts by sendAt', () => {
|
||||
);
|
||||
assert.equal(g.get('!2')?.length, 1);
|
||||
});
|
||||
|
||||
test('[#275] the server limit maps to friendly text; other errors keep theirs', async () => {
|
||||
const { describeScheduleError, SCHEDULE_TOO_FAR_TEXT, MAX_SCHEDULE_AHEAD_MS } =
|
||||
await import('./scheduledMessages');
|
||||
assert.equal(MAX_SCHEDULE_AHEAD_MS, 86_400_000);
|
||||
const tooLarge = Object.assign(new Error('The requested delay (172800000ms) exceeds…'), {
|
||||
errcode: 'ORG.MATRIX.MSC4140_DELAY_TOO_LARGE',
|
||||
});
|
||||
assert.equal(describeScheduleError(tooLarge), SCHEDULE_TOO_FAR_TEXT);
|
||||
assert.equal(describeScheduleError(new Error('Boom')), 'Boom');
|
||||
assert.equal(describeScheduleError('nope'), 'Failed to schedule message.');
|
||||
});
|
||||
|
||||
@@ -1,22 +1,6 @@
|
||||
import { IContent, MatrixClient, Method } from 'matrix-js-sdk';
|
||||
import type { ScheduledMessage } from '../state/scheduledMessages';
|
||||
|
||||
/**
|
||||
* [Gitea #275] Production Synapse caps delayed events at
|
||||
* `max_event_delay_duration: 24h`; a later time is rejected with
|
||||
* ORG.MATRIX.MSC4140_DELAY_TOO_LARGE. The dialog enforces the same limit and
|
||||
* the server's error maps to the same text, in case the limit changes.
|
||||
*/
|
||||
export const MAX_SCHEDULE_AHEAD_MS = 24 * 60 * 60 * 1000;
|
||||
export const SCHEDULE_TOO_FAR_TEXT = 'You can schedule up to 24 hours ahead.';
|
||||
|
||||
/** A user-facing sentence for a failed schedule. */
|
||||
export const describeScheduleError = (err: unknown): string => {
|
||||
const errcode = (err as { errcode?: unknown } | null)?.errcode;
|
||||
if (errcode === 'ORG.MATRIX.MSC4140_DELAY_TOO_LARGE') return SCHEDULE_TOO_FAR_TEXT;
|
||||
return err instanceof Error ? err.message : 'Failed to schedule message.';
|
||||
};
|
||||
|
||||
/**
|
||||
* Schedule a message via MSC4140 (delayed messages).
|
||||
* Synapse implementation: pass org.matrix.msc4140.delay on the standard
|
||||
|
||||
Reference in New Issue
Block a user