@celljs/ta-rooms 4.21.0 → 4.22.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.
- package/extension/index.mjs +77 -12
- package/host/index.mjs +257 -131
- package/package.json +4 -4
- package/web/index.js +671 -19
package/web/index.js
CHANGED
|
@@ -653,9 +653,77 @@ var RelayFriendsUtil;
|
|
|
653
653
|
RelayFriendsUtil2.migrate = migrate;
|
|
654
654
|
})(RelayFriendsUtil || (RelayFriendsUtil = {}));
|
|
655
655
|
|
|
656
|
+
// ../ta-relay/esm/common/relay-room-app.js
|
|
657
|
+
var ROOM_AGENTS_KEY = "agents:";
|
|
658
|
+
var ROOM_APP_STALE_MS = 3 * 24 * 60 * 60 * 1000;
|
|
659
|
+
var HOUR_MS = 60 * 60 * 1000;
|
|
660
|
+
var RoomAppUtil;
|
|
661
|
+
(function(RoomAppUtil2) {
|
|
662
|
+
function quote(text) {
|
|
663
|
+
return text.replace(/</g, "<").replace(/>/g, ">");
|
|
664
|
+
}
|
|
665
|
+
RoomAppUtil2.quote = quote;
|
|
666
|
+
function fresh(lines, self, since, now, staleMs = ROOM_APP_STALE_MS) {
|
|
667
|
+
return lines.filter((line) => {
|
|
668
|
+
var _a;
|
|
669
|
+
return line.from !== self && line.at > since && now - line.at < staleMs && !((_a = line.to) === null || _a === undefined ? undefined : _a.length) && !line.double && !line.agent;
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
RoomAppUtil2.fresh = fresh;
|
|
673
|
+
function within(times, now, most) {
|
|
674
|
+
return times.filter((at) => now - at < HOUR_MS).length < most;
|
|
675
|
+
}
|
|
676
|
+
RoomAppUtil2.within = within;
|
|
677
|
+
function mentions(names) {
|
|
678
|
+
return [...new Set(names)].map((name) => `@${name}`).join(" ");
|
|
679
|
+
}
|
|
680
|
+
RoomAppUtil2.mentions = mentions;
|
|
681
|
+
})(RoomAppUtil || (RoomAppUtil = {}));
|
|
682
|
+
var RELAY_BOARD_KEY = "board:";
|
|
683
|
+
var RELAY_BOARD_MAX = 30;
|
|
684
|
+
var STATES = ["doing", "waiting", "done", "closed"];
|
|
685
|
+
var RelayBoardUtil;
|
|
686
|
+
(function(RelayBoardUtil2) {
|
|
687
|
+
function key(app, member) {
|
|
688
|
+
return `${RELAY_BOARD_KEY}${app}:${member}`;
|
|
689
|
+
}
|
|
690
|
+
RelayBoardUtil2.key = key;
|
|
691
|
+
function read(key2, value, by, owner) {
|
|
692
|
+
if (!owner || by !== owner || !key2.startsWith(RELAY_BOARD_KEY) || !key2.endsWith(`:${owner}`) || !value || typeof value !== "object") {
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
const { title, items } = value;
|
|
696
|
+
if (typeof title !== "string" || !Array.isArray(items)) {
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
return {
|
|
700
|
+
title: cut(title, 40),
|
|
701
|
+
items: items.filter((item) => item && Number.isInteger(item.n) && typeof item.title === "string" && STATES.includes(item.state) && typeof item.label === "string" && typeof item.at === "number").slice(-RELAY_BOARD_MAX).map((item) => ({
|
|
702
|
+
n: item.n,
|
|
703
|
+
title: cut(item.title, 80),
|
|
704
|
+
state: item.state,
|
|
705
|
+
label: cut(item.label, 30),
|
|
706
|
+
people: Array.isArray(item.people) ? item.people.filter((name) => typeof name === "string").slice(0, 5) : [],
|
|
707
|
+
at: item.at
|
|
708
|
+
}))
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
RelayBoardUtil2.read = read;
|
|
712
|
+
function counts(board) {
|
|
713
|
+
return {
|
|
714
|
+
open: board.items.filter((item) => item.state === "doing" || item.state === "waiting").length,
|
|
715
|
+
done: board.items.filter((item) => item.state === "done").length
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
RelayBoardUtil2.counts = counts;
|
|
719
|
+
function cut(text, max) {
|
|
720
|
+
const one = text.replace(/\s+/g, " ").trim();
|
|
721
|
+
return one.length > max ? `${one.slice(0, max - 1)}…` : one;
|
|
722
|
+
}
|
|
723
|
+
})(RelayBoardUtil || (RelayBoardUtil = {}));
|
|
724
|
+
|
|
656
725
|
// web-src/double-protocol.ts
|
|
657
726
|
var DIRECT_KIND = "ta-direct";
|
|
658
|
-
var ROOM_AGENTS_KEY = "agents:";
|
|
659
727
|
var RoomAgentsUtil;
|
|
660
728
|
((RoomAgentsUtil) => {
|
|
661
729
|
function key(member) {
|
|
@@ -771,9 +839,21 @@ var DirectUtil;
|
|
|
771
839
|
DirectUtil.friendOf = friendOf;
|
|
772
840
|
function find(rooms, kept, friend) {
|
|
773
841
|
const mine = rooms.filter((room) => is(room) && room.status === "member");
|
|
774
|
-
return mine.find((room) => room.id === kept[friend]) ?? mine.
|
|
842
|
+
return mine.find((room) => room.id === kept[friend]) ?? mine.filter((room) => peer(room)?.id === friend).sort((a, b) => a.createdAt - b.createdAt || a.id.localeCompare(b.id))[0];
|
|
775
843
|
}
|
|
776
844
|
DirectUtil.find = find;
|
|
845
|
+
function extra(rooms, kept) {
|
|
846
|
+
const mine = rooms.filter((room) => is(room) && room.status === "member");
|
|
847
|
+
const shown = new Set;
|
|
848
|
+
for (const friend of new Set(mine.map((room) => friendOf(room, kept)))) {
|
|
849
|
+
const room = friend ? find(rooms, kept, friend) : undefined;
|
|
850
|
+
if (room) {
|
|
851
|
+
shown.add(room.id);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
return mine.filter((room) => !shown.has(room.id));
|
|
855
|
+
}
|
|
856
|
+
DirectUtil.extra = extra;
|
|
777
857
|
})(DirectUtil ||= {});
|
|
778
858
|
|
|
779
859
|
// ../ta-relay/esm/common/relay-room-chat.js
|
|
@@ -1071,6 +1151,17 @@ var EN = {
|
|
|
1071
1151
|
inviteFriendsTitle: "Invite friends into “{title}”",
|
|
1072
1152
|
inviteFriendsLead: "Each friend you tap finds the group chat in their Ta: once they join, they are in, without your saying yes again.",
|
|
1073
1153
|
inviteFriendsNone: "All your friends are in, or you have none yet",
|
|
1154
|
+
groupPickLead: "Pick one friend to chat with them, two or more for a group chat.",
|
|
1155
|
+
groupPickLeadFrom: "Pick who else joins you and {name}: a new group chat; this chat stays as it is.",
|
|
1156
|
+
groupPickNone: "No friends yet: invite people by a link",
|
|
1157
|
+
groupPickChat: "Message",
|
|
1158
|
+
groupPickDone: "Start ({n})",
|
|
1159
|
+
groupByLink: "Invite by link or QR code",
|
|
1160
|
+
groupByLinkLine: "For people who are not your friends yet",
|
|
1161
|
+
groupNameSep: ", ",
|
|
1162
|
+
groupNameMore: "{names} and others",
|
|
1163
|
+
directGroup: "Start a group chat",
|
|
1164
|
+
directGroupLine: "With {name} and others, a new chat",
|
|
1074
1165
|
inviteFriendsOld: "Update Ta on this computer to invite friends",
|
|
1075
1166
|
invitedFriend: "Invited",
|
|
1076
1167
|
groupInviteTitle: "Invited to a group chat",
|
|
@@ -1192,7 +1283,7 @@ var ZH = {
|
|
|
1192
1283
|
closedNotice: "「{title}」已被群主解散。",
|
|
1193
1284
|
oldApp: "请更新 Ta 应用后再使用群聊。",
|
|
1194
1285
|
room: "群聊",
|
|
1195
|
-
newRoom: "
|
|
1286
|
+
newRoom: "发起群聊",
|
|
1196
1287
|
newRoomPlaceholder: "群聊名,受邀的人能看到",
|
|
1197
1288
|
roomOfName: "{name}的群聊",
|
|
1198
1289
|
back: "返回",
|
|
@@ -1210,6 +1301,17 @@ var ZH = {
|
|
|
1210
1301
|
inviteFriendsTitle: "邀请好友进「{title}」",
|
|
1211
1302
|
inviteFriendsLead: "点一位好友,对方就会在自己的 Ta 里看到这个群聊;对方点加入就直接进来,不用你再同意。",
|
|
1212
1303
|
inviteFriendsNone: "好友都在群里了,或者还没有好友",
|
|
1304
|
+
groupPickLead: "选一位好友就是私聊,选两位以上建群聊。",
|
|
1305
|
+
groupPickLeadFrom: "选要拉进来的人,和你、{name}另建一个群聊;这个私聊不变。",
|
|
1306
|
+
groupPickNone: "还没有好友,可以用链接邀请",
|
|
1307
|
+
groupPickChat: "发消息",
|
|
1308
|
+
groupPickDone: "完成({n})",
|
|
1309
|
+
groupByLink: "用链接或二维码邀请",
|
|
1310
|
+
groupByLinkLine: "邀请还不是好友的人",
|
|
1311
|
+
groupNameSep: "、",
|
|
1312
|
+
groupNameMore: "{names}等",
|
|
1313
|
+
directGroup: "发起群聊",
|
|
1314
|
+
directGroupLine: "拉上别人和{name}另建一个群",
|
|
1213
1315
|
inviteFriendsOld: "先把这台电脑上的 Ta 更新到新版,才能邀请好友",
|
|
1214
1316
|
invitedFriend: "已邀请",
|
|
1215
1317
|
groupInviteTitle: "群聊邀请",
|
|
@@ -1331,7 +1433,7 @@ var ZH_TW = {
|
|
|
1331
1433
|
closedNotice: "「{title}」已被群主解散。",
|
|
1332
1434
|
oldApp: "請更新 Ta 應用後再使用群聊。",
|
|
1333
1435
|
room: "群聊",
|
|
1334
|
-
newRoom: "
|
|
1436
|
+
newRoom: "發起群聊",
|
|
1335
1437
|
newRoomPlaceholder: "群聊名,受邀的人能看到",
|
|
1336
1438
|
roomOfName: "{name}的群聊",
|
|
1337
1439
|
back: "返回",
|
|
@@ -1349,6 +1451,17 @@ var ZH_TW = {
|
|
|
1349
1451
|
inviteFriendsTitle: "邀請好友進「{title}」",
|
|
1350
1452
|
inviteFriendsLead: "點一位好友,對方就會在自己的 Ta 裡看到這個群聊;對方點加入就直接進來,不用你再同意。",
|
|
1351
1453
|
inviteFriendsNone: "好友都在群裡了,或者還沒有好友",
|
|
1454
|
+
groupPickLead: "選一位好友就是私聊,選兩位以上建群聊。",
|
|
1455
|
+
groupPickLeadFrom: "選要拉進來的人,和你、{name}另建一個群聊;這個私聊不變。",
|
|
1456
|
+
groupPickNone: "還沒有好友,可以用連結邀請",
|
|
1457
|
+
groupPickChat: "發訊息",
|
|
1458
|
+
groupPickDone: "完成({n})",
|
|
1459
|
+
groupByLink: "用連結或 QR 碼邀請",
|
|
1460
|
+
groupByLinkLine: "邀請還不是好友的人",
|
|
1461
|
+
groupNameSep: "、",
|
|
1462
|
+
groupNameMore: "{names}等",
|
|
1463
|
+
directGroup: "發起群聊",
|
|
1464
|
+
directGroupLine: "拉上別人和{name}另建一個群",
|
|
1352
1465
|
inviteFriendsOld: "先把這台電腦上的 Ta 更新到新版,才能邀請好友",
|
|
1353
1466
|
invitedFriend: "已邀請",
|
|
1354
1467
|
groupInviteTitle: "群聊邀請",
|
|
@@ -1488,6 +1601,17 @@ var JA = {
|
|
|
1488
1601
|
inviteFriendsTitle: "「{title}」に友だちを招待",
|
|
1489
1602
|
inviteFriendsLead: "友だちをタップすると、その人の Ta にこのグループチャットが届きます。参加すれば、あなたの承認なしで入れます。",
|
|
1490
1603
|
inviteFriendsNone: "友だちは全員参加済みか、まだ友だちがいません",
|
|
1604
|
+
groupPickLead: "友だちを一人選ぶとその人とのチャット、二人以上でグループチャットになります。",
|
|
1605
|
+
groupPickLeadFrom: "あなたと{name}に加える人を選ぶと、新しいグループチャットになります。このチャットはそのままです。",
|
|
1606
|
+
groupPickNone: "まだ友だちがいません。リンクで招待できます",
|
|
1607
|
+
groupPickChat: "メッセージ",
|
|
1608
|
+
groupPickDone: "完了({n})",
|
|
1609
|
+
groupByLink: "リンクか QR コードで招待",
|
|
1610
|
+
groupByLinkLine: "まだ友だちでない人を招待",
|
|
1611
|
+
groupNameSep: "、",
|
|
1612
|
+
groupNameMore: "{names}ほか",
|
|
1613
|
+
directGroup: "グループチャットを作成",
|
|
1614
|
+
directGroupLine: "{name}とほかの人で新しいチャット",
|
|
1491
1615
|
inviteFriendsOld: "友だちを招待するには、このコンピュータの Ta を更新してください",
|
|
1492
1616
|
invitedFriend: "招待済み",
|
|
1493
1617
|
groupInviteTitle: "グループチャットへの招待",
|
|
@@ -2033,6 +2157,7 @@ class DirectBook {
|
|
|
2033
2157
|
kept = {};
|
|
2034
2158
|
listeners = new Set;
|
|
2035
2159
|
started = false;
|
|
2160
|
+
loaded = false;
|
|
2036
2161
|
get() {
|
|
2037
2162
|
return this.kept;
|
|
2038
2163
|
}
|
|
@@ -2062,9 +2187,11 @@ class DirectBook {
|
|
|
2062
2187
|
}
|
|
2063
2188
|
}
|
|
2064
2189
|
async read() {
|
|
2065
|
-
|
|
2190
|
+
const value = await pi.storage.get(DIRECT_KEY).then((kept) => kept ?? {}, () => {
|
|
2066
2191
|
return;
|
|
2067
|
-
})
|
|
2192
|
+
});
|
|
2193
|
+
this.loaded ||= value !== undefined;
|
|
2194
|
+
this.put(DirectUtil.parse(value));
|
|
2068
2195
|
}
|
|
2069
2196
|
put(kept) {
|
|
2070
2197
|
this.kept = kept;
|
|
@@ -2102,7 +2229,16 @@ function DirectFace({ room, size, unread }) {
|
|
|
2102
2229
|
className: "trm-unread"
|
|
2103
2230
|
}));
|
|
2104
2231
|
}
|
|
2105
|
-
|
|
2232
|
+
function openDirect(friend) {
|
|
2233
|
+
let open = opening.get(friend.id);
|
|
2234
|
+
if (!open) {
|
|
2235
|
+
open = openOrMake(friend).finally(() => opening.delete(friend.id));
|
|
2236
|
+
opening.set(friend.id, open);
|
|
2237
|
+
}
|
|
2238
|
+
return open;
|
|
2239
|
+
}
|
|
2240
|
+
var opening = new Map;
|
|
2241
|
+
async function openOrMake(friend) {
|
|
2106
2242
|
const server = rooms();
|
|
2107
2243
|
if (!server?.inviteFriends) {
|
|
2108
2244
|
return;
|
|
@@ -2134,6 +2270,20 @@ async function openDirect(friend) {
|
|
|
2134
2270
|
pi.ui.notify(message(error), "error");
|
|
2135
2271
|
}
|
|
2136
2272
|
}
|
|
2273
|
+
var tidied = new Set;
|
|
2274
|
+
function tidyDirects(list) {
|
|
2275
|
+
const server = rooms();
|
|
2276
|
+
for (const room of DirectUtil.extra(list, directs.get())) {
|
|
2277
|
+
if (!server || !directs.loaded || !room.owner || !DirectUtil.peer(room) || tidied.has(room.id)) {
|
|
2278
|
+
continue;
|
|
2279
|
+
}
|
|
2280
|
+
tidied.add(room.id);
|
|
2281
|
+
const chat = book.chat(room.id);
|
|
2282
|
+
chat?.load().then(() => chat.lines.length === 0 ? server.leave(room.id).then(() => book.load()) : undefined).catch(() => {
|
|
2283
|
+
return;
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2137
2287
|
var reinvited = new Set;
|
|
2138
2288
|
function reinvite(room) {
|
|
2139
2289
|
const friend = DirectUtil.friendOf(room, directs.get());
|
|
@@ -5008,6 +5158,41 @@ async function offerFriend(room, member, name) {
|
|
|
5008
5158
|
}
|
|
5009
5159
|
}
|
|
5010
5160
|
|
|
5161
|
+
// web-src/group-joining.ts
|
|
5162
|
+
var MEMBER_CHOICES = [16, 50, 100];
|
|
5163
|
+
var LINK_DAYS = [7, 30, 365];
|
|
5164
|
+
var DEFAULT_DAYS = 7;
|
|
5165
|
+
var LINK_DAYS_KEY = "linkDays";
|
|
5166
|
+
function parse(value) {
|
|
5167
|
+
return value && typeof value === "object" ? Object.fromEntries(Object.entries(value).filter((entry) => LINK_DAYS.includes(entry[1]))) : {};
|
|
5168
|
+
}
|
|
5169
|
+
async function linkDays(room) {
|
|
5170
|
+
return parse(await pi.storage?.get(LINK_DAYS_KEY).catch(() => {
|
|
5171
|
+
return;
|
|
5172
|
+
}))[room] ?? DEFAULT_DAYS;
|
|
5173
|
+
}
|
|
5174
|
+
async function setLinkDays(room, days) {
|
|
5175
|
+
const all = parse(await pi.storage?.get(LINK_DAYS_KEY).catch(() => {
|
|
5176
|
+
return;
|
|
5177
|
+
}));
|
|
5178
|
+
await pi.storage?.set(LINK_DAYS_KEY, { ...all, [room]: days });
|
|
5179
|
+
await rooms()?.invite(room, { days, renew: true });
|
|
5180
|
+
}
|
|
5181
|
+
function useLinkDays(room) {
|
|
5182
|
+
const [days, setDays] = React.useState(DEFAULT_DAYS);
|
|
5183
|
+
React.useEffect(() => {
|
|
5184
|
+
let live = true;
|
|
5185
|
+
const read = () => void linkDays(room).then((found) => live && setDays(found));
|
|
5186
|
+
read();
|
|
5187
|
+
const stop = pi.storage?.onChange((keys) => keys.includes(LINK_DAYS_KEY) && read());
|
|
5188
|
+
return () => {
|
|
5189
|
+
live = false;
|
|
5190
|
+
stop?.();
|
|
5191
|
+
};
|
|
5192
|
+
}, [room]);
|
|
5193
|
+
return days;
|
|
5194
|
+
}
|
|
5195
|
+
|
|
5011
5196
|
// web-src/dialogs.tsx
|
|
5012
5197
|
function show(component) {
|
|
5013
5198
|
if (!pi.ui.custom) {
|
|
@@ -5161,7 +5346,7 @@ function InviteDialog({ room, close }) {
|
|
|
5161
5346
|
const [error, setError] = React.useState();
|
|
5162
5347
|
const make = React.useCallback((renew) => {
|
|
5163
5348
|
setError(undefined);
|
|
5164
|
-
rooms()?.invite(room.id, renew ? { renew } :
|
|
5349
|
+
linkDays(room.id).then((days) => rooms()?.invite(room.id, { days, ...renew ? { renew } : {} })).then((made) => made && setLink(made.link)).catch((failure) => setError(message(failure)));
|
|
5165
5350
|
}, [room.id]);
|
|
5166
5351
|
React.useEffect(() => make(false), [make]);
|
|
5167
5352
|
return /* @__PURE__ */ React.createElement(ShareSheetCompat, {
|
|
@@ -5482,6 +5667,123 @@ function openFriendPicker(room) {
|
|
|
5482
5667
|
close
|
|
5483
5668
|
}));
|
|
5484
5669
|
}
|
|
5670
|
+
function groupTitle(names2) {
|
|
5671
|
+
const shown = names2.filter(Boolean);
|
|
5672
|
+
const title = shown.slice(0, 4).join(t("groupNameSep"));
|
|
5673
|
+
return (shown.length > 4 ? t("groupNameMore", { names: title }) : title).slice(0, 60);
|
|
5674
|
+
}
|
|
5675
|
+
async function makeGroup(friends, me) {
|
|
5676
|
+
const server = rooms();
|
|
5677
|
+
if (!server?.inviteFriends) {
|
|
5678
|
+
throw new Error(t("inviteFriendsOld"));
|
|
5679
|
+
}
|
|
5680
|
+
const room = await server.createRoom({ kind: ROOMS_KIND, title: groupTitle([me ?? "", ...friends.map((friend) => friend.name)]) });
|
|
5681
|
+
await server.inviteFriends(room.id, friends.map((friend) => friend.id));
|
|
5682
|
+
await book.load();
|
|
5683
|
+
openRoom(room.id);
|
|
5684
|
+
}
|
|
5685
|
+
function GroupPicker({ fixed, close }) {
|
|
5686
|
+
const { friends, identity } = useBook();
|
|
5687
|
+
const list = (friends ?? []).filter((friend) => friend.status === "friend");
|
|
5688
|
+
const [chosen, setChosen] = React.useState(fixed ? [fixed.id] : []);
|
|
5689
|
+
const [busy, setBusy] = React.useState(false);
|
|
5690
|
+
const [error, setError] = React.useState();
|
|
5691
|
+
const Check = icon("Check");
|
|
5692
|
+
const Link = icon("Link");
|
|
5693
|
+
const picked = list.filter((friend) => chosen.includes(friend.id));
|
|
5694
|
+
const direct = !fixed && picked.length === 1;
|
|
5695
|
+
const enough = picked.length >= (fixed ? 2 : 1);
|
|
5696
|
+
const toggle = (id) => {
|
|
5697
|
+
if (id !== fixed?.id) {
|
|
5698
|
+
setChosen((before) => before.includes(id) ? before.filter((each) => each !== id) : [...before, id]);
|
|
5699
|
+
}
|
|
5700
|
+
};
|
|
5701
|
+
const done = () => {
|
|
5702
|
+
if (direct) {
|
|
5703
|
+
close();
|
|
5704
|
+
openDirect(picked[0]);
|
|
5705
|
+
return;
|
|
5706
|
+
}
|
|
5707
|
+
setBusy(true);
|
|
5708
|
+
setError(undefined);
|
|
5709
|
+
makeGroup(picked, identity?.name).then(close, (failure) => {
|
|
5710
|
+
setError(message(failure));
|
|
5711
|
+
setBusy(false);
|
|
5712
|
+
});
|
|
5713
|
+
};
|
|
5714
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
5715
|
+
title: t("newRoom"),
|
|
5716
|
+
onClose: close
|
|
5717
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
5718
|
+
className: "trm-dialog"
|
|
5719
|
+
}, /* @__PURE__ */ React.createElement("p", {
|
|
5720
|
+
className: "trm-note"
|
|
5721
|
+
}, fixed ? t("groupPickLeadFrom", { name: fixed.name }) : t("groupPickLead")), /* @__PURE__ */ React.createElement("ul", {
|
|
5722
|
+
className: "trm-rows trm-group-pick"
|
|
5723
|
+
}, !fixed && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
5724
|
+
type: "button",
|
|
5725
|
+
className: "trm-member",
|
|
5726
|
+
disabled: busy,
|
|
5727
|
+
onClick: () => {
|
|
5728
|
+
close();
|
|
5729
|
+
createRoom();
|
|
5730
|
+
}
|
|
5731
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5732
|
+
className: "trm-member-plus"
|
|
5733
|
+
}, /* @__PURE__ */ React.createElement(Link, {
|
|
5734
|
+
size: 16
|
|
5735
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
5736
|
+
className: "trm-member-text"
|
|
5737
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5738
|
+
className: "trm-member-name"
|
|
5739
|
+
}, t("groupByLink")), /* @__PURE__ */ React.createElement("span", {
|
|
5740
|
+
className: "trm-member-detail"
|
|
5741
|
+
}, t("groupByLinkLine"))))), list.map((friend) => {
|
|
5742
|
+
const on = chosen.includes(friend.id);
|
|
5743
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
5744
|
+
key: friend.id
|
|
5745
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
5746
|
+
type: "button",
|
|
5747
|
+
className: "trm-member",
|
|
5748
|
+
"aria-pressed": on,
|
|
5749
|
+
disabled: busy || friend.id === fixed?.id,
|
|
5750
|
+
onClick: () => toggle(friend.id)
|
|
5751
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5752
|
+
className: `trm-pick-box${on ? " trm-pick-on" : ""}`,
|
|
5753
|
+
"aria-hidden": "true"
|
|
5754
|
+
}, on && /* @__PURE__ */ React.createElement(Check, {
|
|
5755
|
+
size: 12
|
|
5756
|
+
})), /* @__PURE__ */ React.createElement(Face, {
|
|
5757
|
+
id: friend.id,
|
|
5758
|
+
name: friend.name,
|
|
5759
|
+
size: 34
|
|
5760
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
5761
|
+
className: "trm-member-text"
|
|
5762
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5763
|
+
className: "trm-member-name trm-ellipsis"
|
|
5764
|
+
}, friend.name))));
|
|
5765
|
+
})), list.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
5766
|
+
title: t("groupPickNone"),
|
|
5767
|
+
compact: true
|
|
5768
|
+
}), error && /* @__PURE__ */ React.createElement("p", {
|
|
5769
|
+
className: "trm-error"
|
|
5770
|
+
}, error), /* @__PURE__ */ React.createElement("div", {
|
|
5771
|
+
className: "trm-actions"
|
|
5772
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
5773
|
+
type: "button",
|
|
5774
|
+
className: "ta-button ta-primary",
|
|
5775
|
+
disabled: busy || !enough,
|
|
5776
|
+
onClick: done
|
|
5777
|
+
}, busy ? /* @__PURE__ */ React.createElement("span", {
|
|
5778
|
+
className: "ta-spinner"
|
|
5779
|
+
}) : direct ? t("groupPickChat") : t("groupPickDone", { n: picked.length + 1 })))));
|
|
5780
|
+
}
|
|
5781
|
+
function openGroupPicker(fixed) {
|
|
5782
|
+
show(({ close }) => /* @__PURE__ */ React.createElement(GroupPicker, {
|
|
5783
|
+
fixed,
|
|
5784
|
+
close
|
|
5785
|
+
}));
|
|
5786
|
+
}
|
|
5485
5787
|
function InviteDialog2({ invite, close }) {
|
|
5486
5788
|
const [busy, setBusy] = React.useState(false);
|
|
5487
5789
|
const [error, setError] = React.useState();
|
|
@@ -5617,6 +5919,16 @@ var EN4 = {
|
|
|
5617
5919
|
rulesOthers: "Set by the owner; everyone’s Ta keeps them.",
|
|
5618
5920
|
approve: "Invited friends ask too",
|
|
5619
5921
|
approveHint: "Friends you or an admin invite are let in only once one of you agrees",
|
|
5922
|
+
guests: "Those from a browser come in",
|
|
5923
|
+
guestsHint: "Who opens the link in a browser joins without asking, and only chats; past {n} an hour you are asked",
|
|
5924
|
+
joining: "Joining",
|
|
5925
|
+
capacity: "Members at most",
|
|
5926
|
+
capacityValue: "Up to {n}",
|
|
5927
|
+
linkDays: "The link that invites works",
|
|
5928
|
+
linkDaysValue7: "7 days",
|
|
5929
|
+
linkDaysValue30: "30 days",
|
|
5930
|
+
linkDaysValue365: "A year",
|
|
5931
|
+
linkDaysHint: "A new link is made: the one of before stops working.",
|
|
5620
5932
|
agents: "Agents may be invited",
|
|
5621
5933
|
agentsHint: "Members may bring their agents in to help",
|
|
5622
5934
|
doubles: "Doubles may answer for people",
|
|
@@ -5640,6 +5952,16 @@ var ZH4 = {
|
|
|
5640
5952
|
rulesOthers: "由群主设置,每个人的 Ta 都按这个执行。",
|
|
5641
5953
|
approve: "受邀的好友也要同意",
|
|
5642
5954
|
approveHint: "你或管理员邀请的好友,也要你们同意后才能进群",
|
|
5955
|
+
guests: "网页访客直接进",
|
|
5956
|
+
guestsHint: "用浏览器打开链接的人不用同意就能进群,只能聊天;每小时超过 {n} 人后仍要你同意",
|
|
5957
|
+
joining: "加入",
|
|
5958
|
+
capacity: "人数上限",
|
|
5959
|
+
capacityValue: "最多 {n} 人",
|
|
5960
|
+
linkDays: "邀请链接有效期",
|
|
5961
|
+
linkDaysValue7: "7 天",
|
|
5962
|
+
linkDaysValue30: "30 天",
|
|
5963
|
+
linkDaysValue365: "1 年",
|
|
5964
|
+
linkDaysHint: "会生成新链接,之前的链接失效。",
|
|
5643
5965
|
agents: "允许邀请智能体",
|
|
5644
5966
|
agentsHint: "成员可以请自己的智能体进群帮忙",
|
|
5645
5967
|
doubles: "允许分身代答",
|
|
@@ -5663,6 +5985,16 @@ var ZH_TW4 = {
|
|
|
5663
5985
|
rulesOthers: "由群主設定,每個人的 Ta 都按這個執行。",
|
|
5664
5986
|
approve: "受邀的好友也要同意",
|
|
5665
5987
|
approveHint: "你或管理員邀請的好友,也要你們同意後才能進群",
|
|
5988
|
+
guests: "網頁訪客直接進",
|
|
5989
|
+
guestsHint: "用瀏覽器開啟連結的人不用同意就能進群,只能聊天;每小時超過 {n} 人後仍要你同意",
|
|
5990
|
+
joining: "加入",
|
|
5991
|
+
capacity: "人數上限",
|
|
5992
|
+
capacityValue: "最多 {n} 人",
|
|
5993
|
+
linkDays: "邀請連結有效期",
|
|
5994
|
+
linkDaysValue7: "7 天",
|
|
5995
|
+
linkDaysValue30: "30 天",
|
|
5996
|
+
linkDaysValue365: "1 年",
|
|
5997
|
+
linkDaysHint: "會產生新連結,之前的連結失效。",
|
|
5666
5998
|
agents: "允許邀請智慧體",
|
|
5667
5999
|
agentsHint: "成員可以請自己的智慧體進群幫忙",
|
|
5668
6000
|
doubles: "允許分身代答",
|
|
@@ -5686,6 +6018,16 @@ var JA4 = {
|
|
|
5686
6018
|
rulesOthers: "グループ主が設定し、全員の Ta が守ります。",
|
|
5687
6019
|
approve: "招待した友だちも承認が必要",
|
|
5688
6020
|
approveHint: "あなたや管理者が招待した友だちも、承認されてから参加します",
|
|
6021
|
+
guests: "ブラウザからは承認なしで参加",
|
|
6022
|
+
guestsHint: "ブラウザでリンクを開いた人は承認なしで参加し、チャットのみできます。1 時間に {n} 人を超えると承認が必要です",
|
|
6023
|
+
joining: "参加",
|
|
6024
|
+
capacity: "人数の上限",
|
|
6025
|
+
capacityValue: "最大 {n} 人",
|
|
6026
|
+
linkDays: "招待リンクの有効期限",
|
|
6027
|
+
linkDaysValue7: "7 日",
|
|
6028
|
+
linkDaysValue30: "30 日",
|
|
6029
|
+
linkDaysValue365: "1 年",
|
|
6030
|
+
linkDaysHint: "新しいリンクを作成し、以前のリンクは無効になります。",
|
|
5689
6031
|
agents: "エージェントの招待を許可",
|
|
5690
6032
|
agentsHint: "メンバーは自分のエージェントを招待して手伝わせることができます",
|
|
5691
6033
|
doubles: "分身の代理応答を許可",
|
|
@@ -5700,15 +6042,19 @@ function gt(key, values = {}) {
|
|
|
5700
6042
|
|
|
5701
6043
|
// web-src/group-rules-view.tsx
|
|
5702
6044
|
var ADMINS_MAX = 8;
|
|
6045
|
+
var GUESTS_PER_HOUR = 30;
|
|
6046
|
+
var OWN_RULES = ["approve", "guests"];
|
|
5703
6047
|
var SWITCHES = [
|
|
5704
6048
|
{ rule: "approve", label: () => gt("approve"), hint: () => gt("approveHint") },
|
|
6049
|
+
{ rule: "guests", label: () => gt("guests"), hint: () => gt("guestsHint", { n: GUESTS_PER_HOUR }) },
|
|
5705
6050
|
...ROOM_RULES.map((rule) => ({ rule, label: () => gt(rule), hint: () => gt(`${rule}Hint`) }))
|
|
5706
6051
|
];
|
|
6052
|
+
var isOwn = (rule) => OWN_RULES.includes(rule);
|
|
5707
6053
|
function isOn(room, rule) {
|
|
5708
|
-
return rule
|
|
6054
|
+
return isOwn(rule) ? room.rules?.[rule] === true : room.rules?.[rule] !== false;
|
|
5709
6055
|
}
|
|
5710
6056
|
function countSet(room) {
|
|
5711
|
-
return SWITCHES.filter(({ rule }) => isOn(room, rule) !== (rule
|
|
6057
|
+
return SWITCHES.filter(({ rule }) => isOn(room, rule) !== !isOwn(rule)).length;
|
|
5712
6058
|
}
|
|
5713
6059
|
function GroupRulesRow({ room }) {
|
|
5714
6060
|
const Chevron = icon("ChevronRight");
|
|
@@ -5755,12 +6101,60 @@ function AdminRow({ room, member, admins }) {
|
|
|
5755
6101
|
onChange: (next) => configure(room, { admins: next ? [...admins, member.member] : admins.filter((id) => id !== member.member) })
|
|
5756
6102
|
}));
|
|
5757
6103
|
}
|
|
6104
|
+
function Joining({ room }) {
|
|
6105
|
+
const [menu, openMenu] = pi.ui.useContextMenu();
|
|
6106
|
+
const days = useLinkDays(room.id);
|
|
6107
|
+
const Check = icon("Check");
|
|
6108
|
+
const choose = (event, items) => openMenu(event, [items.map((item) => ({ key: item.key, label: item.label, ...item.on ? { icon: Check } : {}, run: item.run }))]);
|
|
6109
|
+
const capacity = room.capacity ?? MEMBER_CHOICES[0];
|
|
6110
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
6111
|
+
className: "trm-panel-label"
|
|
6112
|
+
}, gt("joining")), /* @__PURE__ */ React.createElement(JoinRow, {
|
|
6113
|
+
label: gt("capacity"),
|
|
6114
|
+
value: gt("capacityValue", { n: capacity }),
|
|
6115
|
+
onClick: (event) => choose(event, MEMBER_CHOICES.map((n) => ({
|
|
6116
|
+
key: String(n),
|
|
6117
|
+
label: gt("capacityValue", { n }),
|
|
6118
|
+
on: n === capacity,
|
|
6119
|
+
run: () => void configure(room, { members: n }).catch(() => {
|
|
6120
|
+
return;
|
|
6121
|
+
})
|
|
6122
|
+
})))
|
|
6123
|
+
}), /* @__PURE__ */ React.createElement(JoinRow, {
|
|
6124
|
+
label: gt("linkDays"),
|
|
6125
|
+
value: gt(`linkDaysValue${days}`),
|
|
6126
|
+
onClick: (event) => choose(event, LINK_DAYS.map((n) => ({
|
|
6127
|
+
key: String(n),
|
|
6128
|
+
label: gt(`linkDaysValue${n}`),
|
|
6129
|
+
on: n === days,
|
|
6130
|
+
run: () => void setLinkDays(room.id, n).then(() => pi.ui.notify(gt("linkDaysHint"))).catch((error) => pi.ui.notify(message(error), "error"))
|
|
6131
|
+
})))
|
|
6132
|
+
}), menu, /* @__PURE__ */ React.createElement("div", {
|
|
6133
|
+
className: "trm-panel-sep"
|
|
6134
|
+
}));
|
|
6135
|
+
}
|
|
6136
|
+
function JoinRow({ label, value, onClick }) {
|
|
6137
|
+
const Chevron = icon("ChevronRight");
|
|
6138
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
6139
|
+
type: "button",
|
|
6140
|
+
className: "trm-setting",
|
|
6141
|
+
onClick
|
|
6142
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
6143
|
+
className: "trm-setting-label"
|
|
6144
|
+
}, label), /* @__PURE__ */ React.createElement("span", {
|
|
6145
|
+
className: "trm-setting-value trm-ellipsis"
|
|
6146
|
+
}, value), /* @__PURE__ */ React.createElement(Chevron, {
|
|
6147
|
+
size: 15
|
|
6148
|
+
}));
|
|
6149
|
+
}
|
|
5758
6150
|
function GroupRulesView({ room }) {
|
|
5759
6151
|
const candidates = room.members.filter((member) => !member.owner && !member.guest && !member.self);
|
|
5760
6152
|
const admins = room.members.filter((member) => member.admin).map((member) => member.member);
|
|
5761
6153
|
return /* @__PURE__ */ React.createElement("div", {
|
|
5762
6154
|
className: "trm-rules"
|
|
5763
|
-
}, room.owner && /* @__PURE__ */ React.createElement(
|
|
6155
|
+
}, room.owner && /* @__PURE__ */ React.createElement(Joining, {
|
|
6156
|
+
room
|
|
6157
|
+
}), room.owner && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
5764
6158
|
className: "trm-panel-label"
|
|
5765
6159
|
}, gt("admins")), /* @__PURE__ */ React.createElement("p", {
|
|
5766
6160
|
className: "trm-note trm-panel-note"
|
|
@@ -5995,7 +6389,21 @@ function MembersView() {
|
|
|
5995
6389
|
className: "trm-panel-label"
|
|
5996
6390
|
}, t("membersCount", { n: room.members.length, online })), /* @__PURE__ */ React.createElement("ul", {
|
|
5997
6391
|
className: "trm-panel-members"
|
|
5998
|
-
},
|
|
6392
|
+
}, peerFriend && !!pi.rooms && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
6393
|
+
type: "button",
|
|
6394
|
+
className: "trm-member trm-member-add",
|
|
6395
|
+
onClick: () => pi.ui.startGroup ? pi.ui.startGroup(peerFriend.id) : openGroupPicker(peerFriend)
|
|
6396
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
6397
|
+
className: "trm-member-plus"
|
|
6398
|
+
}, /* @__PURE__ */ React.createElement(Plus, {
|
|
6399
|
+
size: 16
|
|
6400
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
6401
|
+
className: "trm-member-text"
|
|
6402
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
6403
|
+
className: "trm-member-name"
|
|
6404
|
+
}, t("directGroup")), /* @__PURE__ */ React.createElement("span", {
|
|
6405
|
+
className: "trm-member-detail"
|
|
6406
|
+
}, t("directGroupLine", { name: peerFriend.name }))))), (room.owner || room.admin) && !direct && !!pi.rooms && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
5999
6407
|
type: "button",
|
|
6000
6408
|
className: "trm-member trm-member-add",
|
|
6001
6409
|
onClick: () => openFriendPicker(room)
|
|
@@ -6257,7 +6665,12 @@ function RoomList({ openMenu }) {
|
|
|
6257
6665
|
const { identity, rooms: list, requests, groupInvites: invites, opened, seen } = useBook();
|
|
6258
6666
|
const groupInvites = invites.filter((invite) => !DirectUtil.is(invite));
|
|
6259
6667
|
const { asks } = useDoubles();
|
|
6260
|
-
const
|
|
6668
|
+
const kept = useDirects();
|
|
6669
|
+
const shown = React.useMemo(() => {
|
|
6670
|
+
const extra = new Set(DirectUtil.extra(list ?? [], kept).map((room) => room.id));
|
|
6671
|
+
return (list ?? []).filter((room) => !extra.has(room.id));
|
|
6672
|
+
}, [list, kept]);
|
|
6673
|
+
const sorted = useSorted(shown);
|
|
6261
6674
|
return /* @__PURE__ */ React.createElement("div", {
|
|
6262
6675
|
className: "trm-list"
|
|
6263
6676
|
}, asks.length > 0 && /* @__PURE__ */ React.createElement("section", {
|
|
@@ -6306,7 +6719,7 @@ function RoomList({ openMenu }) {
|
|
|
6306
6719
|
function addMenu() {
|
|
6307
6720
|
return [
|
|
6308
6721
|
[
|
|
6309
|
-
{ key: "new", label: t("newRoom"), icon: icon("MessagesSquare"), run: () =>
|
|
6722
|
+
{ key: "new", label: t("newRoom"), icon: icon("MessagesSquare"), run: () => pi.ui.startGroup ? pi.ui.startGroup() : openGroupPicker() },
|
|
6310
6723
|
{ key: "link", label: t("joinByLink"), icon: icon("Link"), run: () => void pasteLink() },
|
|
6311
6724
|
...pi.ui.scanCode ? [{ key: "scan", label: t("scan"), icon: icon("ScanLine"), run: () => void scanLink() }] : []
|
|
6312
6725
|
],
|
|
@@ -6519,7 +6932,9 @@ class RoomsHome {
|
|
|
6519
6932
|
const { rooms: rooms2 = [], seen, friends, friendRequests, requests } = book.get();
|
|
6520
6933
|
const groupInvites = book.get().groupInvites.filter((invite) => !DirectUtil.is(invite));
|
|
6521
6934
|
const sent = this.partners ? FriendShares.get() : [];
|
|
6522
|
-
const
|
|
6935
|
+
const extra = new Set(DirectUtil.extra(rooms2, directs.get()).map((room) => room.id));
|
|
6936
|
+
tidyDirects(rooms2);
|
|
6937
|
+
const joined = this.shown || this.partners ? rooms2.filter((room) => room.status === "member" && !extra.has(room.id)) : [];
|
|
6523
6938
|
this.follow(joined);
|
|
6524
6939
|
const rows = joined.map((room) => ({ room, lines: book.chat(room.id)?.lines ?? [] })).sort((a, b) => lastAt(b.room) - lastAt(a.room));
|
|
6525
6940
|
const signature = [
|
|
@@ -6724,6 +7139,233 @@ function roomsSettings() {
|
|
|
6724
7139
|
};
|
|
6725
7140
|
}
|
|
6726
7141
|
|
|
7142
|
+
// web-src/rooms-partners.tsx
|
|
7143
|
+
var NAME = "@celljs/ta-rooms";
|
|
7144
|
+
var CHANNELS = "@celljs/ta-channels";
|
|
7145
|
+
|
|
7146
|
+
class RoomsPartners {
|
|
7147
|
+
current = [];
|
|
7148
|
+
signature = "";
|
|
7149
|
+
listeners = new Set;
|
|
7150
|
+
chats = new Map;
|
|
7151
|
+
faces = new Map;
|
|
7152
|
+
partners = () => this.current;
|
|
7153
|
+
subscribe = (listener) => {
|
|
7154
|
+
this.listeners.add(listener);
|
|
7155
|
+
return () => this.listeners.delete(listener);
|
|
7156
|
+
};
|
|
7157
|
+
start() {
|
|
7158
|
+
const stops = [
|
|
7159
|
+
book.subscribe(() => this.refresh()),
|
|
7160
|
+
directs.subscribe(() => this.refresh()),
|
|
7161
|
+
FriendShares.subscribe(() => this.refresh()),
|
|
7162
|
+
FriendShares.start()
|
|
7163
|
+
];
|
|
7164
|
+
this.refresh();
|
|
7165
|
+
return () => {
|
|
7166
|
+
for (const stop of stops) {
|
|
7167
|
+
stop();
|
|
7168
|
+
}
|
|
7169
|
+
for (const stop of this.chats.values()) {
|
|
7170
|
+
stop();
|
|
7171
|
+
}
|
|
7172
|
+
this.chats.clear();
|
|
7173
|
+
};
|
|
7174
|
+
}
|
|
7175
|
+
add() {
|
|
7176
|
+
return [
|
|
7177
|
+
{ key: "friend", label: t("addFriend"), icon: icon("UserPlus"), run: openAddFriend },
|
|
7178
|
+
...pi.ui.scanCode ? [{ key: "scan", label: t("scan"), icon: icon("ScanLine"), run: () => void scanLink() }] : []
|
|
7179
|
+
];
|
|
7180
|
+
}
|
|
7181
|
+
async group(members) {
|
|
7182
|
+
const friend = (member) => member.extension === NAME && member.kind === "friend";
|
|
7183
|
+
const agent = (member) => member.extension === CHANNELS && member.kind === "agent";
|
|
7184
|
+
const server = rooms();
|
|
7185
|
+
if (!server?.inviteFriends || !members.some(friend) || !members.every((member) => friend(member) || agent(member))) {
|
|
7186
|
+
return false;
|
|
7187
|
+
}
|
|
7188
|
+
const room = await server.createRoom({ kind: ROOMS_KIND, title: groupTitle([book.get().identity?.name ?? "", ...members.map((member) => member.name)]) });
|
|
7189
|
+
await server.inviteFriends(room.id, members.filter(friend).map((member) => member.id));
|
|
7190
|
+
for (const member of members.filter(agent)) {
|
|
7191
|
+
await callDoubles({ kind: "invite", room: room.id, agent: member.id }).catch((error) => pi.ui.notify(error instanceof Error ? error.message : String(error), "error"));
|
|
7192
|
+
}
|
|
7193
|
+
await book.load();
|
|
7194
|
+
await openRoom(room.id, true);
|
|
7195
|
+
return true;
|
|
7196
|
+
}
|
|
7197
|
+
refresh() {
|
|
7198
|
+
const state = book.get();
|
|
7199
|
+
const { rooms: list = [], seen, friends = [], friendRequests, requests } = state;
|
|
7200
|
+
const invites = state.groupInvites.filter((invite) => !DirectUtil.is(invite));
|
|
7201
|
+
const shares = FriendShares.get();
|
|
7202
|
+
const extra = new Set(DirectUtil.extra(list, directs.get()).map((room) => room.id));
|
|
7203
|
+
tidyDirects(list);
|
|
7204
|
+
const joined = list.filter((room) => room.status === "member" && !extra.has(room.id));
|
|
7205
|
+
this.follow(joined);
|
|
7206
|
+
const lines = (room) => book.chat(room.id)?.lines ?? [];
|
|
7207
|
+
const signature = [
|
|
7208
|
+
pi.ui.language,
|
|
7209
|
+
...friends.map((friend) => [friend.id, friend.name, friend.look, friend.status, friend.online ? 1 : 0].join("/")),
|
|
7210
|
+
...friendRequests.map((request) => `${request.id}/${request.at}`),
|
|
7211
|
+
...requests.map((request) => `${request.room}/${request.ask}`),
|
|
7212
|
+
...invites.map((invite) => invite.room),
|
|
7213
|
+
...shares.map((share) => `${share.id}/${share.seen ? 1 : 0}`),
|
|
7214
|
+
...joined.map((room) => [
|
|
7215
|
+
room.id,
|
|
7216
|
+
room.title,
|
|
7217
|
+
room.members.length,
|
|
7218
|
+
lines(room).at(-1)?.id ?? "",
|
|
7219
|
+
unseen(room, lines(room), seen) ? 1 : 0,
|
|
7220
|
+
Object.keys(directs.get()).length
|
|
7221
|
+
].join(":"))
|
|
7222
|
+
].join("|");
|
|
7223
|
+
if (signature === this.signature) {
|
|
7224
|
+
return;
|
|
7225
|
+
}
|
|
7226
|
+
this.signature = signature;
|
|
7227
|
+
const directOf = new Map;
|
|
7228
|
+
for (const room of joined.filter(DirectUtil.is)) {
|
|
7229
|
+
const peer = DirectUtil.friendOf(room, directs.get());
|
|
7230
|
+
if (peer) {
|
|
7231
|
+
directOf.set(peer, room);
|
|
7232
|
+
}
|
|
7233
|
+
}
|
|
7234
|
+
this.current = [
|
|
7235
|
+
...friendRequests.map((request) => this.asking(request)),
|
|
7236
|
+
...friends.map((friend) => this.friend(friend, directOf.get(friend.id), shares.filter((share) => share.by.id === friend.id && !share.seen).at(-1))),
|
|
7237
|
+
...requests.map((request) => this.joining(request)),
|
|
7238
|
+
...invites.map((invite) => this.invited(invite)),
|
|
7239
|
+
...joined.filter((room) => !DirectUtil.is(room)).map((room) => this.groupOf(room))
|
|
7240
|
+
];
|
|
7241
|
+
for (const listener of this.listeners) {
|
|
7242
|
+
listener();
|
|
7243
|
+
}
|
|
7244
|
+
}
|
|
7245
|
+
friend(friend, direct, share) {
|
|
7246
|
+
const said = direct ? book.chat(direct.id)?.lines ?? [] : [];
|
|
7247
|
+
const at = direct ? lastAt(direct) : undefined;
|
|
7248
|
+
const shared = share && (at === undefined || share.at > at) ? share : undefined;
|
|
7249
|
+
const online = friend.status === "friend" ? friend.online : undefined;
|
|
7250
|
+
return {
|
|
7251
|
+
id: friend.id,
|
|
7252
|
+
kind: "friend",
|
|
7253
|
+
name: friend.name,
|
|
7254
|
+
face: this.faceOf(`friend:${friend.id}`, ({ size }) => /* @__PURE__ */ React.createElement(Face, {
|
|
7255
|
+
id: friend.id,
|
|
7256
|
+
name: friend.name,
|
|
7257
|
+
size
|
|
7258
|
+
})),
|
|
7259
|
+
icon: icon("Contact"),
|
|
7260
|
+
...friend.status === "adding" ? { status: "waiting", about: t("friendAdding") } : {},
|
|
7261
|
+
...online ? { online } : {},
|
|
7262
|
+
chat: shared ? { last: t("friendShareRow", { title: shared.title || shared.link }), at: shared.at, unseen: true } : direct ? { last: roomPreview(direct, said.at(-1)) || undefined, at, unseen: unseen(direct, said, book.get().seen) } : undefined,
|
|
7263
|
+
open: () => shared ? openFriendShare(shared) : friend.status === "friend" ? openDirect(friend) : openFriend(friend.id),
|
|
7264
|
+
...direct ? { menu: () => [[{ key: "delete", label: rt("directDelete"), danger: true, run: () => void leaveRoom(direct) }]] } : {}
|
|
7265
|
+
};
|
|
7266
|
+
}
|
|
7267
|
+
groupOf(room) {
|
|
7268
|
+
const said = book.chat(room.id)?.lines ?? [];
|
|
7269
|
+
return {
|
|
7270
|
+
id: room.id,
|
|
7271
|
+
kind: "group",
|
|
7272
|
+
name: room.title,
|
|
7273
|
+
face: this.faceOf(`room:${room.id}`, ({ size }) => /* @__PURE__ */ React.createElement(RoomFaceOf, {
|
|
7274
|
+
id: room.id,
|
|
7275
|
+
size
|
|
7276
|
+
})),
|
|
7277
|
+
icon: icon("Users"),
|
|
7278
|
+
about: t("roomOf", { name: room.ownerName }),
|
|
7279
|
+
chat: { last: roomPreview(room, said.at(-1)) || undefined, at: lastAt(room), unseen: unseen(room, said, book.get().seen) },
|
|
7280
|
+
open: () => openRoom(room.id, true),
|
|
7281
|
+
menu: () => [[{ key: "leave", label: room.owner ? t("close") : t("leave"), danger: true, run: () => void leaveRoom(room) }]]
|
|
7282
|
+
};
|
|
7283
|
+
}
|
|
7284
|
+
asking(request) {
|
|
7285
|
+
return {
|
|
7286
|
+
id: `friend-request:${request.id}`,
|
|
7287
|
+
kind: "friend",
|
|
7288
|
+
name: request.name,
|
|
7289
|
+
face: ({ size }) => /* @__PURE__ */ React.createElement(Face, {
|
|
7290
|
+
id: request.id,
|
|
7291
|
+
name: request.name,
|
|
7292
|
+
size
|
|
7293
|
+
}),
|
|
7294
|
+
icon: icon("UserPlus"),
|
|
7295
|
+
status: "asking",
|
|
7296
|
+
about: request.via === "room" && request.room ? t("friendRequestRoom", { room: request.room }) : t("friendRequestLink"),
|
|
7297
|
+
open: openFriendRequests
|
|
7298
|
+
};
|
|
7299
|
+
}
|
|
7300
|
+
joining(request) {
|
|
7301
|
+
return {
|
|
7302
|
+
id: `request:${request.room}:${request.ask}`,
|
|
7303
|
+
kind: "group",
|
|
7304
|
+
name: request.name,
|
|
7305
|
+
face: ({ size }) => /* @__PURE__ */ React.createElement(Face, {
|
|
7306
|
+
id: request.id,
|
|
7307
|
+
name: request.name,
|
|
7308
|
+
size
|
|
7309
|
+
}),
|
|
7310
|
+
icon: icon("UserPlus"),
|
|
7311
|
+
status: "asking",
|
|
7312
|
+
about: t("requestLine", { title: request.title }),
|
|
7313
|
+
open: openRequests
|
|
7314
|
+
};
|
|
7315
|
+
}
|
|
7316
|
+
invited(invite) {
|
|
7317
|
+
return {
|
|
7318
|
+
id: `invite:${invite.room}`,
|
|
7319
|
+
kind: "group",
|
|
7320
|
+
name: invite.title,
|
|
7321
|
+
face: ({ size }) => /* @__PURE__ */ React.createElement(Face, {
|
|
7322
|
+
id: invite.by.id,
|
|
7323
|
+
name: invite.by.name,
|
|
7324
|
+
size
|
|
7325
|
+
}),
|
|
7326
|
+
icon: icon("MessagesSquare"),
|
|
7327
|
+
status: "invited",
|
|
7328
|
+
about: t("groupInviteLine", { name: invite.by.name }),
|
|
7329
|
+
open: () => openGroupInvite(invite)
|
|
7330
|
+
};
|
|
7331
|
+
}
|
|
7332
|
+
faceOf(key, face) {
|
|
7333
|
+
let kept = this.faces.get(key);
|
|
7334
|
+
if (!kept) {
|
|
7335
|
+
kept = face;
|
|
7336
|
+
this.faces.set(key, kept);
|
|
7337
|
+
}
|
|
7338
|
+
return kept;
|
|
7339
|
+
}
|
|
7340
|
+
follow(joined) {
|
|
7341
|
+
const ids = new Set(joined.map((room) => room.id));
|
|
7342
|
+
for (const [id, stop] of this.chats) {
|
|
7343
|
+
if (!ids.has(id)) {
|
|
7344
|
+
stop();
|
|
7345
|
+
this.chats.delete(id);
|
|
7346
|
+
}
|
|
7347
|
+
}
|
|
7348
|
+
for (const room of joined) {
|
|
7349
|
+
if (!this.chats.has(room.id)) {
|
|
7350
|
+
const stop = book.chat(room.id)?.subscribe(() => this.refresh());
|
|
7351
|
+
this.chats.set(room.id, stop ?? (() => {
|
|
7352
|
+
return;
|
|
7353
|
+
}));
|
|
7354
|
+
}
|
|
7355
|
+
}
|
|
7356
|
+
}
|
|
7357
|
+
}
|
|
7358
|
+
function RoomFaceOf({ id, size }) {
|
|
7359
|
+
const room = React.useSyncExternalStore((listener) => book.subscribe(listener), () => book.get().rooms?.find((each) => each.id === id));
|
|
7360
|
+
return room ? DirectUtil.is(room) ? /* @__PURE__ */ React.createElement(DirectFace, {
|
|
7361
|
+
room,
|
|
7362
|
+
size
|
|
7363
|
+
}) : /* @__PURE__ */ React.createElement(RoomFace, {
|
|
7364
|
+
room,
|
|
7365
|
+
size
|
|
7366
|
+
}) : null;
|
|
7367
|
+
}
|
|
7368
|
+
|
|
6727
7369
|
// web-src/style.ts
|
|
6728
7370
|
var STYLE = `
|
|
6729
7371
|
.trm-ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
@@ -6938,6 +7580,11 @@ button.trm-member { cursor: pointer; }
|
|
|
6938
7580
|
.trm-try-alone { margin-top: 12px; }
|
|
6939
7581
|
.trm-chat-joining { display: inline-flex; align-self: center; align-items: center; gap: 8px; margin: 10px 0 4px; padding: 6px 12px; border-radius: 999px; background: var(--ta-hover); color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
6940
7582
|
.trm-agent-pick .trm-member:disabled { cursor: default; opacity: 1; }
|
|
7583
|
+
.trm-group-pick { max-height: min(56vh, 420px); overflow-y: auto; }
|
|
7584
|
+
.trm-group-pick .trm-member:disabled { cursor: default; opacity: 1; }
|
|
7585
|
+
.trm-pick-box { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border: 1.5px solid var(--ta-border-field); border-radius: 50%; color: #fff; transition: background 0.12s, border-color 0.12s; }
|
|
7586
|
+
.trm-pick-on { border-color: var(--ta-green); background: var(--ta-green); }
|
|
7587
|
+
.trm-group-pick .trm-member:disabled .trm-pick-on { opacity: 0.5; }
|
|
6941
7588
|
.trm-agent-pick .trm-member:disabled .trm-member-detail { color: var(--ta-green); }
|
|
6942
7589
|
.trm-member-may { color: var(--ta-secondary); }
|
|
6943
7590
|
.trm-member-action.trm-on-icon { opacity: 1; color: var(--ta-green); }
|
|
@@ -7087,11 +7734,16 @@ function activate(pi2) {
|
|
|
7087
7734
|
const stopDirects = pi2.rooms ? directs.start() : () => {
|
|
7088
7735
|
return;
|
|
7089
7736
|
};
|
|
7090
|
-
const
|
|
7091
|
-
const
|
|
7737
|
+
const shared = pi2.rooms && typeof pi2.registerPartners === "function" ? new RoomsPartners : undefined;
|
|
7738
|
+
const home = shared ? undefined : new RoomsHome(partners2);
|
|
7739
|
+
const stopHome = !pi2.rooms ? () => {
|
|
7092
7740
|
return;
|
|
7093
|
-
}
|
|
7094
|
-
|
|
7741
|
+
} : shared ? shared.start() : home?.start() ?? (() => {
|
|
7742
|
+
return;
|
|
7743
|
+
});
|
|
7744
|
+
if (shared) {
|
|
7745
|
+
pi2.registerPartners(shared);
|
|
7746
|
+
} else if (pi2.rooms && home) {
|
|
7095
7747
|
pi2.registerHomeItems?.(home);
|
|
7096
7748
|
}
|
|
7097
7749
|
const stopAsks = pi2.rooms ? listenAsks() : () => {
|