@glissandoo/lib 1.1.10 → 1.1.11

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.
@@ -25,6 +25,7 @@ export declare enum AppScenes {
25
25
  EditProfileDescription = "EditProfileDescription",
26
26
  EditProfileLanguage = "EditProfileLanguage",
27
27
  CommunicationList = "communications",
28
+ CommunicationNewComment = "communicationNewComment",
28
29
  Communication = "communication",
29
30
  EventList = "events",
30
31
  Event = "event",
@@ -29,6 +29,7 @@ var AppScenes;
29
29
  AppScenes["EditProfileDescription"] = "EditProfileDescription";
30
30
  AppScenes["EditProfileLanguage"] = "EditProfileLanguage";
31
31
  AppScenes["CommunicationList"] = "communications";
32
+ AppScenes["CommunicationNewComment"] = "communicationNewComment";
32
33
  AppScenes["Communication"] = "communication";
33
34
  AppScenes["EventList"] = "events";
34
35
  AppScenes["Event"] = "event";
@@ -32,8 +32,9 @@ export default class Communication extends Model<CommunicationData> {
32
32
  get editedAt(): FirebaseFirestore.Timestamp | null;
33
33
  /** @deprecated use reactions */
34
34
  get totalClaps(): number;
35
- get reactions(): Record<string, string[]>;
35
+ get reactions(): [string, string[]][];
36
36
  get totalViews(): number;
37
37
  get isServer(): boolean;
38
38
  getRecipient: (userId: string) => import("./types").CommunicationRecipientData | null;
39
+ getReactionsOrdered(maxItems?: number): [string, [string, string[]]][];
39
40
  }
@@ -92,9 +92,10 @@ class Communication extends Model_1.default {
92
92
  .reduce((acc, current) => acc + current, 0);
93
93
  }
94
94
  get reactions() {
95
- return this.listRecipients.reduce((acc, { reaction, id }) => (Object.assign(Object.assign({}, acc), (reaction && {
95
+ const array = this.listRecipients.reduce((acc, { reaction, id }) => (Object.assign(Object.assign({}, acc), (reaction && {
96
96
  [reaction]: reaction in acc ? [...acc[reaction], id] : [id],
97
97
  }))), {});
98
+ return lodash_1.sortBy(Object.entries(array), [(e) => e[1].length]);
98
99
  }
99
100
  get totalViews() {
100
101
  return this.listRecipients
@@ -104,5 +105,9 @@ class Communication extends Model_1.default {
104
105
  get isServer() {
105
106
  return this.data.server === true;
106
107
  }
108
+ getReactionsOrdered(maxItems) {
109
+ const array = lodash_1.sortBy(Object.entries(this.reactions), [(e) => e[1].length]).reverse();
110
+ return maxItems ? array.slice(0, maxItems) : array;
111
+ }
107
112
  }
108
113
  exports.default = Communication;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",