@glissandoo/lib 1.1.9 → 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.
package/helpers/appScenes.d.ts
CHANGED
|
@@ -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",
|
package/helpers/appScenes.js
CHANGED
|
@@ -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";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DocumentReference, DocumentSnapshot } from '@google-cloud/firestore';
|
|
2
2
|
import { LanguagesTypes } from '../../lang';
|
|
3
3
|
import Model from '../Model';
|
|
4
|
-
import { CommunicationData,
|
|
4
|
+
import { CommunicationData, CommunicationType } from './types';
|
|
5
5
|
export default class Communication extends Model<CommunicationData> {
|
|
6
6
|
protected lang: LanguagesTypes;
|
|
7
7
|
constructor(doc: DocumentSnapshot, lang?: LanguagesTypes);
|
|
@@ -11,7 +11,7 @@ export default class Communication extends Model<CommunicationData> {
|
|
|
11
11
|
get promoterInfo(): import("../Group/types").GroupTinyData;
|
|
12
12
|
get owner(): DocumentReference;
|
|
13
13
|
get ownerInfo(): import("../User/types").UserTinyData | import("../Group/types").GroupTinyData;
|
|
14
|
-
get
|
|
14
|
+
get blockAnswers(): boolean;
|
|
15
15
|
get templateId(): string | null;
|
|
16
16
|
get recipients(): string[];
|
|
17
17
|
get recipientsInfo(): Record<string, import("./types").CommunicationRecipientData>;
|
|
@@ -29,23 +29,12 @@ export default class Communication extends Model<CommunicationData> {
|
|
|
29
29
|
get isActive(): boolean;
|
|
30
30
|
get plainText(): string;
|
|
31
31
|
get createdAt(): FirebaseFirestore.Timestamp;
|
|
32
|
-
get createdToNow(): string;
|
|
33
|
-
get thumbnailType(): CommunicationThumbnailType | null;
|
|
34
|
-
get isThumbnailAvatar(): boolean;
|
|
35
|
-
get isThumbnailImage(): boolean;
|
|
36
|
-
get thumbnailURL(): string | null;
|
|
37
|
-
get avatar(): (import("../User/types").UserTinyData & {
|
|
38
|
-
id: string;
|
|
39
|
-
}) | null;
|
|
40
|
-
get thumbnail(): {
|
|
41
|
-
url: string;
|
|
42
|
-
alt: string;
|
|
43
|
-
};
|
|
44
32
|
get editedAt(): FirebaseFirestore.Timestamp | null;
|
|
45
33
|
/** @deprecated use reactions */
|
|
46
34
|
get totalClaps(): number;
|
|
47
|
-
get reactions():
|
|
35
|
+
get reactions(): [string, string[]][];
|
|
48
36
|
get totalViews(): number;
|
|
49
37
|
get isServer(): boolean;
|
|
50
38
|
getRecipient: (userId: string) => import("./types").CommunicationRecipientData | null;
|
|
39
|
+
getReactionsOrdered(maxItems?: number): [string, [string, string[]]][];
|
|
51
40
|
}
|
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const date_fns_1 = require("date-fns");
|
|
7
6
|
const lodash_1 = require("lodash");
|
|
8
7
|
const utils_1 = require("../../helpers/utils");
|
|
9
8
|
const lang_1 = require("../../lang");
|
|
@@ -35,8 +34,8 @@ class Communication extends Model_1.default {
|
|
|
35
34
|
get ownerInfo() {
|
|
36
35
|
return this.data.ownerInfo;
|
|
37
36
|
}
|
|
38
|
-
get
|
|
39
|
-
return this.data.
|
|
37
|
+
get blockAnswers() {
|
|
38
|
+
return this.data.blockAnswers || false;
|
|
40
39
|
}
|
|
41
40
|
get templateId() {
|
|
42
41
|
return this.data.templateId || null;
|
|
@@ -83,47 +82,6 @@ class Communication extends Model_1.default {
|
|
|
83
82
|
get createdAt() {
|
|
84
83
|
return this.data.createdAt;
|
|
85
84
|
}
|
|
86
|
-
get createdToNow() {
|
|
87
|
-
const dateLang = lang_1.getDateLang(this.lang);
|
|
88
|
-
// @ÑAPA
|
|
89
|
-
const text = date_fns_1.formatDistanceToNow(this.createdAt.toDate(), { locale: dateLang.locale })
|
|
90
|
-
.replace('alrededor de', 'hace')
|
|
91
|
-
.replace('arredor de', 'fa');
|
|
92
|
-
return text;
|
|
93
|
-
}
|
|
94
|
-
get thumbnailType() {
|
|
95
|
-
return this.data.thumbnailType || null;
|
|
96
|
-
}
|
|
97
|
-
get isThumbnailAvatar() {
|
|
98
|
-
return this.thumbnailType === types_1.CommunicationThumbnailType.Avatar;
|
|
99
|
-
}
|
|
100
|
-
get isThumbnailImage() {
|
|
101
|
-
return this.thumbnailType === types_1.CommunicationThumbnailType.Image;
|
|
102
|
-
}
|
|
103
|
-
get thumbnailURL() {
|
|
104
|
-
return this.data.thumbnailURL || null;
|
|
105
|
-
}
|
|
106
|
-
get avatar() {
|
|
107
|
-
return this.data.avatar || null;
|
|
108
|
-
}
|
|
109
|
-
get thumbnail() {
|
|
110
|
-
if (this.isThumbnailAvatar && this.avatar) {
|
|
111
|
-
return {
|
|
112
|
-
url: this.avatar.photoURL,
|
|
113
|
-
alt: this.avatar.displayName,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
if (this.isThumbnailImage && this.thumbnailURL) {
|
|
117
|
-
return {
|
|
118
|
-
url: this.thumbnailURL,
|
|
119
|
-
alt: '',
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
url: this.promoterInfo.photoURL,
|
|
124
|
-
alt: this.promoterInfo.displayName,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
85
|
get editedAt() {
|
|
128
86
|
return this.data.editedAt || null;
|
|
129
87
|
}
|
|
@@ -134,9 +92,10 @@ class Communication extends Model_1.default {
|
|
|
134
92
|
.reduce((acc, current) => acc + current, 0);
|
|
135
93
|
}
|
|
136
94
|
get reactions() {
|
|
137
|
-
|
|
95
|
+
const array = this.listRecipients.reduce((acc, { reaction, id }) => (Object.assign(Object.assign({}, acc), (reaction && {
|
|
138
96
|
[reaction]: reaction in acc ? [...acc[reaction], id] : [id],
|
|
139
97
|
}))), {});
|
|
98
|
+
return lodash_1.sortBy(Object.entries(array), [(e) => e[1].length]);
|
|
140
99
|
}
|
|
141
100
|
get totalViews() {
|
|
142
101
|
return this.listRecipients
|
|
@@ -146,5 +105,9 @@ class Communication extends Model_1.default {
|
|
|
146
105
|
get isServer() {
|
|
147
106
|
return this.data.server === true;
|
|
148
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
|
+
}
|
|
149
112
|
}
|
|
150
113
|
exports.default = Communication;
|
|
@@ -6,10 +6,6 @@ export declare enum CommunicationType {
|
|
|
6
6
|
Private = "user",
|
|
7
7
|
Public = "group"
|
|
8
8
|
}
|
|
9
|
-
export declare enum CommunicationThumbnailType {
|
|
10
|
-
Avatar = "avatar",
|
|
11
|
-
Image = "image"
|
|
12
|
-
}
|
|
13
9
|
export declare enum CommunicationReactions {
|
|
14
10
|
OK = "\uD83D\uDC4D",
|
|
15
11
|
Claps = "\uD83D\uDC4F",
|
|
@@ -50,23 +46,18 @@ export interface CommunicationRecipientData {
|
|
|
50
46
|
export interface CommunicationData {
|
|
51
47
|
title: string;
|
|
52
48
|
message: Node[];
|
|
53
|
-
promoter: DocumentReference;
|
|
54
|
-
promoterInfo: GroupTinyData;
|
|
55
49
|
type: CommunicationType;
|
|
56
|
-
|
|
50
|
+
readonly promoter: DocumentReference;
|
|
51
|
+
promoterInfo: GroupTinyData;
|
|
52
|
+
readonly owner: DocumentReference;
|
|
57
53
|
ownerInfo: GroupTinyData | UserTinyData;
|
|
58
|
-
|
|
54
|
+
blockAnswers: boolean;
|
|
59
55
|
attachmentsPath: string[];
|
|
60
56
|
imagesPath: string[];
|
|
61
57
|
templateId: string | null;
|
|
62
58
|
recipients: string[];
|
|
63
59
|
recipientsInfo: Record<string, CommunicationRecipientData>;
|
|
64
|
-
thumbnailType: CommunicationThumbnailType | null;
|
|
65
|
-
thumbnailURL: string | null;
|
|
66
60
|
commentsCount: number;
|
|
67
|
-
avatar: (UserTinyData & {
|
|
68
|
-
id: string;
|
|
69
|
-
}) | null;
|
|
70
61
|
deletedAt: Timestamp | null;
|
|
71
62
|
editedAt: Timestamp | null;
|
|
72
63
|
readonly server: boolean;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommunicationReactions = exports.
|
|
3
|
+
exports.CommunicationReactions = exports.CommunicationType = void 0;
|
|
4
4
|
var CommunicationType;
|
|
5
5
|
(function (CommunicationType) {
|
|
6
6
|
CommunicationType["Private"] = "user";
|
|
7
7
|
CommunicationType["Public"] = "group";
|
|
8
8
|
})(CommunicationType = exports.CommunicationType || (exports.CommunicationType = {}));
|
|
9
|
-
var CommunicationThumbnailType;
|
|
10
|
-
(function (CommunicationThumbnailType) {
|
|
11
|
-
CommunicationThumbnailType["Avatar"] = "avatar";
|
|
12
|
-
CommunicationThumbnailType["Image"] = "image";
|
|
13
|
-
})(CommunicationThumbnailType = exports.CommunicationThumbnailType || (exports.CommunicationThumbnailType = {}));
|
|
14
9
|
var CommunicationReactions;
|
|
15
10
|
(function (CommunicationReactions) {
|
|
16
11
|
CommunicationReactions["OK"] = "\uD83D\uDC4D";
|