polfan-server-js-client 0.2.39 → 0.2.41

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": "polfan-server-js-client",
3
- "version": "0.2.39",
3
+ "version": "0.2.41",
4
4
  "description": "JavaScript client library for handling communication with Polfan chat server.",
5
5
  "author": "Jarosław Żak",
6
6
  "license": "MIT",
@@ -14,10 +14,11 @@ export class FilesClient extends AbstractRestClient {
14
14
  protected defaultUrl: string = 'https://files.devana.pl';
15
15
 
16
16
  public async uploadFile(file: globalThis.File | Blob): Promise<RestClientResponse<File>> {
17
+ const name = encodeURIComponent((file as globalThis.File).name ?? '');
17
18
  let headers = {
18
19
  ...this.getAuthHeaders(),
19
20
  Accept: 'application/json',
20
- 'Content-Disposition': `attachment; filename="${(file as globalThis.File).name ?? ''}"`,
21
+ 'Content-Disposition': `attachment; filename="${name}"`,
21
22
  'Content-Length': file.size
22
23
  };
23
24
 
@@ -21,18 +21,20 @@ export class EmoticonsManager {
21
21
  }
22
22
 
23
23
  public async get(spaceId?: string): Promise<ObservableIndexedObjectCollection<Emoticon>> {
24
- if (this.emoticonsPromises.notExist(spaceId)) {
24
+ const key = spaceId ?? GLOBAL_KEY;
25
+
26
+ if (this.emoticonsPromises.notExist(key)) {
25
27
  this.emoticonsPromises.registerByFunction(async () => {
26
28
  const result = await this.tracker.client.send('GetEmoticons', {spaceId});
27
29
  if (result.error) {
28
30
  throw result.error;
29
31
  }
30
32
  this.handleEmoticons(result.data);
31
- }, spaceId ?? GLOBAL_KEY);
33
+ }, key);
32
34
  }
33
35
 
34
- await this.emoticonsPromises.get(spaceId);
35
- return this.list.get(spaceId);
36
+ await this.emoticonsPromises.get(key);
37
+ return this.list.get(key);
36
38
  }
37
39
 
38
40
  private handleEmoticons(event: Emoticons): void {