oficina / sheets Public

Clone
git clone https://amadan.net/oficina/sheets

Plain git — no account needed to clone.

Download

Download this file

1/* Send one atomic batch per 500 cells, with chunks and invocations in order.
2 * Concurrent writes lost paints when older replies were discarded.
3 * A final refetch still raced with live edits. Serial chunks avoid both;
4 * stop on the first failed chunk. */
5(function () {
6 'use strict';
7
8 var tail = Promise.resolve();
9 window.SheetsCellQueue = function (jobs, post, done) {
10 var run = function () {
11 var i = 0;
12 function step() {
13 if (i >= jobs.length) { if (done) done(); return true; }
14 var cells = jobs.slice(i, i + 500);
15 i += cells.length;
16 return post('/cells/batch', { cells: cells }).then(function (ok) {
17 if (ok === true) return step();
18 return false;
19 }, function () { return false; });
20 }
21 return step();
22 };
23 tail = tail.then(run, run);
24 return tail;
25 };
26}());
27