mirror of
https://github.com/timvisee/send.git
synced 2025-10-05 02:19:26 +02:00
Begin implementing a reporting mechanism
This commit is contained in:
parent
ccbcb69666
commit
9891d1f0ba
37 changed files with 762 additions and 183 deletions
|
@ -1,5 +1,6 @@
|
|||
import FileSender from './fileSender';
|
||||
import FileReceiver from './fileReceiver';
|
||||
import { reportLink } from './api';
|
||||
import { copyToClipboard, delay, openLinksInNewTab, percent } from './utils';
|
||||
import * as metrics from './metrics';
|
||||
import { bytes, locale } from './utils';
|
||||
|
@ -306,6 +307,26 @@ export default function(state, emitter) {
|
|||
render();
|
||||
});
|
||||
|
||||
emitter.on('report', async ({ reason }) => {
|
||||
try {
|
||||
const file = state.fileInfo;
|
||||
if (!file) {
|
||||
// TODO
|
||||
emitter.emit('pushState', '/error');
|
||||
return render();
|
||||
}
|
||||
await reportLink(file.id, file.secretKey, reason);
|
||||
render();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
if (err.message === '404') {
|
||||
state.fileInfo = { reported: true };
|
||||
return render();
|
||||
}
|
||||
emitter.emit('pushState', '/error');
|
||||
}
|
||||
});
|
||||
|
||||
setInterval(() => {
|
||||
// poll for updates of the upload list
|
||||
if (!state.modal && state.route === '/') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue