D1, seconda parte: «Cosa scaricare prima» anche per account, reel distinti e quota per chi aspetta
L'ordine dei tipi (storie, evidenza, post, reel, taggati) ora vale anche per il singolo account: nella scheda account → Impostazioni si sceglie «Come le impostazioni generali» o un ordine suo, con lo stesso elenco da trascinare (o Su/Giù da tastiera) di Limiti e comportamento, ora un modulo solo (download-order.js). Il motore pesa le visite con l'ordine dell'account, la coda dei file mette ogni file al posto del suo tipo nell'ordine del suo account, stabile dentro il tipo (scadenza, scoperta, elemento, posizione). Perché nessun tipo resti fermo per sempre quando il tetto dei dati finisce prima della coda, un posto su otto di ogni giro della coda va al file che aspetta da più tempo, di qualunque tipo. I reel non si inventano (regola 9): un post è reel se viene dalla scheda Reel o se la risposta ha product_type «clips», valore visto nei campioni ripuliti. Il segno si scrive da solo e non si toglie mai, così una copia vecchia non sposta di nuovo i file in coda. Migrazione 0002_ordine_scaricamento (account.download_order, entry.is_reel): prende il primo numero dopo quelle unite, E1 userà il successivo. Prove su motore (seme fisso), coda, lettori, ricette e API; dimostrazione con un account che ha l'ordine suo; guida e decisioni aggiornate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d6c0ef851d
commit
0547c747c5
40 files changed
+775
-158
No files matched your search
@@ -9,11 +9,10 @@ import { h, icon, fill } from '../core/dom.js';
|
||||
import { refreshEngine } from '../core/engine.js';
|
||||
import { t, list, number, decimal } from '../core/text.js';
|
||||
import { checkbox, confirmDialog, label, showError, toast, toggle } from '../core/ui.js';
|
||||
import { DEFAULT_ORDER, orderEditor, orderOrDefault } from './download-order.js';
|
||||
import { guardChanges, heading } from './settings.js';
|
||||
|
||||
const PACES = ['slow', 'natural', 'brisk'];
|
||||
// «Cosa scaricare prima» (spec §7.2): the default order of the kinds, the one the server also uses.
|
||||
const DEFAULT_ORDER = ['storie', 'evidenza', 'post', 'reel', 'taggati'];
|
||||
const DAY_ORDER = [1, 2, 3, 4, 5, 6, 0]; // Monday first; the API counts from Sunday = 0
|
||||
|
||||
export default async function limits(page, box) {
|
||||
@@ -34,73 +33,20 @@ export default async function limits(page, box) {
|
||||
gradualStart: d.gradualStart,
|
||||
activeDays: new Set(d.activeDays),
|
||||
jitterOn: d.current.jitterMinutes > 0,
|
||||
order: Array.isArray(d.downloadOrder) && d.downloadOrder.length ? [...d.downloadOrder] : [...DEFAULT_ORDER],
|
||||
order: orderOrDefault(d.downloadOrder),
|
||||
};
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------- download order
|
||||
// The rows move by dragging (mouse) or with «Su» and «Giù» (keyboard); the order is saved with the save bar.
|
||||
const orderList = h('ol.ordine-tipi', { 'aria-label': t('impostazioni.limiti.ordine') });
|
||||
const orderStatus = h('span.vh', { 'aria-live': 'polite' });
|
||||
let dragged = null;
|
||||
|
||||
function move(from, to, focus) {
|
||||
if (to < 0 || to >= form.order.length || from === to) return;
|
||||
const [kind] = form.order.splice(from, 1);
|
||||
form.order.splice(to, 0, kind);
|
||||
drawOrder();
|
||||
drawSaveBar();
|
||||
orderStatus.textContent = t('impostazioni.limiti.ordineSpostato', { tipo: t(`impostazioni.limiti.tipi.${kind}`), n: to + 1 });
|
||||
if (focus) {
|
||||
const again = orderList.querySelector(`[data-tipo="${kind}"] [data-verso="${focus}"]`);
|
||||
if (again && !again.disabled) again.focus();
|
||||
else orderList.querySelector(`[data-tipo="${kind}"] button:not([disabled])`)?.focus();
|
||||
}
|
||||
}
|
||||
|
||||
function drawOrder() {
|
||||
fill(orderList, form.order.map((kind, i) => {
|
||||
const name = t(`impostazioni.limiti.tipi.${kind}`);
|
||||
const row = h('li.riga-ordine', { draggable: 'true', dataset: { tipo: kind } },
|
||||
h('span.maniglia', { title: t('impostazioni.limiti.ordineManiglia'), 'aria-hidden': 'true' }, icon('grip-vertical', 's')),
|
||||
h('span.posizione.dati', String(i + 1)),
|
||||
h('b', name),
|
||||
kind === 'storie' && i > 0 ? h('span.muto.piccolo', icon('clock', 'xs'), ' ', t('impostazioni.limiti.ordineStorie')) : null,
|
||||
h('div.destra',
|
||||
h('button.btn.piccolo.nudo', {
|
||||
type: 'button', disabled: i === 0, dataset: { verso: 'su' }, 'aria-label': t('impostazioni.limiti.ordineSuDi', { tipo: name }), onclick: () => move(i, i - 1, 'su'),
|
||||
}, icon('chevron-up', 's'), h('span.testo-btn', t('impostazioni.limiti.ordineSu'))),
|
||||
h('button.btn.piccolo.nudo', {
|
||||
type: 'button', disabled: i === form.order.length - 1, dataset: { verso: 'giu' }, 'aria-label': t('impostazioni.limiti.ordineGiuDi', { tipo: name }), onclick: () => move(i, i + 1, 'giu'),
|
||||
}, icon('chevron-down', 's'), h('span.testo-btn', t('impostazioni.limiti.ordineGiu')))));
|
||||
row.addEventListener('dragstart', (event) => {
|
||||
dragged = i;
|
||||
row.classList.add('trascinata');
|
||||
try {
|
||||
event.dataTransfer.effectAllowed = 'move';
|
||||
event.dataTransfer.setData('text/plain', kind);
|
||||
} catch {
|
||||
// Some browsers refuse data on a drag: the index above is enough.
|
||||
}
|
||||
});
|
||||
row.addEventListener('dragend', () => {
|
||||
dragged = null;
|
||||
row.classList.remove('trascinata');
|
||||
});
|
||||
row.addEventListener('dragover', (event) => {
|
||||
if (dragged === null) return;
|
||||
event.preventDefault();
|
||||
});
|
||||
row.addEventListener('drop', (event) => {
|
||||
if (dragged === null) return;
|
||||
event.preventDefault();
|
||||
const from = dragged;
|
||||
dragged = null;
|
||||
move(from, i, null);
|
||||
});
|
||||
return row;
|
||||
}));
|
||||
}
|
||||
// The rows move by dragging or with «Su» and «Giù» (download-order.js); the order is saved with the save bar.
|
||||
const order = orderEditor({
|
||||
read: () => form.order,
|
||||
write: (next) => { form.order = next; },
|
||||
changed: () => drawSaveBar(),
|
||||
});
|
||||
const orderList = order.list;
|
||||
const orderStatus = order.status;
|
||||
const drawOrder = order.draw;
|
||||
|
||||
const orderReset = h('button.btn.collegamento', {
|
||||
type: 'button',
|
||||
|
||||
Reference in new issue
Block a user