@glissandoo/lib 1.1.11 → 1.2.0

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.
@@ -1,4 +1,3 @@
1
- import { MusicStyleId } from '../helpers/musicStyles';
2
1
  import { GroupBasicData, GroupData, GroupStatus } from '../models/Group/types';
3
2
  export declare namespace GroupFbFunctionsTypes {
4
3
  interface PublishParams {
@@ -6,7 +5,7 @@ export declare namespace GroupFbFunctionsTypes {
6
5
  locality: string;
7
6
  latitude: number;
8
7
  longitude: number;
9
- musicStyle: MusicStyleId;
8
+ musicStyle: string;
10
9
  photoURL: string;
11
10
  }
12
11
  interface PublishResult {
@@ -6,4 +6,5 @@ export declare enum MusicStyleId {
6
6
  Choir = "coro",
7
7
  Orchestra = "orquesta-sinfonica"
8
8
  }
9
+ export declare type MusicStyleType = MusicStyleId | string;
9
10
  export declare const list: (lang: LanguagesTypes) => MusicStyle[];
@@ -1,4 +1,4 @@
1
1
  import { InstrumentId } from '../instruments';
2
- import { MusicStyleId } from './index';
3
- export declare const getInstrumentsOrderByMusicStyle: (musicStyle: MusicStyleId) => InstrumentId[];
4
- export declare const orderByMusicStyle: <T>(list: T[], field: string, musicStyle: MusicStyleId) => T[];
2
+ import { MusicStyleType } from './index';
3
+ export declare const getInstrumentsOrderByMusicStyle: (musicStyle: MusicStyleType) => InstrumentId[];
4
+ export declare const orderByMusicStyle: <T>(list: T[], field: string, musicStyle: MusicStyleType) => T[];
@@ -117,7 +117,9 @@ const orders = {
117
117
  instruments_1.InstrumentId.DrumSet,
118
118
  ],
119
119
  };
120
- const getInstrumentsOrderByMusicStyle = (musicStyle) => musicStyle in orders ? orders[musicStyle] : Object.values(instruments_1.InstrumentId);
120
+ const getInstrumentsOrderByMusicStyle = (musicStyle) => {
121
+ return musicStyle in orders ? orders[musicStyle] : Object.values(instruments_1.InstrumentId);
122
+ };
121
123
  exports.getInstrumentsOrderByMusicStyle = getInstrumentsOrderByMusicStyle;
122
124
  const orderByMusicStyle = (list, field, musicStyle) => {
123
125
  const order = exports.getInstrumentsOrderByMusicStyle(musicStyle);
package/lang/index.d.ts CHANGED
@@ -1084,5 +1084,5 @@ export declare const getDateLang: (lang: LanguagesTypes) => {
1084
1084
  time: string;
1085
1085
  };
1086
1086
  };
1087
- export declare const getTranslation: (key: string, lang: LanguagesTypes) => string;
1087
+ export declare const getTranslation: (key: string, lang: LanguagesTypes) => string | null;
1088
1088
  export default languageProvider;
package/lang/index.js CHANGED
@@ -91,11 +91,7 @@ const getDateLang = (lang) => {
91
91
  };
92
92
  exports.getDateLang = getDateLang;
93
93
  const getTranslation = (key, lang) => {
94
- const translation = get_1.default(languageProvider, [lang, 'messages', key]);
95
- if (!translation) {
96
- return '';
97
- }
98
- return translation;
94
+ return get_1.default(languageProvider, [lang, 'messages', key]) || null;
99
95
  };
100
96
  exports.getTranslation = getTranslation;
101
97
  exports.default = languageProvider;
@@ -32,9 +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(): [string, string[]][];
35
+ get reactions(): Record<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
+ getReactionsOrdered(maxItems?: number): [string, string[]][];
40
40
  }
@@ -92,10 +92,9 @@ class Communication extends Model_1.default {
92
92
  .reduce((acc, current) => acc + current, 0);
93
93
  }
94
94
  get reactions() {
95
- const array = this.listRecipients.reduce((acc, { reaction, id }) => (Object.assign(Object.assign({}, acc), (reaction && {
95
+ return 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]);
99
98
  }
100
99
  get totalViews() {
101
100
  return this.listRecipients
@@ -36,7 +36,7 @@ class EventoBasic extends Model_1.default {
36
36
  if (this.displayName) {
37
37
  return this.displayName;
38
38
  }
39
- return lang_1.getTranslation(this.type, this.lang) || lang_1.getTranslation('event', this.lang);
39
+ return (lang_1.getTranslation(this.type, this.lang) || lang_1.getTranslation('event', this.lang) || 'event');
40
40
  }
41
41
  get type() {
42
42
  return this.data.type;
@@ -14,7 +14,7 @@ class EventoTiny {
14
14
  if (this.displayName) {
15
15
  return this.displayName;
16
16
  }
17
- return lang_1.getTranslation(this.type, this.lang) || lang_1.getTranslation('event', this.lang);
17
+ return (lang_1.getTranslation(this.type, this.lang) || lang_1.getTranslation('event', this.lang) || this.type);
18
18
  }
19
19
  get type() {
20
20
  return this.data.type;
@@ -12,6 +12,6 @@ export default class GroupBasic<D> extends Model<D & GroupBasicData> {
12
12
  get locality(): string;
13
13
  get location(): FirebaseFirestore.GeoPoint;
14
14
  get username(): string;
15
- get musicStyle(): import("../../helpers/musicStyles").MusicStyleId;
15
+ get musicStyle(): string;
16
16
  get musicStyleString(): string;
17
17
  }
@@ -45,7 +45,8 @@ class GroupBasic extends Model_1.default {
45
45
  return this.data.musicStyle;
46
46
  }
47
47
  get musicStyleString() {
48
- return lang_1.getTranslation(`musicStyles.${this.musicStyle}`, this.lang);
48
+ const translation = lang_1.getTranslation(`musicStyles.${this.musicStyle}`, this.lang);
49
+ return translation || this.musicStyle;
49
50
  }
50
51
  }
51
52
  exports.default = GroupBasic;
@@ -1,5 +1,5 @@
1
1
  import { DocumentReference, GeoPoint, Timestamp } from '@google-cloud/firestore';
2
- import { MusicStyleId } from '../../helpers/musicStyles';
2
+ import { MusicStyleType } from '../../helpers/musicStyles';
3
3
  import { PlayerBasicData } from '../Player/types';
4
4
  export declare enum GroupConfig {
5
5
  IncludesMembersToEventsWhenJoined = "includesMembersToEventsWhenJoined"
@@ -39,7 +39,7 @@ export interface GroupTinyData {
39
39
  }
40
40
  export interface GroupBasicData extends GroupTinyData {
41
41
  username: string;
42
- musicStyle: MusicStyleId;
42
+ musicStyle: MusicStyleType;
43
43
  locality: string;
44
44
  location: GeoPoint;
45
45
  }
@@ -8,7 +8,8 @@ class Instrument {
8
8
  this.lang = lang;
9
9
  }
10
10
  get name() {
11
- return lang_1.getTranslation(`instruments.${this.id}`, this.lang);
11
+ const translation = lang_1.getTranslation(`instruments.${this.id}`, this.lang);
12
+ return translation || this.id;
12
13
  }
13
14
  get icon() {
14
15
  return instruments_1.InstrumentIcons[this.id] || 'warning';
@@ -1,8 +1,8 @@
1
- import { MusicStyleId } from '../../helpers/musicStyles';
1
+ import { MusicStyleType } from '../../helpers/musicStyles';
2
2
  import { LanguagesTypes } from '../../lang';
3
3
  export default class MusicStyle {
4
- id: MusicStyleId;
4
+ id: MusicStyleType;
5
5
  private lang;
6
- constructor(id: MusicStyleId, lang?: LanguagesTypes);
6
+ constructor(id: MusicStyleType, lang?: LanguagesTypes);
7
7
  get name(): string;
8
8
  }
@@ -7,7 +7,8 @@ class MusicStyle {
7
7
  this.lang = lang;
8
8
  }
9
9
  get name() {
10
- return lang_1.getTranslation(`musicStyles.${this.id}`, this.lang);
10
+ const translation = lang_1.getTranslation(`musicStyles.${this.id}`, this.lang);
11
+ return translation || this.id;
11
12
  }
12
13
  }
13
14
  exports.default = MusicStyle;
@@ -21,7 +21,8 @@ class PlayerBasic extends basic_1.default {
21
21
  return this.data.mainInstrument;
22
22
  }
23
23
  get instrument() {
24
- return lang_1.getTranslation(`instruments.${this.mainInstrument}`, this.lang);
24
+ const translation = lang_1.getTranslation(`instruments.${this.mainInstrument}`, this.lang);
25
+ return translation || this.mainInstrument;
25
26
  }
26
27
  }
27
28
  exports.default = PlayerBasic;
@@ -18,7 +18,8 @@ class UserGroup extends basic_1.default {
18
18
  return this.data.mainInstrument;
19
19
  }
20
20
  get instrument() {
21
- return lang_1.getTranslation(`instruments.${this.mainInstrument}`, this.lang);
21
+ const translation = lang_1.getTranslation(`instruments.${this.mainInstrument}`, this.lang);
22
+ return translation || this.mainInstrument;
22
23
  }
23
24
  get instruments() {
24
25
  return this.data.instruments || [];
@@ -12,7 +12,9 @@ class Notification extends Model_1.default {
12
12
  super(doc);
13
13
  this.getTranslationByAction = (key) => {
14
14
  const translation = lang_1.getTranslation(`${this.action}.${key}`, this.lang);
15
- return utils_1.replaceKeysNotification(translation, this.meta, this.lang);
15
+ return !translation
16
+ ? this.action
17
+ : utils_1.replaceKeysNotification(translation, this.meta, this.lang);
16
18
  };
17
19
  this.lang = lang;
18
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.1.11",
3
+ "version": "1.2.0",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",