(socket:any, {data: {granularity, start, requestID}}: ChangesetRequest)
| 1528 | * Handles a request for a rough changeset, the timeslider client needs it |
| 1529 | */ |
| 1530 | const handleChangesetRequest = async (socket:any, {data: {granularity, start, requestID}}: ChangesetRequest) => { |
| 1531 | if (granularity == null) throw new Error('missing granularity'); |
| 1532 | if (!Number.isInteger(granularity)) throw new Error('granularity is not an integer'); |
| 1533 | if (start == null) throw new Error('missing start'); |
| 1534 | start = checkValidRev(start); |
| 1535 | if (requestID == null) throw new Error('mising requestID'); |
| 1536 | const end = start + (100 * granularity); |
| 1537 | const {padId, author: authorId} = sessioninfos[socket.id]; |
| 1538 | const pad = await padManager.getPad(padId, null, authorId); |
| 1539 | const headRev = pad.getHeadRevisionNumber(); |
| 1540 | if (start > headRev) |
| 1541 | start = headRev; |
| 1542 | const data:MapArrayType<any> = await getChangesetInfo(pad, start, end, granularity); |
| 1543 | data.requestID = requestID; |
| 1544 | socket.emit('message', {type: 'CHANGESET_REQ', data}); |
| 1545 | }; |
| 1546 | |
| 1547 | /** |
| 1548 | * Tries to rebuild the getChangestInfo function of the original Etherpad |
no test coverage detected