Fix calendar drag snap-back, IG filter, and default to 2026.
Prefer the latest year in the archive, normalize Instagram casing so stories show under IG/FB, sync pipeline dates on move, and stop stale plan re-renders from undoing a successful drag. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -156,9 +156,9 @@ export default function RrssArchiveYear({
|
||||
const byMonth = new Map(plans.map((p) => [p.month, p]));
|
||||
const years = Array.from(
|
||||
new Set(plans.map((p) => Number(p.month.slice(0, 4))).filter(Boolean))
|
||||
).sort();
|
||||
).sort((a, b) => b - a);
|
||||
if (!years.includes(year)) years.push(year);
|
||||
years.sort();
|
||||
years.sort((a, b) => b - a);
|
||||
const legend = plans[0]?.legend || [
|
||||
{ label: 'Educativo / serie', color: '#2071cf' },
|
||||
{ label: 'Familia / bienestar', color: '#E08E2E' },
|
||||
|
||||
@@ -179,9 +179,22 @@ export default function RrssMonthView({
|
||||
const draggingId = React.useRef<string | null>(null);
|
||||
const suppressClick = React.useRef(false);
|
||||
|
||||
// Only re-hydrate from server when the month or piece dates actually change.
|
||||
// Avoids snapping a successful drag back if the parent re-renders with a
|
||||
// stale plan object (common on older month views after soft navigation).
|
||||
const serverSig = useMemo(
|
||||
() =>
|
||||
`${plan.month}:${(plan.pieces || [])
|
||||
.map((p) => `${p.id}@${String(p.date || '').slice(0, 10)}`)
|
||||
.join(',')}`,
|
||||
[plan.month, plan.pieces]
|
||||
);
|
||||
const lastServerSig = React.useRef('');
|
||||
useEffect(() => {
|
||||
if (serverSig === lastServerSig.current) return;
|
||||
lastServerSig.current = serverSig;
|
||||
setLivePieces(plan.pieces || []);
|
||||
}, [plan]);
|
||||
}, [serverSig, plan.pieces]);
|
||||
|
||||
const pieces = livePieces;
|
||||
|
||||
@@ -192,10 +205,11 @@ export default function RrssMonthView({
|
||||
|
||||
const filtered = pieces.filter((p) => {
|
||||
if (platform === 'all') return true;
|
||||
const pl = String(p.platform || '').toLowerCase();
|
||||
if (platform === 'instagram') {
|
||||
return p.platform === 'instagram' || p.platform === 'facebook';
|
||||
return pl === 'instagram' || pl === 'facebook';
|
||||
}
|
||||
return p.platform === platform;
|
||||
return pl === platform;
|
||||
});
|
||||
|
||||
const ids = pieces.map((p) => p.id);
|
||||
@@ -641,16 +655,21 @@ export default function RrssMonthView({
|
||||
}
|
||||
}}
|
||||
onClick={() => openDay(key, dayPieces[0])}
|
||||
className={`min-h-[112px] rounded-lg border bg-white p-1.5 text-left cursor-pointer overflow-hidden ${
|
||||
className={`min-h-[128px] rounded-lg border bg-white p-1.5 text-left cursor-pointer ${
|
||||
over
|
||||
? 'border-brand-500 ring-2 ring-brand-200 bg-brand-50/40'
|
||||
: 'border-gray-200 hover:border-brand-400 hover:shadow-sm'
|
||||
}`}
|
||||
>
|
||||
<p className="text-[13px] font-bold text-gray-900 mb-1 tabular-nums">
|
||||
{day}
|
||||
<p className="text-[13px] font-bold text-gray-900 mb-1 tabular-nums flex items-center justify-between gap-1">
|
||||
<span>{day}</span>
|
||||
{dayPieces.length > 1 ? (
|
||||
<span className="text-[10px] font-semibold text-gray-500">
|
||||
{dayPieces.length}
|
||||
</span>
|
||||
) : null}
|
||||
</p>
|
||||
<div className="space-y-1">
|
||||
<div className="space-y-1 max-h-[140px] overflow-y-auto">
|
||||
{dayPieces.map((p) => {
|
||||
const tone = chipTone(p);
|
||||
const kind =
|
||||
|
||||
Reference in New Issue
Block a user