@social-mail/social-mail-client 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-client",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -31,7 +31,7 @@ export type UploadedFiles = CustomEvent<{ files: IUploadedFile[], extra: any}>;
31
31
 
32
32
  styled.css `
33
33
  display: inline-grid;
34
- grid-template-rows: auto auto;
34
+ grid-template-rows: auto auto auto;
35
35
 
36
36
  & > [data-element=file-name] {
37
37
  grid-row: 1;
@@ -40,15 +40,20 @@ export type UploadedFiles = CustomEvent<{ files: IUploadedFile[], extra: any}>;
40
40
  text-overflow: ellipsis;
41
41
  }
42
42
 
43
- & > [data-element=progress] {
43
+ & > progress {
44
44
  grid-row: 2;
45
45
  width: 100%;
46
46
  }
47
+ & > [data-element=error] {
48
+ grid-row: 3;
49
+ width: 100%;
50
+ }
47
51
 
48
52
  `.installGlobal("[data-attachment-file]");
49
53
 
50
54
  export interface IFileUpload {
51
55
  name: string;
56
+ error?: string;
52
57
  progress?: number;
53
58
  promise?: Promise<{ appFileID }>
54
59
  }
@@ -164,23 +169,38 @@ export default class LocalFileService extends TaskManager {
164
169
  const upload = {
165
170
  total: 0,
166
171
  tasks,
167
- progress:0
172
+ progress:0,
173
+ error: "",
168
174
  };
169
175
  for (const file of files) {
170
176
  upload.total += file.size;
171
177
  const uploadFile: IFileUpload = {
172
178
  name: file.name,
179
+ error: "",
173
180
  progress: 0
174
181
  };
175
182
  uploadFile.promise = this.run(async () => {
176
- uploadFile.progress = 0.01;
177
-
178
- // we will check if file exists and has same sha256?
179
-
180
- const r = await this.uploadFile(file, extra, ct, (n) => uploadFile.progress = n);
181
- upload.progress += r.file.size;
182
- setTimeout(() => tasks.remove(uploadFile), 500);
183
- return r;
183
+ let lastError: string;
184
+ for(let i=0; i<3; i++) {
185
+ try {
186
+ uploadFile.progress = 0.01;
187
+
188
+ // we will check if file exists and has same sha256?
189
+
190
+ const r = await this.uploadFile(file, extra, ct, (n) => uploadFile.progress = n);
191
+ upload.progress += r.file.size;
192
+ setTimeout(() => tasks.remove(uploadFile), 500);
193
+ upload.error = "";
194
+ lastError = null;
195
+ return r;
196
+ } catch (error) {
197
+ lastError = `${file.webkitRelativePath ?? ""}/${file.name} failed to upload.\n${error.stack ?? error}`;
198
+ uploadFile.error = lastError;
199
+ }
200
+ }
201
+ if (lastError) {
202
+ upload.error += "\n" + lastError;
203
+ }
184
204
  });
185
205
  tasks.push(uploadFile);
186
206
  }
@@ -231,6 +251,10 @@ class FileUploadWindow extends PopupWindow {
231
251
  min={0}
232
252
  max={1}
233
253
  value={Bind.source(file, (x) => x.source.progress)}/>
254
+ <div
255
+ data-element="error"
256
+ data-color="red"
257
+ text={Bind.source(file, (x) => x.source.error)}/>
234
258
  </div>}
235
259
  />
236
260
  </div>);