@react-native-kakao/channel 2.4.9 → 2.4.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/CHANGELOG.md +15 -0
- package/android/src/main/java/net/mjstudio/rnkakao/channel/RNCKakaoChannelModule.kt +5 -5
- package/lib/commonjs/index.web.js +34 -28
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/module/index.web.js +35 -27
- package/lib/module/index.web.js.map +1 -1
- package/package.json +3 -3
- package/src/index.web.ts +45 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.4.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- de1cc13: Backport Android activity context fixes and align web API contracts with native; image scraping remains v3-only.
|
|
8
|
+
- Updated dependencies [de1cc13]
|
|
9
|
+
- @react-native-kakao/core@2.4.11
|
|
10
|
+
|
|
11
|
+
## 2.4.10
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [0d6e89a]
|
|
16
|
+
- @react-native-kakao/core@2.4.10
|
|
17
|
+
|
|
3
18
|
## 2.4.9
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -29,7 +29,7 @@ class RNCKakaoChannelModule internal constructor(
|
|
|
29
29
|
promise: Promise,
|
|
30
30
|
) = onMain {
|
|
31
31
|
val context =
|
|
32
|
-
currentActivity ?: run {
|
|
32
|
+
reactApplicationContext.currentActivity ?: run {
|
|
33
33
|
promise.rejectWith(ActivityNotFoundException())
|
|
34
34
|
return@onMain
|
|
35
35
|
}
|
|
@@ -51,7 +51,7 @@ class RNCKakaoChannelModule internal constructor(
|
|
|
51
51
|
promise: Promise,
|
|
52
52
|
) = onMain {
|
|
53
53
|
val context =
|
|
54
|
-
currentActivity ?: run {
|
|
54
|
+
reactApplicationContext.currentActivity ?: run {
|
|
55
55
|
promise.rejectWith(ActivityNotFoundException())
|
|
56
56
|
return@onMain
|
|
57
57
|
}
|
|
@@ -84,7 +84,7 @@ class RNCKakaoChannelModule internal constructor(
|
|
|
84
84
|
promise: Promise,
|
|
85
85
|
) = onMain {
|
|
86
86
|
val context =
|
|
87
|
-
currentActivity ?: run {
|
|
87
|
+
reactApplicationContext.currentActivity ?: run {
|
|
88
88
|
promise.rejectWith(ActivityNotFoundException())
|
|
89
89
|
return@onMain
|
|
90
90
|
}
|
|
@@ -103,7 +103,7 @@ class RNCKakaoChannelModule internal constructor(
|
|
|
103
103
|
promise: Promise,
|
|
104
104
|
) = onMain {
|
|
105
105
|
val context =
|
|
106
|
-
currentActivity ?: run {
|
|
106
|
+
reactApplicationContext.currentActivity ?: run {
|
|
107
107
|
promise.rejectWith(ActivityNotFoundException())
|
|
108
108
|
return@onMain
|
|
109
109
|
}
|
|
@@ -136,7 +136,7 @@ class RNCKakaoChannelModule internal constructor(
|
|
|
136
136
|
promise: Promise,
|
|
137
137
|
) = onMain {
|
|
138
138
|
val context =
|
|
139
|
-
currentActivity ?: run {
|
|
139
|
+
reactApplicationContext.currentActivity ?: run {
|
|
140
140
|
promise.rejectWith(ActivityNotFoundException())
|
|
141
141
|
return@onMain
|
|
142
142
|
}
|
|
@@ -5,9 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.openChatChannelUrl = exports.openAddChannelUrl = exports.getChatChannelUrl = exports.getAddChannelUrl = exports.followChannel = exports.default = exports.chatChannel = exports.channels = exports.addChannel = void 0;
|
|
7
7
|
var _core = require("@react-native-kakao/core");
|
|
8
|
-
var querystring = _interopRequireWildcard(require("querystring"));
|
|
9
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
8
|
const KakaoChannel = {
|
|
12
9
|
followChannel: channelPublicId => (0, _core.kRunWebAPI)(async () => {
|
|
13
10
|
const result = await Kakao.Channel.followChannel({
|
|
@@ -21,35 +18,44 @@ const KakaoChannel = {
|
|
|
21
18
|
addChannel: channelPublicId => (0, _core.kRunWebAPI)(() => Kakao.Channel.addChannel({
|
|
22
19
|
channelPublicId
|
|
23
20
|
})),
|
|
24
|
-
getAddChannelUrl:
|
|
25
|
-
|
|
26
|
-
message: 'Use addChannel directly in web'
|
|
27
|
-
};
|
|
28
|
-
}),
|
|
29
|
-
openAddChannelUrl: () => (0, _core.kRunWebAPI)(() => {
|
|
30
|
-
throw {
|
|
31
|
-
message: 'Use addChannel directly in web'
|
|
32
|
-
};
|
|
33
|
-
}),
|
|
21
|
+
getAddChannelUrl: channelPublicId => (0, _core.kRunWebAPI)(() => getChannelUrl(channelPublicId, 'friend')),
|
|
22
|
+
openAddChannelUrl: channelPublicId => openChannelUrl(channelPublicId, 'friend'),
|
|
34
23
|
chatChannel: channelPublicId => (0, _core.kRunWebAPI)(() => Kakao.Channel.chat({
|
|
35
24
|
channelPublicId
|
|
36
25
|
})),
|
|
37
|
-
getChatChannelUrl:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}),
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
26
|
+
getChatChannelUrl: channelPublicId => (0, _core.kRunWebAPI)(() => getChannelUrl(channelPublicId, 'chat')),
|
|
27
|
+
openChatChannelUrl: channelPublicId => openChannelUrl(channelPublicId, 'chat'),
|
|
28
|
+
channels: ({
|
|
29
|
+
channelPublicIds = []
|
|
30
|
+
} = {}) => (0, _core.kRunWebAPI)(async () => {
|
|
31
|
+
const response = await Kakao.API.request({
|
|
32
|
+
url: '/v2/api/talk/channels',
|
|
33
|
+
data: channelPublicIds.length ? {
|
|
34
|
+
channel_ids: channelPublicIds.join(','),
|
|
35
|
+
channel_id_type: 'channel_public_id'
|
|
36
|
+
} : undefined
|
|
37
|
+
});
|
|
38
|
+
return (response.channels ?? []).map(channel => ({
|
|
39
|
+
uuid: channel.channel_uuid,
|
|
40
|
+
encodedId: channel.channel_public_id,
|
|
41
|
+
relation: channel.relation.toLowerCase(),
|
|
42
|
+
updatedAt: channel.updated_at ? Date.parse(channel.updated_at) / 1000 : undefined
|
|
43
|
+
}));
|
|
44
|
+
})
|
|
52
45
|
};
|
|
46
|
+
function getChannelUrl(channelPublicId, action) {
|
|
47
|
+
(0, _core.kAssert)(channelPublicId, 'channelPublicId is missing');
|
|
48
|
+
return `https://pf.kakao.com/${encodeURIComponent(channelPublicId)}/${action}`;
|
|
49
|
+
}
|
|
50
|
+
function openChannelUrl(channelPublicId, action) {
|
|
51
|
+
return (0, _core.kRunWebAPI)(() => {
|
|
52
|
+
const url = getChannelUrl(channelPublicId, action);
|
|
53
|
+
const popup = window.open(url, '_blank');
|
|
54
|
+
(0, _core.kAssert)(!!popup, 'The channel popup was blocked by the browser');
|
|
55
|
+
popup.opener = null;
|
|
56
|
+
return url;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
53
59
|
const {
|
|
54
60
|
addChannel,
|
|
55
61
|
followChannel,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_core","require","
|
|
1
|
+
{"version":3,"names":["_core","require","KakaoChannel","followChannel","channelPublicId","kRunWebAPI","result","Kakao","Channel","channel_public_id","status","addChannel","getAddChannelUrl","getChannelUrl","openAddChannelUrl","openChannelUrl","chatChannel","chat","getChatChannelUrl","openChatChannelUrl","channels","channelPublicIds","response","API","request","url","data","length","channel_ids","join","channel_id_type","undefined","map","channel","uuid","channel_uuid","encodedId","relation","toLowerCase","updatedAt","updated_at","Date","parse","action","kAssert","encodeURIComponent","popup","window","open","opener","exports","_default","default"],"sourceRoot":"../../src","sources":["index.web.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAeA,MAAMC,YAA6B,GAAG;EACpCC,aAAa,EAAGC,eAAuB,IACrC,IAAAC,gBAAU,EAAC,YAAY;IACrB,MAAMC,MAAM,GAAG,MAAMC,KAAK,CAACC,OAAO,CAACL,aAAa,CAAC;MAAEC;IAAgB,CAAC,CAAC;IAErE,IAAIE,MAAM,IAAIF,eAAe,KAAKE,MAAM,CAACG,iBAAiB,IAAIH,MAAM,CAACI,MAAM,KAAK,SAAS,EAAE;MACzF,OAAO,IAAI;IACb;IAEA,OAAO,KAAK;EACd,CAAC,CAAC;EACJC,UAAU,EAAGP,eAAuB,IAClC,IAAAC,gBAAU,EAAC,MAAME,KAAK,CAACC,OAAO,CAACG,UAAU,CAAC;IAAEP;EAAgB,CAAC,CAAC,CAAC;EACjEQ,gBAAgB,EAAGR,eAAe,IAAK,IAAAC,gBAAU,EAAC,MAAMQ,aAAa,CAACT,eAAe,EAAE,QAAQ,CAAC,CAAC;EACjGU,iBAAiB,EAAGV,eAAe,IAAKW,cAAc,CAACX,eAAe,EAAE,QAAQ,CAAC;EACjFY,WAAW,EAAGZ,eAAuB,IACnC,IAAAC,gBAAU,EAAC,MAAME,KAAK,CAACC,OAAO,CAACS,IAAI,CAAC;IAAEb;EAAgB,CAAC,CAAC,CAAC;EAC3Dc,iBAAiB,EAAGd,eAAe,IAAK,IAAAC,gBAAU,EAAC,MAAMQ,aAAa,CAACT,eAAe,EAAE,MAAM,CAAC,CAAC;EAChGe,kBAAkB,EAAGf,eAAe,I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,CAAC;IACxC,IAAAmB,aAAO,EAAC,CAAC,CAACE,KAAK,EAAE,8CAA8C,CAAC;IAChEA,KAAK,CAAEG,MAAM,GAAG,IAAI;IAEpB,OAAOxB,GAAG;EACZ,CAAC,CAAC;AACJ;AAEO,MAAM;EACXd,UAAU;EACVR,aAAa;EACbiB,QAAQ;EACRJ,WAAW;EACXJ,gBAAgB;EAChBM,iBAAiB;EACjBJ,iBAAiB;EACjBK;AACF,CAAC,GAAGjB,YAAY;AAACgD,OAAA,CAAA/B,kBAAA,GAAAA,kBAAA;AAAA+B,OAAA,CAAApC,iBAAA,GAAAA,iBAAA;AAAAoC,OAAA,CAAAhC,iBAAA,GAAAA,iBAAA;AAAAgC,OAAA,CAAAtC,gBAAA,GAAAA,gBAAA;AAAAsC,OAAA,CAAAlC,WAAA,GAAAA,WAAA;AAAAkC,OAAA,CAAA9B,QAAA,GAAAA,QAAA;AAAA8B,OAAA,CAAA/C,aAAA,GAAAA,aAAA;AAAA+C,OAAA,CAAAvC,UAAA,GAAAA,UAAA;AAAA,IAAAwC,QAAA,GAAAD,OAAA,CAAAE,OAAA,GACFlD,YAAY","ignoreList":[]}
|
package/lib/module/index.web.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { kRunWebAPI } from '@react-native-kakao/core';
|
|
4
|
-
import * as querystring from 'querystring';
|
|
3
|
+
import { kAssert, kRunWebAPI } from '@react-native-kakao/core';
|
|
5
4
|
const KakaoChannel = {
|
|
6
5
|
followChannel: channelPublicId => kRunWebAPI(async () => {
|
|
7
6
|
const result = await Kakao.Channel.followChannel({
|
|
@@ -15,35 +14,44 @@ const KakaoChannel = {
|
|
|
15
14
|
addChannel: channelPublicId => kRunWebAPI(() => Kakao.Channel.addChannel({
|
|
16
15
|
channelPublicId
|
|
17
16
|
})),
|
|
18
|
-
getAddChannelUrl:
|
|
19
|
-
|
|
20
|
-
message: 'Use addChannel directly in web'
|
|
21
|
-
};
|
|
22
|
-
}),
|
|
23
|
-
openAddChannelUrl: () => kRunWebAPI(() => {
|
|
24
|
-
throw {
|
|
25
|
-
message: 'Use addChannel directly in web'
|
|
26
|
-
};
|
|
27
|
-
}),
|
|
17
|
+
getAddChannelUrl: channelPublicId => kRunWebAPI(() => getChannelUrl(channelPublicId, 'friend')),
|
|
18
|
+
openAddChannelUrl: channelPublicId => openChannelUrl(channelPublicId, 'friend'),
|
|
28
19
|
chatChannel: channelPublicId => kRunWebAPI(() => Kakao.Channel.chat({
|
|
29
20
|
channelPublicId
|
|
30
21
|
})),
|
|
31
|
-
getChatChannelUrl:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
22
|
+
getChatChannelUrl: channelPublicId => kRunWebAPI(() => getChannelUrl(channelPublicId, 'chat')),
|
|
23
|
+
openChatChannelUrl: channelPublicId => openChannelUrl(channelPublicId, 'chat'),
|
|
24
|
+
channels: ({
|
|
25
|
+
channelPublicIds = []
|
|
26
|
+
} = {}) => kRunWebAPI(async () => {
|
|
27
|
+
const response = await Kakao.API.request({
|
|
28
|
+
url: '/v2/api/talk/channels',
|
|
29
|
+
data: channelPublicIds.length ? {
|
|
30
|
+
channel_ids: channelPublicIds.join(','),
|
|
31
|
+
channel_id_type: 'channel_public_id'
|
|
32
|
+
} : undefined
|
|
33
|
+
});
|
|
34
|
+
return (response.channels ?? []).map(channel => ({
|
|
35
|
+
uuid: channel.channel_uuid,
|
|
36
|
+
encodedId: channel.channel_public_id,
|
|
37
|
+
relation: channel.relation.toLowerCase(),
|
|
38
|
+
updatedAt: channel.updated_at ? Date.parse(channel.updated_at) / 1000 : undefined
|
|
39
|
+
}));
|
|
40
|
+
})
|
|
46
41
|
};
|
|
42
|
+
function getChannelUrl(channelPublicId, action) {
|
|
43
|
+
kAssert(channelPublicId, 'channelPublicId is missing');
|
|
44
|
+
return `https://pf.kakao.com/${encodeURIComponent(channelPublicId)}/${action}`;
|
|
45
|
+
}
|
|
46
|
+
function openChannelUrl(channelPublicId, action) {
|
|
47
|
+
return kRunWebAPI(() => {
|
|
48
|
+
const url = getChannelUrl(channelPublicId, action);
|
|
49
|
+
const popup = window.open(url, '_blank');
|
|
50
|
+
kAssert(!!popup, 'The channel popup was blocked by the browser');
|
|
51
|
+
popup.opener = null;
|
|
52
|
+
return url;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
47
55
|
export const {
|
|
48
56
|
addChannel,
|
|
49
57
|
followChannel,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["kAssert","kRunWebAPI","KakaoChannel","followChannel","channelPublicId","result","Kakao","Channel","channel_public_id","status","addChannel","getAddChannelUrl","getChannelUrl","openAddChannelUrl","openChannelUrl","chatChannel","chat","getChatChannelUrl","openChatChannelUrl","channels","channelPublicIds","response","API","request","url","data","length","channel_ids","join","channel_id_type","undefined","map","channel","uuid","channel_uuid","encodedId","relation","toLowerCase","updatedAt","updated_at","Date","parse","action","encodeURIComponent","popup","window","open","opener"],"sourceRoot":"../../src","sources":["index.web.ts"],"mappings":";;AAAA,SAASA,OAAO,EAAEC,UAAU,QAAQ,0BAA0B;AAe9D,MAAMC,YAA6B,GAAG;EACpCC,aAAa,EAAGC,eAAuB,IACrCH,UAAU,CAAC,YAAY;IACrB,MAAMI,MAAM,GAAG,MAAMC,KAAK,CAACC,OAAO,CAACJ,aAAa,CAAC;MAAEC;IAAgB,CAAC,CAAC;IAErE,IAAIC,MAAM,IAAID,eAAe,KAAKC,MAAM,CAACG,iBAAiB,IAAIH,MAAM,CAACI,MAAM,KAAK,SAAS,EAAE;MACzF,OAAO,IAAI;IACb;IAEA,OAAO,KAAK;EACd,CAAC,CAAC;EACJC,UAAU,EAAGN,eAAuB,IAClCH,UAAU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O,UAAU,CAAC,GAAG,IAAI,GAAGT;IAC1E,CAAC,CAAC,CAAC;EACL,CAAC;AACL,CAAC;AAED,SAASlB,aAAaA,CAACR,eAAuB,EAAEsC,MAAyB,EAAE;EACzE1C,OAAO,CAACI,eAAe,EAAE,4BAA4B,CAAC;EAEtD,OAAO,wBAAwBuC,kBAAkB,CAACvC,eAAe,CAAC,IAAIsC,MAAM,EAAE;AAChF;AAEA,SAAS5B,cAAcA,CAACV,eAAuB,EAAEsC,MAAyB,EAAE;EAC1E,OAAOzC,UAAU,CAAC,MAAM;IACtB,MAAMuB,GAAG,GAAGZ,aAAa,CAACR,eAAe,EAAEsC,MAAM,CAAC;IAClD,MAAME,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACtB,GAAG,EAAE,QAAQ,CAAC;IACxCxB,OAAO,CAAC,CAAC,CAAC4C,KAAK,EAAE,8CAA8C,CAAC;IAChEA,KAAK,CAAEG,MAAM,GAAG,IAAI;IAEpB,OAAOvB,GAAG;EACZ,CAAC,CAAC;AACJ;AAEA,OAAO,MAAM;EACXd,UAAU;EACVP,aAAa;EACbgB,QAAQ;EACRJ,WAAW;EACXJ,gBAAgB;EAChBM,iBAAiB;EACjBJ,iBAAiB;EACjBK;AACF,CAAC,GAAGhB,YAAY;AAChB,eAAeA,YAAY","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-kakao/channel",
|
|
3
3
|
"description": "React Native Kakao Channel SDK",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.11",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
7
7
|
"types": "lib/typescript/src/index.d.ts",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@react-native-kakao/core": "2.4.
|
|
64
|
+
"@react-native-kakao/core": "2.4.11",
|
|
65
65
|
"@types/invariant": "^2",
|
|
66
66
|
"@types/jest": "^29.5.5",
|
|
67
67
|
"@types/react": "19.0.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"zx": "8.8.5"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@react-native-kakao/core": "2.4.
|
|
77
|
+
"@react-native-kakao/core": "2.4.11",
|
|
78
78
|
"react": "*",
|
|
79
79
|
"react-native": "*"
|
|
80
80
|
},
|
package/src/index.web.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { kRunWebAPI } from '@react-native-kakao/core';
|
|
2
|
-
import * as querystring from 'querystring';
|
|
1
|
+
import { kAssert, kRunWebAPI } from '@react-native-kakao/core';
|
|
3
2
|
|
|
4
|
-
import type { KakaoChannelAPI } from './index';
|
|
3
|
+
import type { KakaoChannel as KakaoChannelInfo, KakaoChannelAPI } from './index';
|
|
5
4
|
|
|
6
5
|
declare const Kakao: {
|
|
7
6
|
Channel: {
|
|
@@ -27,32 +26,54 @@ const KakaoChannel: KakaoChannelAPI = {
|
|
|
27
26
|
}),
|
|
28
27
|
addChannel: (channelPublicId: string): Promise<void> =>
|
|
29
28
|
kRunWebAPI(() => Kakao.Channel.addChannel({ channelPublicId })),
|
|
30
|
-
getAddChannelUrl: ()
|
|
31
|
-
|
|
32
|
-
throw { message: 'Use addChannel directly in web' };
|
|
33
|
-
}),
|
|
34
|
-
openAddChannelUrl: (): Promise<string> =>
|
|
35
|
-
kRunWebAPI(() => {
|
|
36
|
-
throw { message: 'Use addChannel directly in web' };
|
|
37
|
-
}),
|
|
29
|
+
getAddChannelUrl: (channelPublicId) => kRunWebAPI(() => getChannelUrl(channelPublicId, 'friend')),
|
|
30
|
+
openAddChannelUrl: (channelPublicId) => openChannelUrl(channelPublicId, 'friend'),
|
|
38
31
|
chatChannel: (channelPublicId: string): Promise<void> =>
|
|
39
32
|
kRunWebAPI(() => Kakao.Channel.chat({ channelPublicId })),
|
|
40
|
-
getChatChannelUrl: ()
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
getChatChannelUrl: (channelPublicId) => kRunWebAPI(() => getChannelUrl(channelPublicId, 'chat')),
|
|
34
|
+
openChatChannelUrl: (channelPublicId) => openChannelUrl(channelPublicId, 'chat'),
|
|
35
|
+
channels: ({ channelPublicIds = [] } = {}) =>
|
|
36
|
+
kRunWebAPI(async () => {
|
|
37
|
+
const response: {
|
|
38
|
+
channels?: {
|
|
39
|
+
channel_uuid: string;
|
|
40
|
+
channel_public_id: string;
|
|
41
|
+
relation: string;
|
|
42
|
+
updated_at?: string;
|
|
43
|
+
}[];
|
|
44
|
+
} = await Kakao.API.request({
|
|
45
|
+
url: '/v2/api/talk/channels',
|
|
46
|
+
data: channelPublicIds.length
|
|
47
|
+
? { channel_ids: channelPublicIds.join(','), channel_id_type: 'channel_public_id' }
|
|
48
|
+
: undefined,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return (response.channels ?? []).map((channel) => ({
|
|
52
|
+
uuid: channel.channel_uuid,
|
|
53
|
+
encodedId: channel.channel_public_id,
|
|
54
|
+
relation: channel.relation.toLowerCase() as KakaoChannelInfo['relation'],
|
|
55
|
+
updatedAt: channel.updated_at ? Date.parse(channel.updated_at) / 1000 : undefined,
|
|
56
|
+
}));
|
|
47
57
|
}),
|
|
48
|
-
channels: (params) =>
|
|
49
|
-
kRunWebAPI(() =>
|
|
50
|
-
Kakao.API.request({
|
|
51
|
-
url: `/v1/api/talk/channels${params?.channelPublicIds ? `?${querystring.stringify({ channel_ids: params.channelPublicIds })}` : ''}`,
|
|
52
|
-
}),
|
|
53
|
-
),
|
|
54
58
|
};
|
|
55
59
|
|
|
60
|
+
function getChannelUrl(channelPublicId: string, action: 'friend' | 'chat') {
|
|
61
|
+
kAssert(channelPublicId, 'channelPublicId is missing');
|
|
62
|
+
|
|
63
|
+
return `https://pf.kakao.com/${encodeURIComponent(channelPublicId)}/${action}`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function openChannelUrl(channelPublicId: string, action: 'friend' | 'chat') {
|
|
67
|
+
return kRunWebAPI(() => {
|
|
68
|
+
const url = getChannelUrl(channelPublicId, action);
|
|
69
|
+
const popup = window.open(url, '_blank');
|
|
70
|
+
kAssert(!!popup, 'The channel popup was blocked by the browser');
|
|
71
|
+
popup!.opener = null;
|
|
72
|
+
|
|
73
|
+
return url;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
56
77
|
export const {
|
|
57
78
|
addChannel,
|
|
58
79
|
followChannel,
|