Improve: enhance real-time paste handling and add saving status feedback

This commit is contained in:
2026-03-17 03:08:38 +01:00
parent 924f9626a6
commit fcd477e876

View File

@@ -32,6 +32,7 @@ const PastePanel = ({ onSubmit, publicPastes, mode, pasteKey: propKey, onConnect
syntax: "", syntax: "",
burnAfter: false, burnAfter: false,
isPrivate: false, isPrivate: false,
isRt: false,
password: "" password: ""
}); });
@@ -113,7 +114,8 @@ const PastePanel = ({ onSubmit, publicPastes, mode, pasteKey: propKey, onConnect
const dataToSave = { const dataToSave = {
...formData, ...formData,
pasteKey: activeKey, pasteKey: activeKey,
title: mode === 'rt' ? `Sesión: ${activeKey?.substring(0, 8)}` : formData.title isRt: true,
title: mode === 'rt' ? `Sesión: ${activeKey}` : formData.title
}; };
await onSubmit(dataToSave, true); await onSubmit(dataToSave, true);
lastSavedContent.current = formData.content; lastSavedContent.current = formData.content;
@@ -131,7 +133,7 @@ const PastePanel = ({ onSubmit, publicPastes, mode, pasteKey: propKey, onConnect
}, [formData.content, mode, connected, activeKey]); }, [formData.content, mode, connected, activeKey]);
const handleChange = (key, value) => { const handleChange = (key, value) => {
const updatedData = { ...formData, [key]: value }; const updatedData = { ...formData, [key]: value, isRt: mode === 'rt' };
setFormData(updatedData); setFormData(updatedData);
@@ -255,7 +257,7 @@ const PastePanel = ({ onSubmit, publicPastes, mode, pasteKey: propKey, onConnect
<Form.Control <Form.Control
disabled={isReadOnly} disabled={isReadOnly}
type="text" type="text"
value={mode === 'rt' ? `Sesión: ${activeKey?.substring(0, 8)}` : formData.title} value={mode === 'rt' ? `Sesión: ${activeKey}` : formData.title}
onChange={(e) => handleChange("title", e.target.value)} onChange={(e) => handleChange("title", e.target.value)}
isInvalid={!!fieldErrors.title} isInvalid={!!fieldErrors.title}
/> />
@@ -308,6 +310,19 @@ const PastePanel = ({ onSubmit, publicPastes, mode, pasteKey: propKey, onConnect
</Form.Select> </Form.Select>
</FloatingLabel> </FloatingLabel>
<div className="d-flex align-items-center ms-1">
{isSaving ? (
<span className="text-muted" style={{ fontSize: '0.8rem' }}>
<FontAwesomeIcon icon={faCircle} className="pulse-animation me-2" style={{ color: '#ffc107', fontSize: '8px' }} />
Guardando cambios...
</span>
) : (
<span className="text-success" style={{ fontSize: '0.8rem' }}>
Cambios guardados
</span>
)}
</div>
<Form.Check <Form.Check
type="switch" type="switch"
disabled={isReadOnly} disabled={isReadOnly}