@alemonjs/bubble 2.1.0-alpha.15 → 2.1.0-alpha.16

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/lib/index.js CHANGED
@@ -14,7 +14,7 @@ const main = () => {
14
14
  const client = new BubbleClient();
15
15
  void client.connect();
16
16
  const createUserAvatar = (_UserId, avatar) => {
17
- if (avatar) {
17
+ if (!avatar) {
18
18
  return '';
19
19
  }
20
20
  return `${CDN_URL}/${avatar}`;
@@ -94,7 +94,7 @@ const main = () => {
94
94
  },
95
95
  use: {
96
96
  send: async (event, val) => {
97
- if (val.length < 0) {
97
+ if (!val || val.length <= 0) {
98
98
  return [];
99
99
  }
100
100
  const tag = event.tag;
@@ -117,9 +117,9 @@ const main = () => {
117
117
  },
118
118
  mention: e => {
119
119
  const event = e.value;
120
- const MessageMention = event.mentions.map(item => {
120
+ const MessageMention = (event.mentions || []).map(item => {
121
121
  const UserId = item.id;
122
- const avatar = event.author?.avatar;
122
+ const avatar = item.avatar;
123
123
  const UserAvatar = createUserAvatar(UserId, avatar);
124
124
  const [isMaster, UserKey] = getMaster(UserId);
125
125
  return {
@@ -79,15 +79,15 @@ const loggerError = err => {
79
79
  message: err?.message
80
80
  });
81
81
  };
82
- const createAxiosInstance = (service, options) => {
83
- return new Promise((resolve, reject) => {
84
- service(options)
85
- .then(res => resolve(res?.data ?? {}))
86
- .catch(err => {
87
- loggerError(err);
88
- reject(err?.response?.data);
89
- });
90
- });
82
+ const createAxiosInstance = async (service, options) => {
83
+ try {
84
+ const res = await service(options);
85
+ return res?.data ?? {};
86
+ }
87
+ catch (err) {
88
+ loggerError(err);
89
+ throw err?.response?.data ?? err;
90
+ }
91
91
  };
92
92
 
93
93
  export { createAxiosInstance };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alemonjs/bubble",
3
- "version": "2.1.0-alpha.15",
3
+ "version": "2.1.0-alpha.16",
4
4
  "description": "bubble platform",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",
@@ -65,4 +65,4 @@
65
65
  "type": "git",
66
66
  "url": "https://github.com/lemonade-lab/alemonjs.git"
67
67
  }
68
- }
68
+ }