Compare commits
2 commits
a3c877e032
...
38045a3c50
| Author | SHA1 | Date | |
|---|---|---|---|
| 38045a3c50 | |||
| 7c260b3fa1 |
2 changed files with 35 additions and 18 deletions
|
|
@ -159,14 +159,23 @@ const postizHeaders = (key, url) => {
|
||||||
|
|
||||||
// Older builds defaulted to a maintainer-hosted Postiz instance and persisted
|
// Older builds defaulted to a maintainer-hosted Postiz instance and persisted
|
||||||
// it to localStorage on mount, so an upgrade could silently keep sending a
|
// it to localStorage on mount, so an upgrade could silently keep sending a
|
||||||
// user's API key to someone else's server. Recognize that retired default and
|
// user's API key to a server they never chose. Retire that one legacy value
|
||||||
// treat it as unset. The host is assembled from parts so no live reference to
|
// ONCE (guarded by a marker) instead of on every read: blanking it on each load
|
||||||
// it remains in the source.
|
// also threw away a URL the user deliberately saved — a self-hoster's own
|
||||||
|
// instance can legitimately live on that host — and forced them to retype it
|
||||||
|
// every session. The host is assembled from parts so no live reference to it
|
||||||
|
// remains in the source.
|
||||||
const RETIRED_POSTIZ_HOST = ['postiz', 'pbento', 'pt'].join('.');
|
const RETIRED_POSTIZ_HOST = ['postiz', 'pbento', 'pt'].join('.');
|
||||||
|
const POSTIZ_URL_RETIRED_KEY = 'postiz_url_retired_v1';
|
||||||
const normalizeStoredPostizUrl = (url) => {
|
const normalizeStoredPostizUrl = (url) => {
|
||||||
const base = String(url || '').trim().replace(/\/$/, '');
|
const base = String(url || '').trim().replace(/\/$/, '');
|
||||||
if (!base) return '';
|
if (!base) return '';
|
||||||
return base === `https://${RETIRED_POSTIZ_HOST}` ? '' : base;
|
let retired = false;
|
||||||
|
try {
|
||||||
|
retired = localStorage.getItem(POSTIZ_URL_RETIRED_KEY) === '1';
|
||||||
|
localStorage.setItem(POSTIZ_URL_RETIRED_KEY, '1');
|
||||||
|
} catch (_) { /* storage unavailable: nothing to migrate */ }
|
||||||
|
return !retired && base === `https://${RETIRED_POSTIZ_HOST}` ? '' : base;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SESSION_KEY = 'clipwright_session';
|
const SESSION_KEY = 'clipwright_session';
|
||||||
|
|
|
||||||
|
|
@ -26,17 +26,26 @@ const PlatformIcon = ({ identifier, size = 16 }) => {
|
||||||
return <Share2 size={size} />;
|
return <Share2 size={size} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
// DD/MM/YYYY + HH:MM parsed into a local Date, with explicit range checks so
|
// Today as YYYY-MM-DD in the user's own timezone, for the date input's `min`.
|
||||||
// 31/02/2026 is rejected instead of silently rolling over to March.
|
// Built from local parts (not toISOString, which would shift the day across the
|
||||||
|
// UTC boundary for users west of Greenwich).
|
||||||
|
function todayInputValue() {
|
||||||
|
const n = new Date();
|
||||||
|
return `${n.getFullYear()}-${String(n.getMonth() + 1).padStart(2, '0')}-${String(n.getDate()).padStart(2, '0')}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// YYYY-MM-DD (a native date picker's value) + HH:MM parsed into a local Date,
|
||||||
|
// with explicit range checks so 2026-02-31 is rejected instead of silently
|
||||||
|
// rolling over to March.
|
||||||
function parseSchedule(dateStr, timeStr) {
|
function parseSchedule(dateStr, timeStr) {
|
||||||
const d = String(dateStr || '').trim();
|
const d = String(dateStr || '').trim();
|
||||||
const t = String(timeStr || '').trim();
|
const t = String(timeStr || '').trim();
|
||||||
if (!d || !t) return { error: 'Enter both a date (dd/mm/yyyy) and a time.' };
|
if (!d || !t) return { error: 'Pick a date and a time.' };
|
||||||
const dm = d.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
const dm = d.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
||||||
if (!dm) return { error: 'Date must be in dd/mm/yyyy format.' };
|
if (!dm) return { error: 'Date must be in yyyy-mm-dd format.' };
|
||||||
const day = Number(dm[1]);
|
const year = Number(dm[1]);
|
||||||
const month = Number(dm[2]);
|
const month = Number(dm[2]);
|
||||||
const year = Number(dm[3]);
|
const day = Number(dm[3]);
|
||||||
if (month < 1 || month > 12) return { error: 'Month must be between 01 and 12.' };
|
if (month < 1 || month > 12) return { error: 'Month must be between 01 and 12.' };
|
||||||
if (day < 1 || day > 31) return { error: 'Day must be between 01 and 31.' };
|
if (day < 1 || day > 31) return { error: 'Day must be between 01 and 31.' };
|
||||||
const tm = t.match(/^(\d{1,2}):(\d{2})$/);
|
const tm = t.match(/^(\d{1,2}):(\d{2})$/);
|
||||||
|
|
@ -1048,7 +1057,7 @@ export default function ResultCard({ clip, index, jobId, postizKey, postizUrl, g
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Scheduling — dd/mm/yyyy + HH:MM */}
|
{/* Scheduling — native date picker + HH:MM */}
|
||||||
<div className="p-3 bg-paper rounded-input border border-rule">
|
<div className="p-3 bg-paper rounded-input border border-rule">
|
||||||
<label className="flex items-center justify-between cursor-pointer">
|
<label className="flex items-center justify-between cursor-pointer">
|
||||||
<span className="flex items-center gap-2 text-sm text-ink2 lowercase">
|
<span className="flex items-center gap-2 text-sm text-ink2 lowercase">
|
||||||
|
|
@ -1067,13 +1076,12 @@ export default function ResultCard({ clip, index, jobId, postizKey, postizUrl, g
|
||||||
<label className="eyebrow block mb-1.5">DATE · TIME</label>
|
<label className="eyebrow block mb-1.5">DATE · TIME</label>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="date"
|
||||||
inputMode="numeric"
|
|
||||||
value={scheduleDate}
|
value={scheduleDate}
|
||||||
onChange={(e) => setScheduleDate(e.target.value)}
|
onChange={(e) => setScheduleDate(e.target.value)}
|
||||||
placeholder="dd/mm/yyyy"
|
min={todayInputValue()}
|
||||||
aria-label="date (dd/mm/yyyy)"
|
aria-label="date"
|
||||||
className="input-field flex-1"
|
className="input-field flex-1 [color-scheme:dark]"
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
type="time"
|
type="time"
|
||||||
|
|
@ -1083,7 +1091,7 @@ export default function ResultCard({ clip, index, jobId, postizKey, postizUrl, g
|
||||||
className="input-field w-[7.5rem] [color-scheme:dark]"
|
className="input-field w-[7.5rem] [color-scheme:dark]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-muted mt-1.5">e.g. 31/12/2026 at 18:30</p>
|
<p className="text-xs text-muted mt-1.5">pick a day and a time, in your local timezone</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue