robbyson-frontend-library 1.0.96 → 1.0.97-rc2

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.
@@ -63,7 +63,9 @@ export function checkIfUserIsSingleAdmin(identification, group) {
63
63
  }
64
64
  export function getChatName(chat) {
65
65
  var _a;
66
- return chat.type !== ChatConstants.TYPE_CHAT.GROUP
66
+ if (!(chat === null || chat === void 0 ? void 0 : chat.name))
67
+ return "";
68
+ return (chat === null || chat === void 0 ? void 0 : chat.type) !== ChatConstants.TYPE_CHAT.GROUP
67
69
  ? _.startCase((_a = chat.name) === null || _a === void 0 ? void 0 : _a.toLowerCase())
68
70
  : chat.name;
69
71
  }
@@ -97,11 +97,26 @@ export function getCroppedImg(imageSrc, pixelCrop, flip, type) {
97
97
  });
98
98
  }
99
99
  export function checkExpiresPublicUrl(publicUrl) {
100
- var _a, _b;
101
- var expiresIn = parseInt((_b = (_a = publicUrl.split("Expires=")[1]) === null || _a === void 0 ? void 0 : _a.split("&")) === null || _b === void 0 ? void 0 : _b[0]);
102
- if (!expiresIn) {
103
- return false;
100
+ var urlParams = new URLSearchParams(publicUrl);
101
+ var googDate = urlParams.get("X-Goog-Date");
102
+ var googExpires = urlParams.get("X-Goog-Expires");
103
+ if (!googDate || !googExpires) {
104
+ return true;
105
+ }
106
+ var expirationInSeconds = parseInt(googExpires);
107
+ var baseDate = parseISODate(googDate);
108
+ if (!baseDate) {
109
+ return true;
110
+ }
111
+ var expirationDate = new Date(baseDate.getTime() + expirationInSeconds * 1000);
112
+ return new Date() > expirationDate;
113
+ }
114
+ function parseISODate(googDate) {
115
+ try {
116
+ return new Date("".concat(googDate.substring(0, 4), "-").concat(googDate.substring(4, 6), "-").concat(googDate.substring(6, 8), "T") +
117
+ "".concat(googDate.substring(9, 11), ":").concat(googDate.substring(11, 13), ":").concat(googDate.substring(13, 15), "Z"));
118
+ }
119
+ catch (_a) {
120
+ return null;
104
121
  }
105
- var currentTime = Math.floor(new Date().getTime() / 1000);
106
- return currentTime > expiresIn;
107
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robbyson-frontend-library",
3
- "version": "1.0.96",
3
+ "version": "1.0.97-rc2",
4
4
  "description": "Robbyson frontend Library",
5
5
  "main": "./dist/index.js",
6
6
  "license": "MIT",
@@ -6,5 +6,5 @@ export interface IAddUserToGroupModalProps extends IBaseComponentProp {
6
6
  chat?: ChatModel;
7
7
  chatId?: string;
8
8
  identification?: string;
9
- onClose: () => void;
9
+ onClose(): void;
10
10
  }
@@ -124,4 +124,8 @@ export interface IChatService {
124
124
  canSendFiles(canSendMessages: boolean): boolean;
125
125
  isChatPage(conversationId?: string): boolean;
126
126
  getCurrentConversations(search?: string): ChatModel[];
127
+ getStateConversation(
128
+ conversationId: string
129
+ ): UserListModel | ChatModel | undefined;
130
+ getStateSmallChat(conversationId: string): ChatDTO.ISmallChat | undefined;
127
131
  }
@@ -99,7 +99,9 @@ export function checkIfUserIsSingleAdmin(
99
99
  }
100
100
 
101
101
  export function getChatName(chat: ChatModel): string {
102
- return chat.type !== ChatConstants.TYPE_CHAT.GROUP
102
+ if (!chat?.name) return "";
103
+
104
+ return chat?.type !== ChatConstants.TYPE_CHAT.GROUP
103
105
  ? _.startCase(chat.name?.toLowerCase())
104
106
  : chat.name;
105
107
  }
@@ -74,13 +74,41 @@ export async function getCroppedImg(
74
74
  }
75
75
 
76
76
  export function checkExpiresPublicUrl(publicUrl: string): boolean {
77
- const expiresIn = parseInt(publicUrl.split("Expires=")[1]?.split("&")?.[0]);
77
+ const urlParams = new URLSearchParams(publicUrl);
78
+ const googDate = urlParams.get("X-Goog-Date");
79
+ const googExpires = urlParams.get("X-Goog-Expires");
78
80
 
79
- if (!expiresIn) {
80
- return false;
81
+ if (!googDate || !googExpires) {
82
+ return true;
81
83
  }
82
84
 
83
- const currentTime = Math.floor(new Date().getTime() / 1000);
85
+ const expirationInSeconds = parseInt(googExpires);
86
+ const baseDate = parseISODate(googDate);
84
87
 
85
- return currentTime > expiresIn;
88
+ if (!baseDate) {
89
+ return true;
90
+ }
91
+
92
+ const expirationDate = new Date(
93
+ baseDate.getTime() + expirationInSeconds * 1000
94
+ );
95
+
96
+ return new Date() > expirationDate;
97
+ }
98
+
99
+ function parseISODate(googDate: string): Date | null {
100
+ try {
101
+ return new Date(
102
+ `${googDate.substring(0, 4)}-${googDate.substring(
103
+ 4,
104
+ 6
105
+ )}-${googDate.substring(6, 8)}T` +
106
+ `${googDate.substring(9, 11)}:${googDate.substring(
107
+ 11,
108
+ 13
109
+ )}:${googDate.substring(13, 15)}Z`
110
+ );
111
+ } catch {
112
+ return null;
113
+ }
86
114
  }