@celljs/ta-rooms 4.20.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 +141 -20
- package/host/index.mjs +793 -191
- package/package.json +4 -4
- package/web/index.js +2842 -452
package/web/index.js
CHANGED
|
@@ -193,6 +193,126 @@ var RelayIdentityUtil;
|
|
|
193
193
|
}
|
|
194
194
|
})(RelayIdentityUtil || (RelayIdentityUtil = {}));
|
|
195
195
|
|
|
196
|
+
// ../ta-relay/esm/common/relay-hub-charter.js
|
|
197
|
+
var RELAY_HUB_MAX_ADMINS = 8;
|
|
198
|
+
var MAX_RULES = 16;
|
|
199
|
+
var RelayHubCharterUtil;
|
|
200
|
+
(function(RelayHubCharterUtil2) {
|
|
201
|
+
function rules(input) {
|
|
202
|
+
if (!input || typeof input !== "object") {
|
|
203
|
+
return {};
|
|
204
|
+
}
|
|
205
|
+
return Object.fromEntries(Object.entries(input).filter(([name, value]) => /^[a-z][a-zA-Z]{0,30}$/.test(name) && typeof value === "boolean").slice(0, MAX_RULES));
|
|
206
|
+
}
|
|
207
|
+
RelayHubCharterUtil2.rules = rules;
|
|
208
|
+
async function seal(owner, body) {
|
|
209
|
+
const p = JSON.stringify(body);
|
|
210
|
+
return { p, s: await RelayIdentityUtil.sign(owner, p) };
|
|
211
|
+
}
|
|
212
|
+
RelayHubCharterUtil2.seal = seal;
|
|
213
|
+
async function open(ownerSign, room, charter) {
|
|
214
|
+
try {
|
|
215
|
+
const { p, s } = charter;
|
|
216
|
+
if (typeof p !== "string" || typeof s !== "string" || !await RelayIdentityUtil.verify(ownerSign, p, s)) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const body = JSON.parse(p);
|
|
220
|
+
if (body.room !== room || !(Number(body.v) > 0) || !Array.isArray(body.admins)) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const capacity = Math.round(Number(body.capacity));
|
|
224
|
+
return {
|
|
225
|
+
room,
|
|
226
|
+
v: Number(body.v),
|
|
227
|
+
admins: body.admins.filter((admin) => admin && typeof admin.member === "string" && typeof admin.id === "string").slice(0, RELAY_HUB_MAX_ADMINS).map((admin) => ({ member: admin.member, id: admin.id })),
|
|
228
|
+
rules: rules(body.rules),
|
|
229
|
+
...capacity >= 2 ? { capacity } : {}
|
|
230
|
+
};
|
|
231
|
+
} catch (_a) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
RelayHubCharterUtil2.open = open;
|
|
236
|
+
async function openRoster(keys, sealed, owner, room) {
|
|
237
|
+
try {
|
|
238
|
+
const found = RelayHubUtil.keyFor(keys, sealed);
|
|
239
|
+
if (!found) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const envelope = JSON.parse(await RelayKeys.open(found.key, found.sealed));
|
|
243
|
+
const signed = JSON.parse(envelope.p);
|
|
244
|
+
if (!(signed === null || signed === undefined ? undefined : signed.b) || !Array.isArray(signed.b.members) || typeof signed.m !== "string") {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const members = signed.b.members.filter((member) => !!member && typeof member.member === "string");
|
|
248
|
+
const head = members.find((member) => member.owner && member.id === owner.id);
|
|
249
|
+
if (!head) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const charter = signed.b.charter ? await open(owner.sign, room, signed.b.charter) : undefined;
|
|
253
|
+
let key;
|
|
254
|
+
let byAdmin = false;
|
|
255
|
+
if (signed.m === head.member) {
|
|
256
|
+
key = owner.sign;
|
|
257
|
+
} else {
|
|
258
|
+
const named = charter === null || charter === undefined ? undefined : charter.admins.find((admin) => admin.member === signed.m);
|
|
259
|
+
const entry = named && members.find((member) => member.member === named.member && member.id === named.id && !member.owner && !member.guest);
|
|
260
|
+
if (entry && await RelayIdentityUtil.check(entry)) {
|
|
261
|
+
key = entry.sign;
|
|
262
|
+
byAdmin = true;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (!key || !await RelayIdentityUtil.verify(key, envelope.p, envelope.s)) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
signer: signed.m,
|
|
270
|
+
byAdmin,
|
|
271
|
+
body: { v: Number(signed.b.v), members, ...signed.b.charter ? { charter: signed.b.charter } : {} },
|
|
272
|
+
...charter ? { charter } : {}
|
|
273
|
+
};
|
|
274
|
+
} catch (_a) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
RelayHubCharterUtil2.openRoster = openRoster;
|
|
279
|
+
function adminMay(next, before) {
|
|
280
|
+
const charter = next.charter;
|
|
281
|
+
if (!charter || (before === null || before === undefined ? undefined : before.charter) && charter.v < before.charter.v) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
const has = (member) => next.body.members.some((each) => each.member === member);
|
|
285
|
+
if (!charter.admins.every((admin) => has(admin.member))) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
const head = before === null || before === undefined ? undefined : before.members.find((member) => member.owner);
|
|
289
|
+
if (head && !next.body.members.some((member) => member.member === head.member && member.owner && member.id === head.id)) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
return next.body.members.every((member) => {
|
|
293
|
+
const was = before === null || before === undefined ? undefined : before.members.find((each) => each.member === member.member);
|
|
294
|
+
return !was || was.id === member.id && !!was.owner === !!member.owner;
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
RelayHubCharterUtil2.adminMay = adminMay;
|
|
298
|
+
function answerProof(head, charter) {
|
|
299
|
+
return { head: RelayIdentityUtil.publicOf(head), charter };
|
|
300
|
+
}
|
|
301
|
+
RelayHubCharterUtil2.answerProof = answerProof;
|
|
302
|
+
async function answeredBy(signer, ownerId, room, proof) {
|
|
303
|
+
if (signer.id === ownerId) {
|
|
304
|
+
return await RelayIdentityUtil.check(signer) ? signer : undefined;
|
|
305
|
+
}
|
|
306
|
+
const head = proof.head;
|
|
307
|
+
if (!head || head.id !== ownerId || !await RelayIdentityUtil.check(head) || !await RelayIdentityUtil.check(signer)) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const charter = await open(head.sign, room, proof.charter);
|
|
311
|
+
return (charter === null || charter === undefined ? undefined : charter.admins.some((admin) => admin.id === signer.id)) ? head : undefined;
|
|
312
|
+
}
|
|
313
|
+
RelayHubCharterUtil2.answeredBy = answeredBy;
|
|
314
|
+
})(RelayHubCharterUtil || (RelayHubCharterUtil = {}));
|
|
315
|
+
|
|
196
316
|
// ../ta-relay/esm/common/relay-hub-util.js
|
|
197
317
|
var RelayHubUtil;
|
|
198
318
|
(function(RelayHubUtil2) {
|
|
@@ -248,15 +368,38 @@ var RelayHubUtil;
|
|
|
248
368
|
return RelayBytes.toBase64(RelayBytes.random(32));
|
|
249
369
|
}
|
|
250
370
|
RelayHubUtil2.randomKey = randomKey;
|
|
251
|
-
async function keys(roomKey) {
|
|
371
|
+
async function keys(roomKey, epochs = {}) {
|
|
252
372
|
const key = RelayBytes.fromBase64(roomKey);
|
|
253
373
|
const none = new Uint8Array(0);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
374
|
+
const sealOf = async (value) => RelayKeys.aesKey(await RelayKeys.hkdf(value, none, "ta-room/1 seal"));
|
|
375
|
+
const ring = new Map([[0, await sealOf(key)]]);
|
|
376
|
+
for (const [epoch2, value] of Object.entries(epochs)) {
|
|
377
|
+
const n = Number(epoch2);
|
|
378
|
+
if (Number.isInteger(n) && n > 0) {
|
|
379
|
+
ring.set(n, await sealOf(RelayBytes.fromBase64(value)));
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
const epoch = Math.max(...ring.keys());
|
|
383
|
+
return { seal: ring.get(epoch), names: await RelayKeys.hkdf(key, none, "ta-room/1 key"), epoch, ring };
|
|
258
384
|
}
|
|
259
385
|
RelayHubUtil2.keys = keys;
|
|
386
|
+
async function sealIn(keys2, identity, member, body, at = Date.now()) {
|
|
387
|
+
const sealed = await seal(keys2.seal, identity, member, body, at);
|
|
388
|
+
return keys2.epoch ? `${keys2.epoch}.${sealed}` : sealed;
|
|
389
|
+
}
|
|
390
|
+
RelayHubUtil2.sealIn = sealIn;
|
|
391
|
+
function keyFor(keys2, sealed) {
|
|
392
|
+
const dot = sealed.indexOf(".");
|
|
393
|
+
const epoch = dot > 0 ? Number(sealed.slice(0, dot)) : 0;
|
|
394
|
+
const key = Number.isInteger(epoch) ? keys2.ring.get(epoch) : undefined;
|
|
395
|
+
return key && { key, sealed: dot > 0 ? sealed.slice(dot + 1) : sealed, epoch };
|
|
396
|
+
}
|
|
397
|
+
RelayHubUtil2.keyFor = keyFor;
|
|
398
|
+
async function openIn(keys2, sealed, signOf, options = {}) {
|
|
399
|
+
const found = keyFor(keys2, String(sealed));
|
|
400
|
+
return found ? open(found.key, found.sealed, signOf, options) : undefined;
|
|
401
|
+
}
|
|
402
|
+
RelayHubUtil2.openIn = openIn;
|
|
260
403
|
async function keyId(keys2, name) {
|
|
261
404
|
return (await RelayKeys.hmac(keys2.names, name)).slice(0, 22);
|
|
262
405
|
}
|
|
@@ -317,20 +460,21 @@ var RelayHubUtil;
|
|
|
317
460
|
}
|
|
318
461
|
}
|
|
319
462
|
RelayHubUtil2.openAsk = openAsk;
|
|
320
|
-
async function sealAnswer(owner, room, ask, body, invite) {
|
|
463
|
+
async function sealAnswer(owner, room, ask, body, invite, proof) {
|
|
321
464
|
const key = await RelayKeys.aesKey(await RelayIdentityUtil.agree(owner, ask.box, room, "ta-room/1 answer"));
|
|
322
465
|
const d = await RelayKeys.seal(key, JSON.stringify(body));
|
|
323
466
|
const signed = `${room}
|
|
324
467
|
${ask.member}
|
|
325
468
|
${d}`;
|
|
326
|
-
const answer = JSON.stringify({ owner: RelayIdentityUtil.publicOf(owner), d, s: await RelayIdentityUtil.sign(owner, signed) });
|
|
469
|
+
const answer = JSON.stringify({ owner: RelayIdentityUtil.publicOf(owner), d, s: await RelayIdentityUtil.sign(owner, signed), ...proof !== null && proof !== undefined ? proof : {} });
|
|
327
470
|
return RelayKeys.seal(await inviteKey(invite), answer);
|
|
328
471
|
}
|
|
329
472
|
RelayHubUtil2.sealAnswer = sealAnswer;
|
|
330
473
|
async function openAnswer(identity, room, member, ownerId, answer, invite) {
|
|
331
474
|
try {
|
|
332
|
-
const { owner, d, s } = JSON.parse(await RelayKeys.open(await inviteKey(invite), answer));
|
|
333
|
-
|
|
475
|
+
const { owner, d, s, head, charter } = JSON.parse(await RelayKeys.open(await inviteKey(invite), answer));
|
|
476
|
+
const named = await RelayHubCharterUtil.answeredBy(owner, ownerId, room, { head, charter });
|
|
477
|
+
if (!named || !await RelayIdentityUtil.verify(owner.sign, `${room}
|
|
334
478
|
${member}
|
|
335
479
|
${d}`, s)) {
|
|
336
480
|
return;
|
|
@@ -338,7 +482,7 @@ ${d}`, s)) {
|
|
|
338
482
|
const key = await RelayKeys.aesKey(await RelayIdentityUtil.agree(identity, owner.box, room, "ta-room/1 answer"));
|
|
339
483
|
const body = JSON.parse(await RelayKeys.open(key, d));
|
|
340
484
|
RelayBytes.fromBase64(body.key);
|
|
341
|
-
return { owner: { ...RelayIdentityUtil.publicOf(
|
|
485
|
+
return { owner: { ...RelayIdentityUtil.publicOf(named), name: String(named.name).slice(0, 100) }, body };
|
|
342
486
|
} catch (_a) {
|
|
343
487
|
return;
|
|
344
488
|
}
|
|
@@ -509,6 +653,209 @@ var RelayFriendsUtil;
|
|
|
509
653
|
RelayFriendsUtil2.migrate = migrate;
|
|
510
654
|
})(RelayFriendsUtil || (RelayFriendsUtil = {}));
|
|
511
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
|
+
|
|
725
|
+
// web-src/double-protocol.ts
|
|
726
|
+
var DIRECT_KIND = "ta-direct";
|
|
727
|
+
var RoomAgentsUtil;
|
|
728
|
+
((RoomAgentsUtil) => {
|
|
729
|
+
function key(member) {
|
|
730
|
+
return `${ROOM_AGENTS_KEY}${member}`;
|
|
731
|
+
}
|
|
732
|
+
RoomAgentsUtil.key = key;
|
|
733
|
+
function address(member, agent) {
|
|
734
|
+
return `${member}/${agent}`;
|
|
735
|
+
}
|
|
736
|
+
RoomAgentsUtil.address = address;
|
|
737
|
+
function list(member, value, by) {
|
|
738
|
+
if (by !== member || !Array.isArray(value)) {
|
|
739
|
+
return [];
|
|
740
|
+
}
|
|
741
|
+
return value.filter((agent) => agent && typeof agent.id === "string" && agent.id && typeof agent.name === "string").slice(0, 16).map((agent) => ({
|
|
742
|
+
id: agent.id,
|
|
743
|
+
name: agent.name,
|
|
744
|
+
...typeof agent.role === "string" && agent.role ? { role: agent.role } : {},
|
|
745
|
+
...Number.isInteger(agent.face) && agent.face >= 0 && agent.face < 64 ? { face: agent.face } : {}
|
|
746
|
+
}));
|
|
747
|
+
}
|
|
748
|
+
RoomAgentsUtil.list = list;
|
|
749
|
+
function of(state) {
|
|
750
|
+
return Object.entries(state).flatMap(([key2, value]) => {
|
|
751
|
+
if (!key2.startsWith(ROOM_AGENTS_KEY) || value.value === null) {
|
|
752
|
+
return [];
|
|
753
|
+
}
|
|
754
|
+
const member = key2.slice(ROOM_AGENTS_KEY.length);
|
|
755
|
+
return list(member, value.value, value.by).map((agent) => ({ ...agent, member }));
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
RoomAgentsUtil.of = of;
|
|
759
|
+
})(RoomAgentsUtil ||= {});
|
|
760
|
+
var TASK_STATUSES = ["queued", "running", "permission", "done", "failed", "stopped", "declined"];
|
|
761
|
+
var ROOM_TASKS_KEY = "tasks:";
|
|
762
|
+
var ROOM_CANCEL_KEY = "cancel:";
|
|
763
|
+
var ROOM_TASKS_SHOWN = 30;
|
|
764
|
+
var RoomTasksUtil;
|
|
765
|
+
((RoomTasksUtil) => {
|
|
766
|
+
function key(member) {
|
|
767
|
+
return `${ROOM_TASKS_KEY}${member}`;
|
|
768
|
+
}
|
|
769
|
+
RoomTasksUtil.key = key;
|
|
770
|
+
function cancelKey(member) {
|
|
771
|
+
return `${ROOM_CANCEL_KEY}${member}`;
|
|
772
|
+
}
|
|
773
|
+
RoomTasksUtil.cancelKey = cancelKey;
|
|
774
|
+
function ended(status) {
|
|
775
|
+
return status === "done" || status === "failed" || status === "stopped" || status === "declined";
|
|
776
|
+
}
|
|
777
|
+
RoomTasksUtil.ended = ended;
|
|
778
|
+
function of(member, value, by) {
|
|
779
|
+
if (by !== member || !value || typeof value !== "object" || Array.isArray(value)) {
|
|
780
|
+
return {};
|
|
781
|
+
}
|
|
782
|
+
const tasks = {};
|
|
783
|
+
for (const [id, task] of Object.entries(value).slice(-ROOM_TASKS_SHOWN)) {
|
|
784
|
+
if (task && TASK_STATUSES.includes(task.status) && typeof task.at === "number") {
|
|
785
|
+
tasks[id] = {
|
|
786
|
+
status: task.status,
|
|
787
|
+
at: task.at,
|
|
788
|
+
...typeof task.detail === "string" && task.detail ? { detail: task.detail.slice(0, 200) } : {}
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return tasks;
|
|
793
|
+
}
|
|
794
|
+
RoomTasksUtil.of = of;
|
|
795
|
+
function cancelled(member, value, by) {
|
|
796
|
+
return by === member && Array.isArray(value) ? value.filter((id) => typeof id === "string").slice(-ROOM_TASKS_SHOWN) : [];
|
|
797
|
+
}
|
|
798
|
+
RoomTasksUtil.cancelled = cancelled;
|
|
799
|
+
})(RoomTasksUtil ||= {});
|
|
800
|
+
var TASK_MESSAGE_TYPE = "ta-rooms:task";
|
|
801
|
+
var ROOM_CAPABILITIES = ["files", "commands"];
|
|
802
|
+
var DoubleKeys;
|
|
803
|
+
((DoubleKeys) => {
|
|
804
|
+
DoubleKeys.QUIET = "doubles.quiet";
|
|
805
|
+
DoubleKeys.REPLY = "doubles.reply";
|
|
806
|
+
DoubleKeys.DRAFTS = "doubles.drafts";
|
|
807
|
+
DoubleKeys.DONE = "doubles.done";
|
|
808
|
+
DoubleKeys.GRANTS = "doubles.grants";
|
|
809
|
+
DoubleKeys.ASKS = "doubles.asks";
|
|
810
|
+
DoubleKeys.LOG = "doubles.log";
|
|
811
|
+
DoubleKeys.SESSIONS = "doubles.sessions";
|
|
812
|
+
DoubleKeys.READ = "doubles.read";
|
|
813
|
+
DoubleKeys.TASKS = "doubles.tasks";
|
|
814
|
+
DoubleKeys.HANDED = "doubles.handed";
|
|
815
|
+
DoubleKeys.DEVICE = "doubles.device";
|
|
816
|
+
})(DoubleKeys ||= {});
|
|
817
|
+
var DRAFT_MS = 24 * 60 * 60 * 1000;
|
|
818
|
+
var GRANT_HOURS = [1, 24, 24 * 7];
|
|
819
|
+
|
|
820
|
+
// web-src/direct.ts
|
|
821
|
+
var DIRECT_KEY = "direct";
|
|
822
|
+
var DirectUtil;
|
|
823
|
+
((DirectUtil) => {
|
|
824
|
+
function is(room) {
|
|
825
|
+
return room?.kind === DIRECT_KIND;
|
|
826
|
+
}
|
|
827
|
+
DirectUtil.is = is;
|
|
828
|
+
function peer(room) {
|
|
829
|
+
return room.members.find((member) => !member.self);
|
|
830
|
+
}
|
|
831
|
+
DirectUtil.peer = peer;
|
|
832
|
+
function parse(value) {
|
|
833
|
+
return value && typeof value === "object" ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string")) : {};
|
|
834
|
+
}
|
|
835
|
+
DirectUtil.parse = parse;
|
|
836
|
+
function friendOf(room, kept) {
|
|
837
|
+
return peer(room)?.id ?? Object.entries(kept).find(([, id]) => id === room.id)?.[0];
|
|
838
|
+
}
|
|
839
|
+
DirectUtil.friendOf = friendOf;
|
|
840
|
+
function find(rooms, kept, friend) {
|
|
841
|
+
const mine = rooms.filter((room) => is(room) && room.status === "member");
|
|
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];
|
|
843
|
+
}
|
|
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;
|
|
857
|
+
})(DirectUtil ||= {});
|
|
858
|
+
|
|
512
859
|
// ../ta-relay/esm/common/relay-room-chat.js
|
|
513
860
|
var RELAY_CHAT_KEY = "chat:";
|
|
514
861
|
var RELAY_CHAT_PART_BYTES = 8 * 1024;
|
|
@@ -546,6 +893,7 @@ var RelayRoomChatUtil;
|
|
|
546
893
|
...line.double === true ? { double: true } : {},
|
|
547
894
|
...agent && typeof agent.id === "string" && agent.id && typeof agent.name === "string" && line.double !== true ? { agent: { id: agent.id.slice(0, 64), name: agent.name.slice(0, 64) } } : {},
|
|
548
895
|
...to.length ? { to } : {},
|
|
896
|
+
...line.person === true && to.length && line.double !== true && !line.agent ? { person: true } : {},
|
|
549
897
|
...typeof line.re === "string" ? { re: line.re } : {},
|
|
550
898
|
...line.task === true && to.length ? { task: true } : {}
|
|
551
899
|
};
|
|
@@ -671,97 +1019,6 @@ class RelayRoomChat {
|
|
|
671
1019
|
}
|
|
672
1020
|
}
|
|
673
1021
|
|
|
674
|
-
// web-src/double-protocol.ts
|
|
675
|
-
var ROOM_AGENTS_KEY = "agents:";
|
|
676
|
-
var RoomAgentsUtil;
|
|
677
|
-
((RoomAgentsUtil) => {
|
|
678
|
-
function key(member) {
|
|
679
|
-
return `${ROOM_AGENTS_KEY}${member}`;
|
|
680
|
-
}
|
|
681
|
-
RoomAgentsUtil.key = key;
|
|
682
|
-
function address(member, agent) {
|
|
683
|
-
return `${member}/${agent}`;
|
|
684
|
-
}
|
|
685
|
-
RoomAgentsUtil.address = address;
|
|
686
|
-
function list(member, value, by) {
|
|
687
|
-
if (by !== member || !Array.isArray(value)) {
|
|
688
|
-
return [];
|
|
689
|
-
}
|
|
690
|
-
return value.filter((agent) => agent && typeof agent.id === "string" && agent.id && typeof agent.name === "string").slice(0, 16).map((agent) => ({
|
|
691
|
-
id: agent.id,
|
|
692
|
-
name: agent.name,
|
|
693
|
-
...typeof agent.role === "string" && agent.role ? { role: agent.role } : {},
|
|
694
|
-
...Number.isInteger(agent.face) && agent.face >= 0 && agent.face < 64 ? { face: agent.face } : {}
|
|
695
|
-
}));
|
|
696
|
-
}
|
|
697
|
-
RoomAgentsUtil.list = list;
|
|
698
|
-
function of(state) {
|
|
699
|
-
return Object.entries(state).flatMap(([key2, value]) => {
|
|
700
|
-
if (!key2.startsWith(ROOM_AGENTS_KEY) || value.value === null) {
|
|
701
|
-
return [];
|
|
702
|
-
}
|
|
703
|
-
const member = key2.slice(ROOM_AGENTS_KEY.length);
|
|
704
|
-
return list(member, value.value, value.by).map((agent) => ({ ...agent, member }));
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
RoomAgentsUtil.of = of;
|
|
708
|
-
})(RoomAgentsUtil ||= {});
|
|
709
|
-
var TASK_STATUSES = ["queued", "running", "permission", "done", "failed", "stopped", "declined"];
|
|
710
|
-
var ROOM_TASKS_KEY = "tasks:";
|
|
711
|
-
var ROOM_CANCEL_KEY = "cancel:";
|
|
712
|
-
var ROOM_TASKS_SHOWN = 30;
|
|
713
|
-
var RoomTasksUtil;
|
|
714
|
-
((RoomTasksUtil) => {
|
|
715
|
-
function key(member) {
|
|
716
|
-
return `${ROOM_TASKS_KEY}${member}`;
|
|
717
|
-
}
|
|
718
|
-
RoomTasksUtil.key = key;
|
|
719
|
-
function cancelKey(member) {
|
|
720
|
-
return `${ROOM_CANCEL_KEY}${member}`;
|
|
721
|
-
}
|
|
722
|
-
RoomTasksUtil.cancelKey = cancelKey;
|
|
723
|
-
function ended(status) {
|
|
724
|
-
return status === "done" || status === "failed" || status === "stopped" || status === "declined";
|
|
725
|
-
}
|
|
726
|
-
RoomTasksUtil.ended = ended;
|
|
727
|
-
function of(member, value, by) {
|
|
728
|
-
if (by !== member || !value || typeof value !== "object" || Array.isArray(value)) {
|
|
729
|
-
return {};
|
|
730
|
-
}
|
|
731
|
-
const tasks = {};
|
|
732
|
-
for (const [id, task] of Object.entries(value).slice(-ROOM_TASKS_SHOWN)) {
|
|
733
|
-
if (task && TASK_STATUSES.includes(task.status) && typeof task.at === "number") {
|
|
734
|
-
tasks[id] = {
|
|
735
|
-
status: task.status,
|
|
736
|
-
at: task.at,
|
|
737
|
-
...typeof task.detail === "string" && task.detail ? { detail: task.detail.slice(0, 200) } : {}
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
return tasks;
|
|
742
|
-
}
|
|
743
|
-
RoomTasksUtil.of = of;
|
|
744
|
-
function cancelled(member, value, by) {
|
|
745
|
-
return by === member && Array.isArray(value) ? value.filter((id) => typeof id === "string").slice(-ROOM_TASKS_SHOWN) : [];
|
|
746
|
-
}
|
|
747
|
-
RoomTasksUtil.cancelled = cancelled;
|
|
748
|
-
})(RoomTasksUtil ||= {});
|
|
749
|
-
var TASK_MESSAGE_TYPE = "ta-rooms:task";
|
|
750
|
-
var ROOM_CAPABILITIES = ["files", "commands"];
|
|
751
|
-
var DoubleKeys;
|
|
752
|
-
((DoubleKeys) => {
|
|
753
|
-
DoubleKeys.QUIET = "doubles.quiet";
|
|
754
|
-
DoubleKeys.GRANTS = "doubles.grants";
|
|
755
|
-
DoubleKeys.ASKS = "doubles.asks";
|
|
756
|
-
DoubleKeys.LOG = "doubles.log";
|
|
757
|
-
DoubleKeys.SESSIONS = "doubles.sessions";
|
|
758
|
-
DoubleKeys.READ = "doubles.read";
|
|
759
|
-
DoubleKeys.TASKS = "doubles.tasks";
|
|
760
|
-
DoubleKeys.HANDED = "doubles.handed";
|
|
761
|
-
DoubleKeys.DEVICE = "doubles.device";
|
|
762
|
-
})(DoubleKeys ||= {});
|
|
763
|
-
var GRANT_HOURS = [1, 24, 24 * 7];
|
|
764
|
-
|
|
765
1022
|
// web-src/i18n.ts
|
|
766
1023
|
var EN = {
|
|
767
1024
|
friendShareTitle: "From {name}",
|
|
@@ -881,7 +1138,7 @@ var EN = {
|
|
|
881
1138
|
roomOfName: "{name}’s group chat",
|
|
882
1139
|
back: "Back",
|
|
883
1140
|
openPage: "Open {name}",
|
|
884
|
-
apps: "Apps
|
|
1141
|
+
apps: "Apps",
|
|
885
1142
|
pageLine: "A group chat of {name}: play in it together",
|
|
886
1143
|
chatEmpty: "Nothing said yet. Only those in the group chat read it: the relay keeps it sealed.",
|
|
887
1144
|
chatPlaceholder: "Message",
|
|
@@ -894,6 +1151,17 @@ var EN = {
|
|
|
894
1151
|
inviteFriendsTitle: "Invite friends into “{title}”",
|
|
895
1152
|
inviteFriendsLead: "Each friend you tap finds the group chat in their Ta: once they join, they are in, without your saying yes again.",
|
|
896
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",
|
|
897
1165
|
inviteFriendsOld: "Update Ta on this computer to invite friends",
|
|
898
1166
|
invitedFriend: "Invited",
|
|
899
1167
|
groupInviteTitle: "Invited to a group chat",
|
|
@@ -1015,12 +1283,12 @@ var ZH = {
|
|
|
1015
1283
|
closedNotice: "「{title}」已被群主解散。",
|
|
1016
1284
|
oldApp: "请更新 Ta 应用后再使用群聊。",
|
|
1017
1285
|
room: "群聊",
|
|
1018
|
-
newRoom: "
|
|
1286
|
+
newRoom: "发起群聊",
|
|
1019
1287
|
newRoomPlaceholder: "群聊名,受邀的人能看到",
|
|
1020
1288
|
roomOfName: "{name}的群聊",
|
|
1021
1289
|
back: "返回",
|
|
1022
1290
|
openPage: "打开{name}",
|
|
1023
|
-
apps: "
|
|
1291
|
+
apps: "应用",
|
|
1024
1292
|
pageLine: "{name}的群聊,大家可以一起玩",
|
|
1025
1293
|
chatEmpty: "还没有人说话。只有群里的人能看到,中继保存的是密文。",
|
|
1026
1294
|
chatPlaceholder: "发消息",
|
|
@@ -1033,6 +1301,17 @@ var ZH = {
|
|
|
1033
1301
|
inviteFriendsTitle: "邀请好友进「{title}」",
|
|
1034
1302
|
inviteFriendsLead: "点一位好友,对方就会在自己的 Ta 里看到这个群聊;对方点加入就直接进来,不用你再同意。",
|
|
1035
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}另建一个群",
|
|
1036
1315
|
inviteFriendsOld: "先把这台电脑上的 Ta 更新到新版,才能邀请好友",
|
|
1037
1316
|
invitedFriend: "已邀请",
|
|
1038
1317
|
groupInviteTitle: "群聊邀请",
|
|
@@ -1154,12 +1433,12 @@ var ZH_TW = {
|
|
|
1154
1433
|
closedNotice: "「{title}」已被群主解散。",
|
|
1155
1434
|
oldApp: "請更新 Ta 應用後再使用群聊。",
|
|
1156
1435
|
room: "群聊",
|
|
1157
|
-
newRoom: "
|
|
1436
|
+
newRoom: "發起群聊",
|
|
1158
1437
|
newRoomPlaceholder: "群聊名,受邀的人能看到",
|
|
1159
1438
|
roomOfName: "{name}的群聊",
|
|
1160
1439
|
back: "返回",
|
|
1161
1440
|
openPage: "開啟{name}",
|
|
1162
|
-
apps: "
|
|
1441
|
+
apps: "應用",
|
|
1163
1442
|
pageLine: "{name}的群聊,大家可以一起玩",
|
|
1164
1443
|
chatEmpty: "還沒有人說話。只有群裡的人能看到,中繼儲存的是密文。",
|
|
1165
1444
|
chatPlaceholder: "發訊息",
|
|
@@ -1172,6 +1451,17 @@ var ZH_TW = {
|
|
|
1172
1451
|
inviteFriendsTitle: "邀請好友進「{title}」",
|
|
1173
1452
|
inviteFriendsLead: "點一位好友,對方就會在自己的 Ta 裡看到這個群聊;對方點加入就直接進來,不用你再同意。",
|
|
1174
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}另建一個群",
|
|
1175
1465
|
inviteFriendsOld: "先把這台電腦上的 Ta 更新到新版,才能邀請好友",
|
|
1176
1466
|
invitedFriend: "已邀請",
|
|
1177
1467
|
groupInviteTitle: "群聊邀請",
|
|
@@ -1298,7 +1588,7 @@ var JA = {
|
|
|
1298
1588
|
roomOfName: "{name}のグループチャット",
|
|
1299
1589
|
back: "戻る",
|
|
1300
1590
|
openPage: "{name} を開く",
|
|
1301
|
-
apps: "
|
|
1591
|
+
apps: "アプリ",
|
|
1302
1592
|
pageLine: "{name} のグループチャット:一緒にプレイします",
|
|
1303
1593
|
chatEmpty: "まだ何も言われていません。グループ内の人だけが見ることができます。リレーは暗号化されて保存します。",
|
|
1304
1594
|
chatPlaceholder: "メッセージ",
|
|
@@ -1311,6 +1601,17 @@ var JA = {
|
|
|
1311
1601
|
inviteFriendsTitle: "「{title}」に友だちを招待",
|
|
1312
1602
|
inviteFriendsLead: "友だちをタップすると、その人の Ta にこのグループチャットが届きます。参加すれば、あなたの承認なしで入れます。",
|
|
1313
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}とほかの人で新しいチャット",
|
|
1314
1615
|
inviteFriendsOld: "友だちを招待するには、このコンピュータの Ta を更新してください",
|
|
1315
1616
|
invitedFriend: "招待済み",
|
|
1316
1617
|
groupInviteTitle: "グループチャットへの招待",
|
|
@@ -1851,8 +2152,162 @@ function MemberFaces({ room, onClick, shown }) {
|
|
|
1851
2152
|
}, "+", members.length - 5));
|
|
1852
2153
|
}
|
|
1853
2154
|
|
|
1854
|
-
// web-src/
|
|
1855
|
-
|
|
2155
|
+
// web-src/direct-view.tsx
|
|
2156
|
+
class DirectBook {
|
|
2157
|
+
kept = {};
|
|
2158
|
+
listeners = new Set;
|
|
2159
|
+
started = false;
|
|
2160
|
+
loaded = false;
|
|
2161
|
+
get() {
|
|
2162
|
+
return this.kept;
|
|
2163
|
+
}
|
|
2164
|
+
subscribe(listener) {
|
|
2165
|
+
this.listeners.add(listener);
|
|
2166
|
+
return () => this.listeners.delete(listener);
|
|
2167
|
+
}
|
|
2168
|
+
start() {
|
|
2169
|
+
if (this.started || !pi.storage) {
|
|
2170
|
+
return () => {
|
|
2171
|
+
return;
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
this.started = true;
|
|
2175
|
+
const stop = pi.storage.onChange((keys) => keys.includes(DIRECT_KEY) && void this.read());
|
|
2176
|
+
this.read();
|
|
2177
|
+
return () => {
|
|
2178
|
+
stop();
|
|
2179
|
+
this.started = false;
|
|
2180
|
+
};
|
|
2181
|
+
}
|
|
2182
|
+
async keep(friend, room) {
|
|
2183
|
+
await this.read();
|
|
2184
|
+
if (this.kept[friend] !== room) {
|
|
2185
|
+
this.put({ ...this.kept, [friend]: room });
|
|
2186
|
+
await pi.storage.set(DIRECT_KEY, this.kept);
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
async read() {
|
|
2190
|
+
const value = await pi.storage.get(DIRECT_KEY).then((kept) => kept ?? {}, () => {
|
|
2191
|
+
return;
|
|
2192
|
+
});
|
|
2193
|
+
this.loaded ||= value !== undefined;
|
|
2194
|
+
this.put(DirectUtil.parse(value));
|
|
2195
|
+
}
|
|
2196
|
+
put(kept) {
|
|
2197
|
+
this.kept = kept;
|
|
2198
|
+
for (const listener of this.listeners) {
|
|
2199
|
+
listener();
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
var directs = new DirectBook;
|
|
2204
|
+
function useDirects() {
|
|
2205
|
+
return React.useSyncExternalStore((listener) => directs.subscribe(listener), () => directs.get());
|
|
2206
|
+
}
|
|
2207
|
+
function directPeer(room, friends, kept = directs.get()) {
|
|
2208
|
+
const peer = DirectUtil.peer(room);
|
|
2209
|
+
if (peer) {
|
|
2210
|
+
return { id: peer.id, name: peer.name };
|
|
2211
|
+
}
|
|
2212
|
+
const id = DirectUtil.friendOf(room, kept);
|
|
2213
|
+
const friend = id ? friends?.find((each) => each.id === id) : undefined;
|
|
2214
|
+
return { id: id ?? room.id, name: friend?.name ?? room.title };
|
|
2215
|
+
}
|
|
2216
|
+
function DirectFace({ room, size, unread }) {
|
|
2217
|
+
const { friends } = React.useSyncExternalStore((listener) => book.subscribe(listener), () => book.get());
|
|
2218
|
+
const kept = useDirects();
|
|
2219
|
+
const peer = directPeer(room, friends, kept);
|
|
2220
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
2221
|
+
className: "trm-room-face",
|
|
2222
|
+
style: { width: size, height: size },
|
|
2223
|
+
"aria-hidden": "true"
|
|
2224
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
2225
|
+
id: peer.id,
|
|
2226
|
+
name: peer.name,
|
|
2227
|
+
size
|
|
2228
|
+
}), unread && /* @__PURE__ */ React.createElement("i", {
|
|
2229
|
+
className: "trm-unread"
|
|
2230
|
+
}));
|
|
2231
|
+
}
|
|
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) {
|
|
2242
|
+
const server = rooms();
|
|
2243
|
+
if (!server?.inviteFriends) {
|
|
2244
|
+
return;
|
|
2245
|
+
}
|
|
2246
|
+
try {
|
|
2247
|
+
await book.load();
|
|
2248
|
+
const { rooms: list = [] } = book.get();
|
|
2249
|
+
let room = DirectUtil.find(list, directs.get(), friend.id);
|
|
2250
|
+
const invite = !room ? (await server.listGroupInvites().catch(() => [])).find((each) => each.kind === DIRECT_KIND && each.by.id === friend.id) : undefined;
|
|
2251
|
+
if (invite) {
|
|
2252
|
+
await server.answerGroupInvite(invite.room, true);
|
|
2253
|
+
room = (await server.listRooms()).find((each) => each.id === invite.room && each.status === "member");
|
|
2254
|
+
}
|
|
2255
|
+
if (!room) {
|
|
2256
|
+
room = await server.createRoom({ kind: DIRECT_KIND, title: friend.name });
|
|
2257
|
+
await server.configureRoom(room.id, { members: 2 }).catch(() => {
|
|
2258
|
+
return;
|
|
2259
|
+
});
|
|
2260
|
+
await server.inviteFriends(room.id, [friend.id]);
|
|
2261
|
+
} else if (room.owner && !DirectUtil.peer(room)) {
|
|
2262
|
+
await server.inviteFriends(room.id, [friend.id]).catch(() => {
|
|
2263
|
+
return;
|
|
2264
|
+
});
|
|
2265
|
+
}
|
|
2266
|
+
await directs.keep(friend.id, room.id);
|
|
2267
|
+
await book.load();
|
|
2268
|
+
openRoom(room.id, true);
|
|
2269
|
+
} catch (error) {
|
|
2270
|
+
pi.ui.notify(message(error), "error");
|
|
2271
|
+
}
|
|
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
|
+
}
|
|
2287
|
+
var reinvited = new Set;
|
|
2288
|
+
function reinvite(room) {
|
|
2289
|
+
const friend = DirectUtil.friendOf(room, directs.get());
|
|
2290
|
+
if (!friend || reinvited.has(room.id)) {
|
|
2291
|
+
return;
|
|
2292
|
+
}
|
|
2293
|
+
reinvited.add(room.id);
|
|
2294
|
+
rooms()?.inviteFriends?.(room.id, [friend]).catch(() => {
|
|
2295
|
+
return;
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
// web-src/double-i18n.ts
|
|
2300
|
+
var EN2 = {
|
|
2301
|
+
scope: "Where",
|
|
2302
|
+
scopeHere: "Only in {place}",
|
|
2303
|
+
placeGroup: "“{title}”",
|
|
2304
|
+
placeDirect: "the chat with {name}",
|
|
2305
|
+
scopeAll: "All chats with {name}",
|
|
2306
|
+
scopeHereShort: "in {place}",
|
|
2307
|
+
scopeAllShort: "all chats",
|
|
2308
|
+
grantsTitle: "What your double does for others",
|
|
2309
|
+
grantsHint: "Besides chatting: given by you, for a person, in one chat or all of them",
|
|
2310
|
+
grantsInSettings: "Taken back in Settings → Others and your double",
|
|
1856
2311
|
doubleOf: "{name}'s double",
|
|
1857
2312
|
myDouble: "Your double",
|
|
1858
2313
|
doubleTag: "Double",
|
|
@@ -1951,6 +2406,16 @@ var EN2 = {
|
|
|
1951
2406
|
taskLog: "{name} handed a task"
|
|
1952
2407
|
};
|
|
1953
2408
|
var ZH2 = {
|
|
2409
|
+
scope: "在哪",
|
|
2410
|
+
scopeHere: "只在{place}",
|
|
2411
|
+
placeGroup: "「{title}」",
|
|
2412
|
+
placeDirect: "和{name}的私聊",
|
|
2413
|
+
scopeAll: "和{name}的所有聊天",
|
|
2414
|
+
scopeHereShort: "在{place}",
|
|
2415
|
+
scopeAllShort: "所有聊天",
|
|
2416
|
+
grantsTitle: "分身替别人做的事",
|
|
2417
|
+
grantsHint: "聊天之外的事:由你给,按人给,可以只在一个聊天里",
|
|
2418
|
+
grantsInSettings: "在 设置 → 别人与我的分身 里查看和收回",
|
|
1954
2419
|
doubleOf: "{name}的分身",
|
|
1955
2420
|
myDouble: "我的分身",
|
|
1956
2421
|
doubleTag: "分身",
|
|
@@ -2049,6 +2514,16 @@ var ZH2 = {
|
|
|
2049
2514
|
taskLog: "{name}交来任务"
|
|
2050
2515
|
};
|
|
2051
2516
|
var ZH_TW2 = {
|
|
2517
|
+
scope: "在哪",
|
|
2518
|
+
scopeHere: "只在{place}",
|
|
2519
|
+
placeGroup: "「{title}」",
|
|
2520
|
+
placeDirect: "和{name}的私聊",
|
|
2521
|
+
scopeAll: "和{name}的所有聊天",
|
|
2522
|
+
scopeHereShort: "在{place}",
|
|
2523
|
+
scopeAllShort: "所有聊天",
|
|
2524
|
+
grantsTitle: "分身替別人做的事",
|
|
2525
|
+
grantsHint: "聊天之外的事:由你給,按人給,可以只在一個聊天裡",
|
|
2526
|
+
grantsInSettings: "在 設定 → 別人與我的分身 裡查看和收回",
|
|
2052
2527
|
doubleOf: "{name}的分身",
|
|
2053
2528
|
myDouble: "我的分身",
|
|
2054
2529
|
doubleTag: "分身",
|
|
@@ -2147,6 +2622,16 @@ var ZH_TW2 = {
|
|
|
2147
2622
|
taskLog: "{name}交來任務"
|
|
2148
2623
|
};
|
|
2149
2624
|
var JA2 = {
|
|
2625
|
+
scope: "場所",
|
|
2626
|
+
scopeHere: "{place}だけ",
|
|
2627
|
+
placeGroup: "「{title}」",
|
|
2628
|
+
placeDirect: "{name}との個別チャット",
|
|
2629
|
+
scopeAll: "{name}とのすべてのチャット",
|
|
2630
|
+
scopeHereShort: "{place}で",
|
|
2631
|
+
scopeAllShort: "すべてのチャット",
|
|
2632
|
+
grantsTitle: "分身が他の人のためにすること",
|
|
2633
|
+
grantsHint: "チャット以外のこと:あなたが人ごとに許可し、1 つのチャットに限ることもできます",
|
|
2634
|
+
grantsInSettings: "設定 → ほかの人と分身 で確認・取り消しできます",
|
|
2150
2635
|
doubleOf: "{name}の分身",
|
|
2151
2636
|
myDouble: "私の分身",
|
|
2152
2637
|
doubleTag: "分身",
|
|
@@ -2256,13 +2741,137 @@ function dt(key, values = {}) {
|
|
|
2256
2741
|
return DoubleWordsUtil.of(pi.ui.language)[key].replace(/\{(\w+)\}/g, (whole, name) => (name in values) ? String(values[name]) : whole);
|
|
2257
2742
|
}
|
|
2258
2743
|
|
|
2744
|
+
// web-src/reply-policy.ts
|
|
2745
|
+
var REPLY_MODES = ["away", "draft", "always", "notify"];
|
|
2746
|
+
var TASK_MODES = ["allow", "ask", "deny"];
|
|
2747
|
+
var INVITE_MODES = ["join", "ask", "deny"];
|
|
2748
|
+
var AWAY_MINUTES = [3, 10, 30, 60];
|
|
2749
|
+
var ReplyPolicyUtil;
|
|
2750
|
+
((ReplyPolicyUtil) => {
|
|
2751
|
+
ReplyPolicyUtil.DEFAULT = {
|
|
2752
|
+
mode: "away",
|
|
2753
|
+
awayMinutes: 10,
|
|
2754
|
+
strangers: "notify",
|
|
2755
|
+
tasks: { friends: "allow", strangers: "ask" },
|
|
2756
|
+
invites: "ask",
|
|
2757
|
+
chats: {},
|
|
2758
|
+
people: {}
|
|
2759
|
+
};
|
|
2760
|
+
function isTaskMode(value) {
|
|
2761
|
+
return typeof value === "string" && TASK_MODES.includes(value);
|
|
2762
|
+
}
|
|
2763
|
+
ReplyPolicyUtil.isTaskMode = isTaskMode;
|
|
2764
|
+
function isInviteMode(value) {
|
|
2765
|
+
return typeof value === "string" && INVITE_MODES.includes(value);
|
|
2766
|
+
}
|
|
2767
|
+
ReplyPolicyUtil.isInviteMode = isInviteMode;
|
|
2768
|
+
function person(value) {
|
|
2769
|
+
if (isMode(value)) {
|
|
2770
|
+
return { reply: value };
|
|
2771
|
+
}
|
|
2772
|
+
const kept = value && typeof value === "object" ? value : undefined;
|
|
2773
|
+
const policy = {
|
|
2774
|
+
...isMode(kept?.reply) ? { reply: kept.reply } : {},
|
|
2775
|
+
...isTaskMode(kept?.tasks) ? { tasks: kept.tasks } : {},
|
|
2776
|
+
...isInviteMode(kept?.invites) ? { invites: kept.invites } : {},
|
|
2777
|
+
...kept?.moments === false ? { moments: false } : {}
|
|
2778
|
+
};
|
|
2779
|
+
return Object.keys(policy).length ? policy : undefined;
|
|
2780
|
+
}
|
|
2781
|
+
ReplyPolicyUtil.person = person;
|
|
2782
|
+
function isMode(value) {
|
|
2783
|
+
return typeof value === "string" && REPLY_MODES.includes(value);
|
|
2784
|
+
}
|
|
2785
|
+
ReplyPolicyUtil.isMode = isMode;
|
|
2786
|
+
function parse(value, quiet) {
|
|
2787
|
+
const kept = value && typeof value === "object" ? value : {};
|
|
2788
|
+
const modes = (map, max) => map && typeof map === "object" ? Object.fromEntries(Object.entries(map).filter((entry) => isMode(entry[1])).slice(0, max)) : {};
|
|
2789
|
+
const off = quiet && typeof quiet === "object" ? Object.fromEntries(Object.entries(quiet).filter(([, on]) => on === true).map(([room]) => [room, "notify"])) : {};
|
|
2790
|
+
const minutes2 = Number(kept.awayMinutes);
|
|
2791
|
+
const q = kept.quiet;
|
|
2792
|
+
const tasks = kept.tasks;
|
|
2793
|
+
const minute = (each) => Number.isInteger(each) && each >= 0 && each < 24 * 60;
|
|
2794
|
+
return {
|
|
2795
|
+
mode: isMode(kept.mode) ? kept.mode : ReplyPolicyUtil.DEFAULT.mode,
|
|
2796
|
+
awayMinutes: Number.isFinite(minutes2) && minutes2 >= 1 && minutes2 <= 24 * 60 ? Math.round(minutes2) : ReplyPolicyUtil.DEFAULT.awayMinutes,
|
|
2797
|
+
strangers: isMode(kept.strangers) ? kept.strangers : ReplyPolicyUtil.DEFAULT.strangers,
|
|
2798
|
+
...q && minute(q.from) && minute(q.to) && q.from !== q.to && isMode(q.mode) ? { quiet: { from: q.from, to: q.to, mode: q.mode } } : {},
|
|
2799
|
+
tasks: {
|
|
2800
|
+
friends: isTaskMode(tasks?.friends) ? tasks.friends : ReplyPolicyUtil.DEFAULT.tasks.friends,
|
|
2801
|
+
strangers: isTaskMode(tasks?.strangers) ? tasks.strangers : ReplyPolicyUtil.DEFAULT.tasks.strangers
|
|
2802
|
+
},
|
|
2803
|
+
invites: isInviteMode(kept.invites) ? kept.invites : ReplyPolicyUtil.DEFAULT.invites,
|
|
2804
|
+
chats: { ...off, ...modes(kept.chats, 500) },
|
|
2805
|
+
people: Object.fromEntries(Object.entries(kept.people && typeof kept.people === "object" ? kept.people : {}).slice(0, 500).flatMap(([id, value2]) => {
|
|
2806
|
+
const one = person(value2);
|
|
2807
|
+
return one ? [[id, one]] : [];
|
|
2808
|
+
}))
|
|
2809
|
+
};
|
|
2810
|
+
}
|
|
2811
|
+
ReplyPolicyUtil.parse = parse;
|
|
2812
|
+
function within(quiet, date) {
|
|
2813
|
+
const now = date.getHours() * 60 + date.getMinutes();
|
|
2814
|
+
return quiet.from < quiet.to ? now >= quiet.from && now < quiet.to : now >= quiet.from || now < quiet.to;
|
|
2815
|
+
}
|
|
2816
|
+
ReplyPolicyUtil.within = within;
|
|
2817
|
+
function modeOf(policy, input) {
|
|
2818
|
+
const person2 = policy.people[input.person]?.reply;
|
|
2819
|
+
if (person2) {
|
|
2820
|
+
return { mode: person2, source: "person" };
|
|
2821
|
+
}
|
|
2822
|
+
const chat = policy.chats[input.room];
|
|
2823
|
+
if (chat) {
|
|
2824
|
+
return { mode: chat, source: "chat" };
|
|
2825
|
+
}
|
|
2826
|
+
if (!input.friend) {
|
|
2827
|
+
return { mode: policy.strangers, source: "strangers" };
|
|
2828
|
+
}
|
|
2829
|
+
if (policy.quiet && within(policy.quiet, input.date)) {
|
|
2830
|
+
return { mode: policy.quiet.mode, source: "quiet" };
|
|
2831
|
+
}
|
|
2832
|
+
return { mode: policy.mode, source: "default" };
|
|
2833
|
+
}
|
|
2834
|
+
ReplyPolicyUtil.modeOf = modeOf;
|
|
2835
|
+
function taskOf(policy, person2, friend) {
|
|
2836
|
+
return policy.people[person2]?.tasks ?? (friend ? policy.tasks.friends : policy.tasks.strangers);
|
|
2837
|
+
}
|
|
2838
|
+
ReplyPolicyUtil.taskOf = taskOf;
|
|
2839
|
+
function inviteOf(policy, person2) {
|
|
2840
|
+
return policy.people[person2]?.invites ?? policy.invites;
|
|
2841
|
+
}
|
|
2842
|
+
ReplyPolicyUtil.inviteOf = inviteOf;
|
|
2843
|
+
function set(policy, where, id, mode) {
|
|
2844
|
+
const { [id]: _was, ...rest } = policy[where];
|
|
2845
|
+
return { ...policy, [where]: mode ? { ...rest, [id]: mode } : rest };
|
|
2846
|
+
}
|
|
2847
|
+
ReplyPolicyUtil.set = set;
|
|
2848
|
+
function setPerson(policy, id, key, value) {
|
|
2849
|
+
const { [key]: _was, ...others } = policy.people[id] ?? {};
|
|
2850
|
+
const next = value === undefined ? others : { ...others, [key]: value };
|
|
2851
|
+
const { [id]: _person, ...rest } = policy.people;
|
|
2852
|
+
return { ...policy, people: Object.keys(next).length ? { ...rest, [id]: next } : rest };
|
|
2853
|
+
}
|
|
2854
|
+
ReplyPolicyUtil.setPerson = setPerson;
|
|
2855
|
+
function clock(minutes2) {
|
|
2856
|
+
return `${String(Math.floor(minutes2 / 60)).padStart(2, "0")}:${String(minutes2 % 60).padStart(2, "0")}`;
|
|
2857
|
+
}
|
|
2858
|
+
ReplyPolicyUtil.clock = clock;
|
|
2859
|
+
function minutes(clock2) {
|
|
2860
|
+
const match = /^(\d{1,2}):(\d{2})$/.exec(clock2.trim());
|
|
2861
|
+
const value = match ? Number(match[1]) * 60 + Number(match[2]) : Number.NaN;
|
|
2862
|
+
return Number.isInteger(value) && value >= 0 && value < 24 * 60 ? value : undefined;
|
|
2863
|
+
}
|
|
2864
|
+
ReplyPolicyUtil.minutes = minutes;
|
|
2865
|
+
})(ReplyPolicyUtil ||= {});
|
|
2866
|
+
|
|
2259
2867
|
// web-src/doubles-store.ts
|
|
2260
|
-
var KEYS = [DoubleKeys.QUIET, DoubleKeys.GRANTS, DoubleKeys.ASKS, DoubleKeys.LOG, DoubleKeys.TASKS, DoubleKeys.HANDED];
|
|
2868
|
+
var KEYS = [DoubleKeys.QUIET, DoubleKeys.REPLY, DoubleKeys.DRAFTS, DoubleKeys.GRANTS, DoubleKeys.ASKS, DoubleKeys.LOG, DoubleKeys.TASKS, DoubleKeys.HANDED];
|
|
2261
2869
|
|
|
2262
2870
|
class DoublesStore {
|
|
2263
|
-
state = { quiet: {}, grants: [], asks: [], log: [], tasks: [], handed: [] };
|
|
2871
|
+
state = { quiet: {}, reply: ReplyPolicyUtil.DEFAULT, drafts: [], grants: [], asks: [], log: [], tasks: [], handed: [] };
|
|
2264
2872
|
listeners = new Set;
|
|
2265
2873
|
started = false;
|
|
2874
|
+
replyValue;
|
|
2266
2875
|
onAsk;
|
|
2267
2876
|
get() {
|
|
2268
2877
|
return this.state;
|
|
@@ -2295,10 +2904,15 @@ class DoublesStore {
|
|
|
2295
2904
|
return;
|
|
2296
2905
|
})));
|
|
2297
2906
|
const next = { ...this.state };
|
|
2907
|
+
let replyValue = this.replyValue;
|
|
2298
2908
|
keys.forEach((key, index) => {
|
|
2299
2909
|
const value = values[index];
|
|
2300
2910
|
if (key === DoubleKeys.QUIET) {
|
|
2301
2911
|
next.quiet = value && typeof value === "object" ? value : {};
|
|
2912
|
+
} else if (key === DoubleKeys.REPLY) {
|
|
2913
|
+
replyValue = value;
|
|
2914
|
+
} else if (key === DoubleKeys.DRAFTS) {
|
|
2915
|
+
next.drafts = Array.isArray(value) ? value : [];
|
|
2302
2916
|
} else if (key === DoubleKeys.GRANTS) {
|
|
2303
2917
|
next.grants = Array.isArray(value) ? value : [];
|
|
2304
2918
|
} else if (key === DoubleKeys.ASKS) {
|
|
@@ -2311,6 +2925,8 @@ class DoublesStore {
|
|
|
2311
2925
|
next.handed = Array.isArray(value) ? value : [];
|
|
2312
2926
|
}
|
|
2313
2927
|
});
|
|
2928
|
+
this.replyValue = replyValue;
|
|
2929
|
+
next.reply = ReplyPolicyUtil.parse(replyValue, next.quiet);
|
|
2314
2930
|
const known = new Set(this.state.asks.map((ask) => ask.id));
|
|
2315
2931
|
const fresh = keys.includes(DoubleKeys.ASKS) ? next.asks.filter((ask) => !known.has(ask.id)) : [];
|
|
2316
2932
|
this.state = next;
|
|
@@ -2334,24 +2950,20 @@ async function callDoubles(request) {
|
|
|
2334
2950
|
throw new Error(/no method|no host/i.test(text) ? dt("oldServer") : text);
|
|
2335
2951
|
}
|
|
2336
2952
|
}
|
|
2337
|
-
function
|
|
2338
|
-
return
|
|
2339
|
-
}
|
|
2340
|
-
function askable(room) {
|
|
2341
|
-
return room.members.filter((member) => !member.self && !member.guest);
|
|
2953
|
+
function mentionable(room) {
|
|
2954
|
+
return room.members.filter((member) => !member.self);
|
|
2342
2955
|
}
|
|
2343
2956
|
function names(text, name) {
|
|
2344
2957
|
const quoted = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2345
2958
|
return new RegExp(`@${quoted}(?![\\p{L}\\p{N}_])`, "u").test(text);
|
|
2346
2959
|
}
|
|
2347
2960
|
function addressed(text, room, agents = []) {
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
];
|
|
2961
|
+
const people = mentionable(room).filter((member) => names(text, member.name)).map((member) => member.member);
|
|
2962
|
+
const named = agents.filter((agent) => names(text, agent.name)).map((agent) => RoomAgentsUtil.address(agent.member, agent.id));
|
|
2963
|
+
return { to: [...people, ...named], person: people.length > 0 };
|
|
2352
2964
|
}
|
|
2353
|
-
function grantsOf(grants, friend, now = Date.now()) {
|
|
2354
|
-
return grants.filter((grant) => grant.friend === friend && grant.expiresAt > now);
|
|
2965
|
+
function grantsOf(grants, friend, room, now = Date.now()) {
|
|
2966
|
+
return grants.filter((grant) => grant.friend === friend && grant.expiresAt > now && (room === undefined || grant.room === undefined || grant.room === room));
|
|
2355
2967
|
}
|
|
2356
2968
|
function left(until, now = Date.now()) {
|
|
2357
2969
|
const minutes = Math.max(1, Math.round((until - now) / 60000));
|
|
@@ -2372,159 +2984,326 @@ function mayLine(grants) {
|
|
|
2372
2984
|
return dt("may", { what: TaLanguageUtil.list(pi.ui.language, what), left: left(Math.min(...grants.map((grant) => grant.expiresAt))) });
|
|
2373
2985
|
}
|
|
2374
2986
|
|
|
2375
|
-
// web-src/
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
}
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
}
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2987
|
+
// web-src/reply-i18n.ts
|
|
2988
|
+
var EN3 = {
|
|
2989
|
+
replyTitle: "Others and your double",
|
|
2990
|
+
replyLead: "When someone @s you in a group chat or writes to you, who answers.",
|
|
2991
|
+
modeAway: "Your double, once you are away",
|
|
2992
|
+
modeAwayHint: "You are told; if you neither look nor answer within {n} min, your double answers for you",
|
|
2993
|
+
modeDraft: "Your double drafts, you send",
|
|
2994
|
+
modeDraftHint: "Your double writes an answer at once; you send it, change it or drop it",
|
|
2995
|
+
modeAlways: "Your double, at once",
|
|
2996
|
+
modeAlwaysHint: "Your double answers at once, and you are told",
|
|
2997
|
+
modeNotify: "Only you",
|
|
2998
|
+
modeNotifyHint: "You are told; your double keeps quiet",
|
|
2999
|
+
modeDefault: "As for everyone",
|
|
3000
|
+
replyDefault: "Who answers",
|
|
3001
|
+
replyAway: "Away after",
|
|
3002
|
+
replyAwayHint: "Unread and unanswered this long, you count as away",
|
|
3003
|
+
minutes: "{n} min",
|
|
3004
|
+
replyStrangers: "People who are not your friends",
|
|
3005
|
+
replyStrangersHint: "In group chats: what they @ you with",
|
|
3006
|
+
replyQuiet: "Quiet hours",
|
|
3007
|
+
replyQuietHint: "In these hours, for friends, instead of the above",
|
|
3008
|
+
replyQuietOff: "Off",
|
|
3009
|
+
replyQuietFrom: "From",
|
|
3010
|
+
replyQuietTo: "to",
|
|
3011
|
+
replyOwn: "Set on their own",
|
|
3012
|
+
replyOwnHint: "Chats and people set apart, in the members of a chat or on a friend",
|
|
3013
|
+
replyOwnNone: "None yet",
|
|
3014
|
+
replyOwnRemove: "Back to as for everyone",
|
|
3015
|
+
replyHere: "Who answers here",
|
|
3016
|
+
replyThem: "When {name} reaches you",
|
|
3017
|
+
replyPick: "Who answers",
|
|
3018
|
+
draftTitle: "Your double drafted an answer to {name}",
|
|
3019
|
+
draftSend: "Send",
|
|
3020
|
+
draftEdit: "Change",
|
|
3021
|
+
draftDrop: "Drop",
|
|
3022
|
+
draftSave: "Send it",
|
|
3023
|
+
draftCancel: "Cancel",
|
|
3024
|
+
drafted: "Drafted",
|
|
3025
|
+
message: "Message",
|
|
3026
|
+
directEmpty: "Your chat with {name}",
|
|
3027
|
+
directHint: "Only the two of you, end to end. When {name} is away, their double may answer, as they set it.",
|
|
3028
|
+
directWaiting: "{name} gets it in their Ta",
|
|
3029
|
+
directDelete: "Delete the chat",
|
|
3030
|
+
directDeleteTitle: "Delete your chat with {name}?",
|
|
3031
|
+
directDeleteOwn: "It is gone for both of you. Messages sent later start a new one.",
|
|
3032
|
+
directDeleteOther: "You leave it. A message from {name} later starts a new one.",
|
|
3033
|
+
chatsSection: "Chats",
|
|
3034
|
+
mentionPerson: "Member",
|
|
3035
|
+
chatInfo: "Chat info",
|
|
3036
|
+
removeFriendLong: "Remove from friends",
|
|
3037
|
+
workFor: "Your double works for them",
|
|
3038
|
+
workNone: "Only chats with them",
|
|
3039
|
+
workGive: "Allow",
|
|
3040
|
+
workStop: "Stop all",
|
|
3041
|
+
tasksFrom: "Tasks they hand your double",
|
|
3042
|
+
taskAllow: "Take them",
|
|
3043
|
+
taskAsk: "Ask me first",
|
|
3044
|
+
taskDeny: "Turn them down",
|
|
3045
|
+
invitesFrom: "Their invitations to group chats",
|
|
3046
|
+
inviteJoin: "Join at once",
|
|
3047
|
+
inviteAsk: "Ask me",
|
|
3048
|
+
inviteDeny: "Turn them down",
|
|
3049
|
+
momentsTo: "They see your posts",
|
|
3050
|
+
momentsShown: "Your posts show to them",
|
|
3051
|
+
momentsHidden: "Your new posts do not show to them",
|
|
3052
|
+
personTitle: "Member",
|
|
3053
|
+
personPolicy: "What they may do",
|
|
3054
|
+
tasksShort: "Tasks:",
|
|
3055
|
+
invitesShort: "Invites:",
|
|
3056
|
+
momentsHiddenShort: "Posts hidden",
|
|
3057
|
+
policyAll: "What others may do",
|
|
3058
|
+
policyAllHint: "For all, unless set for someone in their info",
|
|
3059
|
+
tasksFriends: "Tasks from friends",
|
|
3060
|
+
tasksOthers: "Tasks from others",
|
|
3061
|
+
invitesAll: "Invitations of friends to group chats",
|
|
3062
|
+
approveTitle: "{name} hands your double a task",
|
|
3063
|
+
approveTake: "Take it",
|
|
3064
|
+
approveDecline: "Not this time",
|
|
3065
|
+
approveWaiting: "Waits for you to take it"
|
|
3066
|
+
};
|
|
3067
|
+
var ZH3 = {
|
|
3068
|
+
replyTitle: "别人与我的分身",
|
|
3069
|
+
replyLead: "有人在群聊里 @ 你、或者给你发消息时,由谁来回。",
|
|
3070
|
+
modeAway: "我不在时分身回",
|
|
3071
|
+
modeAwayHint: "先提醒你;{n} 分钟内没看也没回,分身替你回",
|
|
3072
|
+
modeDraft: "分身拟稿我确认",
|
|
3073
|
+
modeDraftHint: "分身马上写好回复,你点发送、改一下或者不发",
|
|
3074
|
+
modeAlways: "分身直接回",
|
|
3075
|
+
modeAlwaysHint: "分身立刻回,你也会收到提醒",
|
|
3076
|
+
modeNotify: "只提醒我",
|
|
3077
|
+
modeNotifyHint: "只提醒你,分身不回",
|
|
3078
|
+
modeDefault: "跟随默认",
|
|
3079
|
+
replyDefault: "谁来回",
|
|
3080
|
+
replyAway: "多久算不在",
|
|
3081
|
+
replyAwayHint: "这么久没看也没回,就算你不在",
|
|
3082
|
+
minutes: "{n} 分钟",
|
|
3083
|
+
replyStrangers: "不是好友的人",
|
|
3084
|
+
replyStrangersHint: "群聊里不是你好友的人 @ 你时",
|
|
3085
|
+
replyQuiet: "勿扰时段",
|
|
3086
|
+
replyQuietHint: "这段时间里,好友找你时按这里来,不按上面",
|
|
3087
|
+
replyQuietOff: "不开",
|
|
3088
|
+
replyQuietFrom: "从",
|
|
3089
|
+
replyQuietTo: "到",
|
|
3090
|
+
replyOwn: "单独设置",
|
|
3091
|
+
replyOwnHint: "在聊天的成员页或好友资料里,可以给某个聊天、某个人单独设",
|
|
3092
|
+
replyOwnNone: "还没有",
|
|
3093
|
+
replyOwnRemove: "改回跟随默认",
|
|
3094
|
+
replyHere: "这里谁来回",
|
|
3095
|
+
replyThem: "{name}找我时",
|
|
3096
|
+
replyPick: "谁来回",
|
|
3097
|
+
draftTitle: "分身拟好了给{name}的回复",
|
|
3098
|
+
draftSend: "发送",
|
|
3099
|
+
draftEdit: "改一下",
|
|
3100
|
+
draftDrop: "不发",
|
|
3101
|
+
draftSave: "发送",
|
|
3102
|
+
draftCancel: "取消",
|
|
3103
|
+
drafted: "已拟稿",
|
|
3104
|
+
message: "发消息",
|
|
3105
|
+
directEmpty: "和{name}的聊天",
|
|
3106
|
+
directHint: "只有你们两个人,端到端加密。{name}不在时,TA 的分身可能会按 TA 的设置替 TA 回。",
|
|
3107
|
+
directWaiting: "{name}会在自己的 Ta 里收到",
|
|
3108
|
+
directDelete: "删除聊天",
|
|
3109
|
+
directDeleteTitle: "删除和{name}的聊天?",
|
|
3110
|
+
directDeleteOwn: "你们两边都会删掉。之后再发消息会开始新的聊天。",
|
|
3111
|
+
directDeleteOther: "你会离开这个聊天。{name}之后再发消息会开始新的聊天。",
|
|
3112
|
+
chatsSection: "聊天",
|
|
3113
|
+
mentionPerson: "成员",
|
|
3114
|
+
chatInfo: "聊天信息",
|
|
3115
|
+
removeFriendLong: "删除好友",
|
|
3116
|
+
workFor: "分身替 TA 做事",
|
|
3117
|
+
workNone: "只聊天",
|
|
3118
|
+
workGive: "授权",
|
|
3119
|
+
workStop: "全部停掉",
|
|
3120
|
+
tasksFrom: "TA 给我的分身派任务",
|
|
3121
|
+
taskAllow: "直接接",
|
|
3122
|
+
taskAsk: "先问我",
|
|
3123
|
+
taskDeny: "不接",
|
|
3124
|
+
invitesFrom: "TA 拉我进群",
|
|
3125
|
+
inviteJoin: "直接进",
|
|
3126
|
+
inviteAsk: "先问我",
|
|
3127
|
+
inviteDeny: "不进",
|
|
3128
|
+
momentsTo: "TA 能看我的动态",
|
|
3129
|
+
momentsShown: "我的动态对 TA 可见",
|
|
3130
|
+
momentsHidden: "之后发的动态不给 TA 看",
|
|
3131
|
+
personTitle: "成员",
|
|
3132
|
+
personPolicy: "TA 能做什么",
|
|
3133
|
+
tasksShort: "派任务",
|
|
3134
|
+
invitesShort: "拉群",
|
|
3135
|
+
momentsHiddenShort: "不给看动态",
|
|
3136
|
+
policyAll: "别人能做什么",
|
|
3137
|
+
policyAllHint: "对所有人生效;在某人的资料里可以单独设",
|
|
3138
|
+
tasksFriends: "好友派任务",
|
|
3139
|
+
tasksOthers: "其他人派任务",
|
|
3140
|
+
invitesAll: "好友拉我进群",
|
|
3141
|
+
approveTitle: "{name}给你的分身派了任务",
|
|
3142
|
+
approveTake: "接",
|
|
3143
|
+
approveDecline: "这次不接",
|
|
3144
|
+
approveWaiting: "等你决定接不接"
|
|
3145
|
+
};
|
|
3146
|
+
var ZH_TW3 = {
|
|
3147
|
+
replyTitle: "別人與我的分身",
|
|
3148
|
+
replyLead: "有人在群聊裡 @ 你、或者傳訊息給你時,由誰來回。",
|
|
3149
|
+
modeAway: "我不在時分身回",
|
|
3150
|
+
modeAwayHint: "先提醒你;{n} 分鐘內沒看也沒回,分身替你回",
|
|
3151
|
+
modeDraft: "分身擬稿我確認",
|
|
3152
|
+
modeDraftHint: "分身馬上寫好回覆,你點傳送、改一下或者不傳",
|
|
3153
|
+
modeAlways: "分身直接回",
|
|
3154
|
+
modeAlwaysHint: "分身立刻回,你也會收到提醒",
|
|
3155
|
+
modeNotify: "只提醒我",
|
|
3156
|
+
modeNotifyHint: "只提醒你,分身不回",
|
|
3157
|
+
modeDefault: "跟隨預設",
|
|
3158
|
+
replyDefault: "誰來回",
|
|
3159
|
+
replyAway: "多久算不在",
|
|
3160
|
+
replyAwayHint: "這麼久沒看也沒回,就算你不在",
|
|
3161
|
+
minutes: "{n} 分鐘",
|
|
3162
|
+
replyStrangers: "不是好友的人",
|
|
3163
|
+
replyStrangersHint: "群聊裡不是你好友的人 @ 你時",
|
|
3164
|
+
replyQuiet: "勿擾時段",
|
|
3165
|
+
replyQuietHint: "這段時間裡,好友找你時按這裡來,不按上面",
|
|
3166
|
+
replyQuietOff: "不開",
|
|
3167
|
+
replyQuietFrom: "從",
|
|
3168
|
+
replyQuietTo: "到",
|
|
3169
|
+
replyOwn: "單獨設定",
|
|
3170
|
+
replyOwnHint: "在聊天的成員頁或好友資料裡,可以給某個聊天、某個人單獨設",
|
|
3171
|
+
replyOwnNone: "還沒有",
|
|
3172
|
+
replyOwnRemove: "改回跟隨預設",
|
|
3173
|
+
replyHere: "這裡誰來回",
|
|
3174
|
+
replyThem: "{name}找我時",
|
|
3175
|
+
replyPick: "誰來回",
|
|
3176
|
+
draftTitle: "分身擬好了給{name}的回覆",
|
|
3177
|
+
draftSend: "傳送",
|
|
3178
|
+
draftEdit: "改一下",
|
|
3179
|
+
draftDrop: "不傳",
|
|
3180
|
+
draftSave: "傳送",
|
|
3181
|
+
draftCancel: "取消",
|
|
3182
|
+
drafted: "已擬稿",
|
|
3183
|
+
message: "傳訊息",
|
|
3184
|
+
directEmpty: "和{name}的聊天",
|
|
3185
|
+
directHint: "只有你們兩個人,端對端加密。{name}不在時,TA 的分身可能會按 TA 的設定替 TA 回。",
|
|
3186
|
+
directWaiting: "{name}會在自己的 Ta 裡收到",
|
|
3187
|
+
directDelete: "刪除聊天",
|
|
3188
|
+
directDeleteTitle: "刪除和{name}的聊天?",
|
|
3189
|
+
directDeleteOwn: "你們兩邊都會刪掉。之後再傳訊息會開始新的聊天。",
|
|
3190
|
+
directDeleteOther: "你會離開這個聊天。{name}之後再傳訊息會開始新的聊天。",
|
|
3191
|
+
chatsSection: "聊天",
|
|
3192
|
+
mentionPerson: "成員",
|
|
3193
|
+
chatInfo: "聊天資訊",
|
|
3194
|
+
removeFriendLong: "刪除好友",
|
|
3195
|
+
workFor: "分身替 TA 做事",
|
|
3196
|
+
workNone: "只聊天",
|
|
3197
|
+
workGive: "授權",
|
|
3198
|
+
workStop: "全部停掉",
|
|
3199
|
+
tasksFrom: "TA 給我的分身派任務",
|
|
3200
|
+
taskAllow: "直接接",
|
|
3201
|
+
taskAsk: "先問我",
|
|
3202
|
+
taskDeny: "不接",
|
|
3203
|
+
invitesFrom: "TA 拉我進群",
|
|
3204
|
+
inviteJoin: "直接進",
|
|
3205
|
+
inviteAsk: "先問我",
|
|
3206
|
+
inviteDeny: "不進",
|
|
3207
|
+
momentsTo: "TA 能看我的動態",
|
|
3208
|
+
momentsShown: "我的動態對 TA 可見",
|
|
3209
|
+
momentsHidden: "之後發的動態不給 TA 看",
|
|
3210
|
+
personTitle: "成員",
|
|
3211
|
+
personPolicy: "TA 能做什麼",
|
|
3212
|
+
tasksShort: "派任務",
|
|
3213
|
+
invitesShort: "拉群",
|
|
3214
|
+
momentsHiddenShort: "不給看動態",
|
|
3215
|
+
policyAll: "別人能做什麼",
|
|
3216
|
+
policyAllHint: "對所有人生效;在某人的資料裡可以單獨設",
|
|
3217
|
+
tasksFriends: "好友派任務",
|
|
3218
|
+
tasksOthers: "其他人派任務",
|
|
3219
|
+
invitesAll: "好友拉我進群",
|
|
3220
|
+
approveTitle: "{name}給你的分身派了任務",
|
|
3221
|
+
approveTake: "接",
|
|
3222
|
+
approveDecline: "這次不接",
|
|
3223
|
+
approveWaiting: "等你決定接不接"
|
|
3224
|
+
};
|
|
3225
|
+
var JA3 = {
|
|
3226
|
+
replyTitle: "ほかの人と分身",
|
|
3227
|
+
replyLead: "グループチャットで @ されたときや、メッセージが届いたときに、誰が返信するか。",
|
|
3228
|
+
modeAway: "不在のときは分身が返信",
|
|
3229
|
+
modeAwayHint: "まず通知し、{n} 分以内に見ても返信してもいなければ分身が代わりに返信します",
|
|
3230
|
+
modeDraft: "分身が下書き、自分で送信",
|
|
3231
|
+
modeDraftHint: "分身がすぐに返信を書き、送信・修正・破棄はあなたが決めます",
|
|
3232
|
+
modeAlways: "すぐに分身が返信",
|
|
3233
|
+
modeAlwaysHint: "分身がすぐに返信し、あなたにも通知します",
|
|
3234
|
+
modeNotify: "自分だけに通知",
|
|
3235
|
+
modeNotifyHint: "通知のみで、分身は返信しません",
|
|
3236
|
+
modeDefault: "デフォルトに従う",
|
|
3237
|
+
replyDefault: "誰が返信するか",
|
|
3238
|
+
replyAway: "不在とみなすまで",
|
|
3239
|
+
replyAwayHint: "この時間見ずに返信もしなければ、不在とみなします",
|
|
3240
|
+
minutes: "{n} 分",
|
|
3241
|
+
replyStrangers: "友だちではない人",
|
|
3242
|
+
replyStrangersHint: "グループチャットで友だちではない人に @ されたとき",
|
|
3243
|
+
replyQuiet: "おやすみ時間",
|
|
3244
|
+
replyQuietHint: "この時間帯は、友だちからの連絡に上の設定ではなくこちらを使います",
|
|
3245
|
+
replyQuietOff: "オフ",
|
|
3246
|
+
replyQuietFrom: "開始",
|
|
3247
|
+
replyQuietTo: "〜",
|
|
3248
|
+
replyOwn: "個別の設定",
|
|
3249
|
+
replyOwnHint: "チャットのメンバー画面や友だちのプロフィールで、チャットや人ごとに設定できます",
|
|
3250
|
+
replyOwnNone: "まだありません",
|
|
3251
|
+
replyOwnRemove: "デフォルトに戻す",
|
|
3252
|
+
replyHere: "ここでは誰が返信するか",
|
|
3253
|
+
replyThem: "{name} から連絡が来たとき",
|
|
3254
|
+
replyPick: "誰が返信するか",
|
|
3255
|
+
draftTitle: "分身が {name} への返信を下書きしました",
|
|
3256
|
+
draftSend: "送信",
|
|
3257
|
+
draftEdit: "修正",
|
|
3258
|
+
draftDrop: "破棄",
|
|
3259
|
+
draftSave: "送信",
|
|
3260
|
+
draftCancel: "キャンセル",
|
|
3261
|
+
drafted: "下書き済み",
|
|
3262
|
+
message: "メッセージ",
|
|
3263
|
+
directEmpty: "{name} とのチャット",
|
|
3264
|
+
directHint: "ふたりだけの、エンドツーエンド暗号化されたチャットです。{name} が不在のときは、設定に応じて分身が代わりに返信することがあります。",
|
|
3265
|
+
directWaiting: "{name} の Ta に届きます",
|
|
3266
|
+
directDelete: "チャットを削除",
|
|
3267
|
+
directDeleteTitle: "{name} とのチャットを削除しますか?",
|
|
3268
|
+
directDeleteOwn: "ふたりとも削除されます。あとでメッセージを送ると新しいチャットが始まります。",
|
|
3269
|
+
directDeleteOther: "このチャットから退出します。{name} があとでメッセージを送ると新しいチャットが始まります。",
|
|
3270
|
+
chatsSection: "チャット",
|
|
3271
|
+
mentionPerson: "メンバー",
|
|
3272
|
+
chatInfo: "チャット情報",
|
|
3273
|
+
removeFriendLong: "友だちから削除",
|
|
3274
|
+
workFor: "分身が代わりに作業",
|
|
3275
|
+
workNone: "チャットのみ",
|
|
3276
|
+
workGive: "許可",
|
|
3277
|
+
workStop: "すべて停止",
|
|
3278
|
+
tasksFrom: "分身へのタスク依頼",
|
|
3279
|
+
taskAllow: "すぐ受ける",
|
|
3280
|
+
taskAsk: "先に確認",
|
|
3281
|
+
taskDeny: "受けない",
|
|
3282
|
+
invitesFrom: "グループチャットへの招待",
|
|
3283
|
+
inviteJoin: "すぐ参加",
|
|
3284
|
+
inviteAsk: "先に確認",
|
|
3285
|
+
inviteDeny: "参加しない",
|
|
3286
|
+
momentsTo: "投稿を見られる",
|
|
3287
|
+
momentsShown: "あなたの投稿が表示されます",
|
|
3288
|
+
momentsHidden: "今後の投稿は表示されません",
|
|
3289
|
+
personTitle: "メンバー",
|
|
3290
|
+
personPolicy: "できること",
|
|
3291
|
+
tasksShort: "タスク",
|
|
3292
|
+
invitesShort: "招待",
|
|
3293
|
+
momentsHiddenShort: "投稿非表示",
|
|
3294
|
+
policyAll: "ほかの人ができること",
|
|
3295
|
+
policyAllHint: "全員に適用。各人のプロフィールで個別に設定できます",
|
|
3296
|
+
tasksFriends: "友だちからのタスク",
|
|
3297
|
+
tasksOthers: "ほかの人からのタスク",
|
|
3298
|
+
invitesAll: "友だちからのグループ招待",
|
|
3299
|
+
approveTitle: "{name}があなたの分身にタスクを依頼しました",
|
|
3300
|
+
approveTake: "受ける",
|
|
3301
|
+
approveDecline: "今回は受けない",
|
|
3302
|
+
approveWaiting: "受けるかどうか待っています"
|
|
3303
|
+
};
|
|
3304
|
+
var REPLY_WORDS = { "zh-CN": ZH3, "zh-TW": ZH_TW3, "en-US": EN3, "ja-JP": JA3 };
|
|
3305
|
+
function rt(key, values = {}) {
|
|
3306
|
+
return TaLanguageUtil.pick(pi.ui.language, REPLY_WORDS)[key].replace(/\{(\w+)\}/g, (whole, name) => (name in values) ? String(values[name]) : whole);
|
|
2528
3307
|
}
|
|
2529
3308
|
|
|
2530
3309
|
// web-src/doubles-view.tsx
|
|
@@ -2551,7 +3330,21 @@ function useBusy() {
|
|
|
2551
3330
|
function hoursLabel(hours) {
|
|
2552
3331
|
return hours === 1 ? dt("hours1") : hours === 24 ? dt("hours24") : dt("hours168");
|
|
2553
3332
|
}
|
|
2554
|
-
function GrantDialog({
|
|
3333
|
+
function GrantDialog({
|
|
3334
|
+
friend,
|
|
3335
|
+
name,
|
|
3336
|
+
ask,
|
|
3337
|
+
room,
|
|
3338
|
+
close
|
|
3339
|
+
}) {
|
|
3340
|
+
const { rooms: rooms2 } = useBook();
|
|
3341
|
+
const at = ask ? { id: ask.room, title: ask.title } : room;
|
|
3342
|
+
const chat = at && rooms2?.find((each) => each.id === at.id);
|
|
3343
|
+
const here = at && {
|
|
3344
|
+
id: at.id,
|
|
3345
|
+
place: chat && DirectUtil.is(chat) ? dt("placeDirect", { name: DirectUtil.peer(chat)?.name ?? name }) : dt("placeGroup", { title: at.title })
|
|
3346
|
+
};
|
|
3347
|
+
const [everywhere, setEverywhere] = React.useState(!here);
|
|
2555
3348
|
const cwd = pi.ui.useCwd();
|
|
2556
3349
|
const [directory, setDirectory] = React.useState(cwd);
|
|
2557
3350
|
const [picking, setPicking] = React.useState(false);
|
|
@@ -2564,9 +3357,17 @@ function GrantDialog({ friend, name, ask, close }) {
|
|
|
2564
3357
|
setError(undefined);
|
|
2565
3358
|
try {
|
|
2566
3359
|
if (ask) {
|
|
2567
|
-
await callDoubles({ kind: "answer", ask: ask.id, accept, cwd: directory, hours });
|
|
3360
|
+
await callDoubles({ kind: "answer", ask: ask.id, accept, cwd: directory, hours, everywhere, ...here ? { place: here.place } : {} });
|
|
2568
3361
|
} else if (accept) {
|
|
2569
|
-
await callDoubles({
|
|
3362
|
+
await callDoubles({
|
|
3363
|
+
kind: "grant",
|
|
3364
|
+
friend,
|
|
3365
|
+
name,
|
|
3366
|
+
capabilities: chosen,
|
|
3367
|
+
cwd: directory,
|
|
3368
|
+
hours,
|
|
3369
|
+
...here && !everywhere ? { room: here.id, title: here.place } : {}
|
|
3370
|
+
});
|
|
2570
3371
|
}
|
|
2571
3372
|
close();
|
|
2572
3373
|
} catch (failure) {
|
|
@@ -2619,16 +3420,30 @@ function GrantDialog({ friend, name, ask, close }) {
|
|
|
2619
3420
|
size: 15
|
|
2620
3421
|
}), /* @__PURE__ */ React.createElement("span", {
|
|
2621
3422
|
className: "trm-ellipsis"
|
|
2622
|
-
}, directory || dt("pick")))), /* @__PURE__ */ React.createElement("div", {
|
|
3423
|
+
}, directory || dt("pick")))), here && /* @__PURE__ */ React.createElement("div", {
|
|
2623
3424
|
className: "trm-grant-field"
|
|
2624
3425
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
2625
3426
|
className: "trm-grant-label"
|
|
2626
|
-
}, dt("
|
|
3427
|
+
}, dt("scope")), /* @__PURE__ */ React.createElement("span", {
|
|
2627
3428
|
className: "trm-chips"
|
|
2628
|
-
},
|
|
2629
|
-
key:
|
|
3429
|
+
}, [false, true].map((all) => /* @__PURE__ */ React.createElement("button", {
|
|
3430
|
+
key: String(all),
|
|
2630
3431
|
type: "button",
|
|
2631
|
-
"aria-pressed":
|
|
3432
|
+
"aria-pressed": everywhere === all,
|
|
3433
|
+
className: `trm-chip${everywhere === all ? " trm-chip-on" : ""}`,
|
|
3434
|
+
onClick: () => setEverywhere(all)
|
|
3435
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3436
|
+
className: "trm-ellipsis"
|
|
3437
|
+
}, all ? dt("scopeAll", { name }) : dt("scopeHere", { place: here.place })))))), /* @__PURE__ */ React.createElement("div", {
|
|
3438
|
+
className: "trm-grant-field"
|
|
3439
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3440
|
+
className: "trm-grant-label"
|
|
3441
|
+
}, dt("duration")), /* @__PURE__ */ React.createElement("span", {
|
|
3442
|
+
className: "trm-chips"
|
|
3443
|
+
}, GRANT_HOURS.map((each) => /* @__PURE__ */ React.createElement("button", {
|
|
3444
|
+
key: each,
|
|
3445
|
+
type: "button",
|
|
3446
|
+
"aria-pressed": hours === each,
|
|
2632
3447
|
className: `trm-chip${hours === each ? " trm-chip-on" : ""}`,
|
|
2633
3448
|
onClick: () => setHours(each)
|
|
2634
3449
|
}, hoursLabel(each))))), /* @__PURE__ */ React.createElement("p", {
|
|
@@ -2661,13 +3476,53 @@ function GrantDialog({ friend, name, ask, close }) {
|
|
|
2661
3476
|
onClose: () => setPicking(false)
|
|
2662
3477
|
}));
|
|
2663
3478
|
}
|
|
2664
|
-
function openGrant(member) {
|
|
3479
|
+
function openGrant(member, room) {
|
|
2665
3480
|
show(({ close }) => /* @__PURE__ */ React.createElement(GrantDialog, {
|
|
2666
3481
|
friend: member.id,
|
|
2667
3482
|
name: member.name,
|
|
3483
|
+
room,
|
|
3484
|
+
close
|
|
3485
|
+
}));
|
|
3486
|
+
}
|
|
3487
|
+
function openApprove(task) {
|
|
3488
|
+
show(({ close }) => /* @__PURE__ */ React.createElement(ApproveDialog, {
|
|
3489
|
+
task,
|
|
2668
3490
|
close
|
|
2669
3491
|
}));
|
|
2670
3492
|
}
|
|
3493
|
+
function ApproveDialog({ task, close }) {
|
|
3494
|
+
const [busy, run] = useBusy();
|
|
3495
|
+
const answer = (accept) => void run(async () => {
|
|
3496
|
+
await callDoubles({ kind: "approveTask", task: task.id, accept }).catch((error) => pi.ui.notify(message(error), "error"));
|
|
3497
|
+
close();
|
|
3498
|
+
});
|
|
3499
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
3500
|
+
title: rt("approveTitle", { name: task.name }),
|
|
3501
|
+
onClose: close
|
|
3502
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3503
|
+
className: "trm-dialog"
|
|
3504
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3505
|
+
className: "trm-grant-who"
|
|
3506
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
3507
|
+
id: task.friend,
|
|
3508
|
+
name: task.name,
|
|
3509
|
+
size: 36
|
|
3510
|
+
}), /* @__PURE__ */ React.createElement("p", {
|
|
3511
|
+
className: "trm-lead"
|
|
3512
|
+
}, task.text)), /* @__PURE__ */ React.createElement("div", {
|
|
3513
|
+
className: "trm-actions"
|
|
3514
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3515
|
+
type: "button",
|
|
3516
|
+
className: "ta-button",
|
|
3517
|
+
disabled: busy,
|
|
3518
|
+
onClick: () => answer(false)
|
|
3519
|
+
}, rt("approveDecline")), /* @__PURE__ */ React.createElement("button", {
|
|
3520
|
+
type: "button",
|
|
3521
|
+
className: "ta-button ta-primary",
|
|
3522
|
+
disabled: busy,
|
|
3523
|
+
onClick: () => answer(true)
|
|
3524
|
+
}, rt("approveTake")))));
|
|
3525
|
+
}
|
|
2671
3526
|
var asking;
|
|
2672
3527
|
function openAsk(ask) {
|
|
2673
3528
|
if (asking) {
|
|
@@ -2706,23 +3561,12 @@ function AskRow({ ask }) {
|
|
|
2706
3561
|
onClick: () => openAsk(ask)
|
|
2707
3562
|
}, dt("review"))));
|
|
2708
3563
|
}
|
|
2709
|
-
function
|
|
2710
|
-
const { quiet } = useDoubles();
|
|
2711
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
2712
|
-
className: "trm-double-switch"
|
|
2713
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
2714
|
-
className: "trm-grant-text"
|
|
2715
|
-
}, /* @__PURE__ */ React.createElement("span", null, dt("answersHere")), /* @__PURE__ */ React.createElement("span", {
|
|
2716
|
-
className: "trm-note"
|
|
2717
|
-
}, dt("answersHint"))), /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
2718
|
-
checked: !quiet[room.id],
|
|
2719
|
-
label: dt("answersHere"),
|
|
2720
|
-
onChange: (on) => callDoubles({ kind: "quiet", room: room.id, quiet: !on }).catch((error) => pi.ui.notify(message(error), "error"))
|
|
2721
|
-
}));
|
|
2722
|
-
}
|
|
2723
|
-
function useMayLine(member) {
|
|
3564
|
+
function useMayLine(member, room) {
|
|
2724
3565
|
const { grants } = useDoubles();
|
|
2725
|
-
return member.self || member.guest ? "" : mayLine(grantsOf(grants, member.id));
|
|
3566
|
+
return member.self || member.guest ? "" : mayLine(grantsOf(grants, member.id, room));
|
|
3567
|
+
}
|
|
3568
|
+
function scopeOf(grant) {
|
|
3569
|
+
return grant.room ? dt("scopeHereShort", { place: grant.title ?? "" }) : dt("scopeAllShort");
|
|
2726
3570
|
}
|
|
2727
3571
|
async function revokeAll(friend, name) {
|
|
2728
3572
|
if (await pi.ui.confirm(dt("revokeAllTitle", { name }), dt("revokeAllHint", { name }), { confirmLabel: dt("stop"), danger: true })) {
|
|
@@ -2758,7 +3602,7 @@ function GrantRow({ grant }) {
|
|
|
2758
3602
|
}, capabilityName(grant.capability))), /* @__PURE__ */ React.createElement("span", {
|
|
2759
3603
|
className: "trm-row-line trm-ellipsis",
|
|
2760
3604
|
title: grant.cwd
|
|
2761
|
-
}, grant.cwd, " · ", left(grant.expiresAt))), /* @__PURE__ */ React.createElement("button", {
|
|
3605
|
+
}, scopeOf(grant), " · ", grant.cwd, " · ", left(grant.expiresAt))), /* @__PURE__ */ React.createElement("button", {
|
|
2762
3606
|
type: "button",
|
|
2763
3607
|
className: "ta-button",
|
|
2764
3608
|
disabled: busy,
|
|
@@ -2766,7 +3610,7 @@ function GrantRow({ grant }) {
|
|
|
2766
3610
|
}, dt("revoke")));
|
|
2767
3611
|
}
|
|
2768
3612
|
function LogRow({ entry }) {
|
|
2769
|
-
const outcome = entry.outcome === "answered" ? dt("answered") : entry.outcome === "failed" ? dt("failed") : dt("limited");
|
|
3613
|
+
const outcome = entry.outcome === "answered" ? dt("answered") : entry.outcome === "drafted" ? rt("drafted") : entry.outcome === "failed" ? dt("failed") : dt("limited");
|
|
2770
3614
|
return /* @__PURE__ */ React.createElement("li", {
|
|
2771
3615
|
className: "trm-log"
|
|
2772
3616
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
@@ -2784,7 +3628,7 @@ function LogRow({ entry }) {
|
|
|
2784
3628
|
}, entry.asked), entry.answer && /* @__PURE__ */ React.createElement("div", {
|
|
2785
3629
|
className: "trm-log-answer"
|
|
2786
3630
|
}, entry.answer), /* @__PURE__ */ React.createElement("div", {
|
|
2787
|
-
className: `trm-log-meta${entry.outcome === "answered" ? "" : " trm-log-bad"}`
|
|
3631
|
+
className: `trm-log-meta${entry.outcome === "answered" || entry.outcome === "drafted" ? "" : " trm-log-bad"}`
|
|
2788
3632
|
}, [
|
|
2789
3633
|
outcome,
|
|
2790
3634
|
...entry.capabilities.length ? [entry.capabilities.map(capabilityName).join(" · ")] : [],
|
|
@@ -2792,11 +3636,33 @@ function LogRow({ entry }) {
|
|
|
2792
3636
|
...entry.error ? [entry.error] : []
|
|
2793
3637
|
].join(" · ")));
|
|
2794
3638
|
}
|
|
3639
|
+
function GrantList() {
|
|
3640
|
+
const { grants } = useDoubles();
|
|
3641
|
+
const now = Date.now();
|
|
3642
|
+
const live = grants.filter((grant) => grant.expiresAt > now);
|
|
3643
|
+
const friends = [...new Map(live.map((grant) => [grant.friend, grant.name])).entries()];
|
|
3644
|
+
if (live.length === 0) {
|
|
3645
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
3646
|
+
className: "trm-note"
|
|
3647
|
+
}, dt("noGrants"));
|
|
3648
|
+
}
|
|
3649
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3650
|
+
className: "trm-grants"
|
|
3651
|
+
}, /* @__PURE__ */ React.createElement("ul", {
|
|
3652
|
+
className: "trm-rows"
|
|
3653
|
+
}, live.map((grant) => /* @__PURE__ */ React.createElement(GrantRow, {
|
|
3654
|
+
key: grant.id,
|
|
3655
|
+
grant
|
|
3656
|
+
}))), friends.map(([friend, name]) => /* @__PURE__ */ React.createElement(RevokeAll, {
|
|
3657
|
+
key: friend,
|
|
3658
|
+
friend,
|
|
3659
|
+
name
|
|
3660
|
+
})));
|
|
3661
|
+
}
|
|
2795
3662
|
function DoublesView() {
|
|
2796
3663
|
const { grants, asks, log } = useDoubles();
|
|
2797
3664
|
const now = Date.now();
|
|
2798
3665
|
const live = grants.filter((grant) => grant.expiresAt > now);
|
|
2799
|
-
const friends = [...new Map(live.map((grant) => [grant.friend, grant.name])).entries()];
|
|
2800
3666
|
const recent = [...log].reverse();
|
|
2801
3667
|
return /* @__PURE__ */ React.createElement("div", {
|
|
2802
3668
|
className: "trm-panel"
|
|
@@ -2811,48 +3677,571 @@ function DoublesView() {
|
|
|
2811
3677
|
ask
|
|
2812
3678
|
})))), /* @__PURE__ */ React.createElement("div", {
|
|
2813
3679
|
className: "trm-panel-label"
|
|
2814
|
-
}, dt("grants")),
|
|
3680
|
+
}, dt("grants")), /* @__PURE__ */ React.createElement("p", {
|
|
2815
3681
|
className: "trm-note trm-panel-note"
|
|
2816
|
-
}, dt("noGrants"))
|
|
2817
|
-
className: "trm-rows"
|
|
2818
|
-
}, live.map((grant) => /* @__PURE__ */ React.createElement(GrantRow, {
|
|
2819
|
-
key: grant.id,
|
|
2820
|
-
grant
|
|
2821
|
-
}))), friends.map(([friend, name]) => /* @__PURE__ */ React.createElement(RevokeAll, {
|
|
2822
|
-
key: friend,
|
|
2823
|
-
friend,
|
|
2824
|
-
name
|
|
2825
|
-
}))), /* @__PURE__ */ React.createElement("div", {
|
|
3682
|
+
}, [live.length ? mayLine(live) : dt("noGrants"), dt("grantsInSettings")].join(" · ")), /* @__PURE__ */ React.createElement("div", {
|
|
2826
3683
|
className: "trm-panel-label trm-log-label"
|
|
2827
3684
|
}, /* @__PURE__ */ React.createElement("span", null, dt("logTitle")), recent.length > 0 && /* @__PURE__ */ React.createElement("button", {
|
|
2828
3685
|
type: "button",
|
|
2829
|
-
className: "trm-link",
|
|
2830
|
-
onClick: () => void callDoubles({ kind: "clearLog" }).catch((error) => pi.ui.notify(message(error), "error"))
|
|
2831
|
-
}, dt("clearLog"))), recent.length === 0 ? /* @__PURE__ */ React.createElement("div", {
|
|
2832
|
-
className: "trm-log-empty"
|
|
2833
|
-
}, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
2834
|
-
title: dt("logEmpty"),
|
|
2835
|
-
hint: dt("logEmptyHint"),
|
|
2836
|
-
compact: true
|
|
2837
|
-
})) : /* @__PURE__ */ React.createElement("ul", {
|
|
2838
|
-
className: "trm-logs"
|
|
2839
|
-
}, recent.map((entry) => /* @__PURE__ */ React.createElement(LogRow, {
|
|
2840
|
-
key: entry.id,
|
|
2841
|
-
entry
|
|
2842
|
-
})))));
|
|
2843
|
-
}
|
|
2844
|
-
function listenAsks() {
|
|
2845
|
-
doubles.onAsk = (asks) => {
|
|
2846
|
-
const latest = asks[asks.length - 1];
|
|
2847
|
-
if (latest) {
|
|
2848
|
-
openAsk(latest);
|
|
2849
|
-
}
|
|
2850
|
-
};
|
|
2851
|
-
const stop = doubles.start();
|
|
2852
|
-
return () => {
|
|
2853
|
-
doubles.onAsk = undefined;
|
|
2854
|
-
stop();
|
|
2855
|
-
};
|
|
3686
|
+
className: "trm-link",
|
|
3687
|
+
onClick: () => void callDoubles({ kind: "clearLog" }).catch((error) => pi.ui.notify(message(error), "error"))
|
|
3688
|
+
}, dt("clearLog"))), recent.length === 0 ? /* @__PURE__ */ React.createElement("div", {
|
|
3689
|
+
className: "trm-log-empty"
|
|
3690
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
3691
|
+
title: dt("logEmpty"),
|
|
3692
|
+
hint: dt("logEmptyHint"),
|
|
3693
|
+
compact: true
|
|
3694
|
+
})) : /* @__PURE__ */ React.createElement("ul", {
|
|
3695
|
+
className: "trm-logs"
|
|
3696
|
+
}, recent.map((entry) => /* @__PURE__ */ React.createElement(LogRow, {
|
|
3697
|
+
key: entry.id,
|
|
3698
|
+
entry
|
|
3699
|
+
})))));
|
|
3700
|
+
}
|
|
3701
|
+
function listenAsks() {
|
|
3702
|
+
doubles.onAsk = (asks) => {
|
|
3703
|
+
const latest = asks[asks.length - 1];
|
|
3704
|
+
if (latest) {
|
|
3705
|
+
openAsk(latest);
|
|
3706
|
+
}
|
|
3707
|
+
};
|
|
3708
|
+
const stop = doubles.start();
|
|
3709
|
+
return () => {
|
|
3710
|
+
doubles.onAsk = undefined;
|
|
3711
|
+
stop();
|
|
3712
|
+
};
|
|
3713
|
+
}
|
|
3714
|
+
|
|
3715
|
+
// web-src/reply-view.tsx
|
|
3716
|
+
function modeName(mode) {
|
|
3717
|
+
switch (mode) {
|
|
3718
|
+
case "away":
|
|
3719
|
+
return rt("modeAway");
|
|
3720
|
+
case "draft":
|
|
3721
|
+
return rt("modeDraft");
|
|
3722
|
+
case "always":
|
|
3723
|
+
return rt("modeAlways");
|
|
3724
|
+
default:
|
|
3725
|
+
return rt("modeNotify");
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
function modeHint(mode, policy) {
|
|
3729
|
+
switch (mode) {
|
|
3730
|
+
case "away":
|
|
3731
|
+
return rt("modeAwayHint", { n: policy.awayMinutes });
|
|
3732
|
+
case "draft":
|
|
3733
|
+
return rt("modeDraftHint");
|
|
3734
|
+
case "always":
|
|
3735
|
+
return rt("modeAlwaysHint");
|
|
3736
|
+
default:
|
|
3737
|
+
return rt("modeNotifyHint");
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
async function setReply(change) {
|
|
3741
|
+
try {
|
|
3742
|
+
const { reply, quiet } = doubles.get();
|
|
3743
|
+
await pi.storage.set(DoubleKeys.REPLY, change(reply));
|
|
3744
|
+
if (Object.keys(quiet).length) {
|
|
3745
|
+
await pi.storage.set(DoubleKeys.QUIET, {});
|
|
3746
|
+
}
|
|
3747
|
+
} catch (error) {
|
|
3748
|
+
pi.ui.notify(message(error), "error");
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
function ModeSelect({
|
|
3752
|
+
value,
|
|
3753
|
+
onChange,
|
|
3754
|
+
inherit,
|
|
3755
|
+
label
|
|
3756
|
+
}) {
|
|
3757
|
+
return /* @__PURE__ */ React.createElement("select", {
|
|
3758
|
+
className: "trm-field",
|
|
3759
|
+
"aria-label": label,
|
|
3760
|
+
value: value ?? "",
|
|
3761
|
+
onChange: (event) => onChange(ReplyPolicyUtil.isMode(event.target.value) ? event.target.value : undefined)
|
|
3762
|
+
}, inherit && /* @__PURE__ */ React.createElement("option", {
|
|
3763
|
+
value: ""
|
|
3764
|
+
}, rt("modeDefault")), REPLY_MODES.map((mode) => /* @__PURE__ */ React.createElement("option", {
|
|
3765
|
+
key: mode,
|
|
3766
|
+
value: mode
|
|
3767
|
+
}, modeName(mode))));
|
|
3768
|
+
}
|
|
3769
|
+
function ReplyRow({
|
|
3770
|
+
label,
|
|
3771
|
+
value,
|
|
3772
|
+
inherit,
|
|
3773
|
+
onChange
|
|
3774
|
+
}) {
|
|
3775
|
+
const { reply } = useDoubles();
|
|
3776
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3777
|
+
className: "trm-reply-row"
|
|
3778
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3779
|
+
className: "trm-grant-text"
|
|
3780
|
+
}, /* @__PURE__ */ React.createElement("span", null, label), /* @__PURE__ */ React.createElement("span", {
|
|
3781
|
+
className: "trm-note"
|
|
3782
|
+
}, modeHint(value ?? inherit, reply))), /* @__PURE__ */ React.createElement(ModeSelect, {
|
|
3783
|
+
value,
|
|
3784
|
+
inherit,
|
|
3785
|
+
label,
|
|
3786
|
+
onChange
|
|
3787
|
+
}));
|
|
3788
|
+
}
|
|
3789
|
+
function ReplyHere({ room }) {
|
|
3790
|
+
const { reply } = useDoubles();
|
|
3791
|
+
const { friends } = useBook();
|
|
3792
|
+
const peer = DirectUtil.is(room) ? DirectUtil.peer(room) : undefined;
|
|
3793
|
+
const friend = !!peer && !!friends?.some((each) => each.id === peer.id && each.status === "friend");
|
|
3794
|
+
const inherit = peer && reply.people[peer.id]?.reply || (peer && !friend ? reply.strangers : reply.mode);
|
|
3795
|
+
return /* @__PURE__ */ React.createElement(ReplyRow, {
|
|
3796
|
+
label: rt("replyHere"),
|
|
3797
|
+
value: reply.chats[room.id],
|
|
3798
|
+
inherit,
|
|
3799
|
+
onChange: (mode) => void setReply((policy) => ReplyPolicyUtil.set(policy, "chats", room.id, mode))
|
|
3800
|
+
});
|
|
3801
|
+
}
|
|
3802
|
+
function DefaultMode() {
|
|
3803
|
+
const { reply } = useDoubles();
|
|
3804
|
+
return /* @__PURE__ */ React.createElement(ModeSelect, {
|
|
3805
|
+
value: reply.mode,
|
|
3806
|
+
label: rt("replyDefault"),
|
|
3807
|
+
onChange: (mode) => mode && void setReply((policy) => ({ ...policy, mode }))
|
|
3808
|
+
});
|
|
3809
|
+
}
|
|
3810
|
+
function AwayMinutes() {
|
|
3811
|
+
const { reply } = useDoubles();
|
|
3812
|
+
const choices = AWAY_MINUTES.includes(reply.awayMinutes) ? AWAY_MINUTES : [...AWAY_MINUTES, reply.awayMinutes].sort((a, b) => a - b);
|
|
3813
|
+
return /* @__PURE__ */ React.createElement("select", {
|
|
3814
|
+
className: "trm-field",
|
|
3815
|
+
"aria-label": rt("replyAway"),
|
|
3816
|
+
value: reply.awayMinutes,
|
|
3817
|
+
onChange: (event) => void setReply((policy) => ({ ...policy, awayMinutes: Number(event.target.value) }))
|
|
3818
|
+
}, choices.map((n) => /* @__PURE__ */ React.createElement("option", {
|
|
3819
|
+
key: n,
|
|
3820
|
+
value: n
|
|
3821
|
+
}, rt("minutes", { n }))));
|
|
3822
|
+
}
|
|
3823
|
+
function StrangersMode() {
|
|
3824
|
+
const { reply } = useDoubles();
|
|
3825
|
+
return /* @__PURE__ */ React.createElement(ModeSelect, {
|
|
3826
|
+
value: reply.strangers,
|
|
3827
|
+
label: rt("replyStrangers"),
|
|
3828
|
+
onChange: (mode) => mode && void setReply((policy) => ({ ...policy, strangers: mode }))
|
|
3829
|
+
});
|
|
3830
|
+
}
|
|
3831
|
+
var QUIET_DEFAULT = { from: 22 * 60, to: 8 * 60, mode: "draft" };
|
|
3832
|
+
function QuietHours() {
|
|
3833
|
+
const { reply } = useDoubles();
|
|
3834
|
+
const quiet = reply.quiet;
|
|
3835
|
+
const Switch = pi.ui.Switch;
|
|
3836
|
+
const change = (next) => void setReply((policy) => ({ ...policy, quiet: { ...policy.quiet ?? QUIET_DEFAULT, ...next } }));
|
|
3837
|
+
const time = (key, label) => /* @__PURE__ */ React.createElement("input", {
|
|
3838
|
+
className: "trm-field trm-field-time",
|
|
3839
|
+
type: "time",
|
|
3840
|
+
"aria-label": label,
|
|
3841
|
+
value: ReplyPolicyUtil.clock((quiet ?? QUIET_DEFAULT)[key]),
|
|
3842
|
+
onChange: (event) => {
|
|
3843
|
+
const minutes = ReplyPolicyUtil.minutes(event.target.value);
|
|
3844
|
+
if (minutes !== undefined) {
|
|
3845
|
+
change({ [key]: minutes });
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
});
|
|
3849
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3850
|
+
className: "trm-quiet-hours"
|
|
3851
|
+
}, /* @__PURE__ */ React.createElement(Switch, {
|
|
3852
|
+
checked: !!quiet,
|
|
3853
|
+
label: rt("replyQuiet"),
|
|
3854
|
+
onChange: (on) => void setReply((policy) => {
|
|
3855
|
+
const { quiet: _was, ...rest } = policy;
|
|
3856
|
+
return on ? { ...rest, quiet: QUIET_DEFAULT } : rest;
|
|
3857
|
+
})
|
|
3858
|
+
}), quiet && /* @__PURE__ */ React.createElement("span", {
|
|
3859
|
+
className: "trm-quiet-line"
|
|
3860
|
+
}, rt("replyQuietFrom") && /* @__PURE__ */ React.createElement("span", null, rt("replyQuietFrom")), time("from", rt("replyQuietFrom") || rt("replyQuiet")), /* @__PURE__ */ React.createElement("span", null, rt("replyQuietTo")), time("to", rt("replyQuietTo")), /* @__PURE__ */ React.createElement(ModeSelect, {
|
|
3861
|
+
value: quiet.mode,
|
|
3862
|
+
label: rt("replyQuiet"),
|
|
3863
|
+
onChange: (mode) => mode && change({ mode })
|
|
3864
|
+
})));
|
|
3865
|
+
}
|
|
3866
|
+
function OwnList() {
|
|
3867
|
+
const { reply } = useDoubles();
|
|
3868
|
+
const { rooms: rooms2, friends } = useBook();
|
|
3869
|
+
const Remove = icon("X");
|
|
3870
|
+
const rows = [
|
|
3871
|
+
...Object.entries(reply.people).map(([id, person]) => {
|
|
3872
|
+
const friend = friends?.find((each) => each.id === id);
|
|
3873
|
+
const what = [
|
|
3874
|
+
person.reply ? modeName(person.reply) : "",
|
|
3875
|
+
person.tasks ? `${rt("tasksShort")} ${taskName(person.tasks)}` : "",
|
|
3876
|
+
person.invites ? `${rt("invitesShort")} ${inviteName(person.invites)}` : "",
|
|
3877
|
+
person.moments === false ? rt("momentsHiddenShort") : ""
|
|
3878
|
+
].filter(Boolean);
|
|
3879
|
+
return {
|
|
3880
|
+
key: `p:${id}`,
|
|
3881
|
+
id,
|
|
3882
|
+
name: friend?.name ?? id.slice(0, 6),
|
|
3883
|
+
what: what.join(" · "),
|
|
3884
|
+
open: () => openPersonOf({ id, name: friend?.name ?? id.slice(0, 6) }),
|
|
3885
|
+
reset: () => setReply((policy) => ({ ...policy, people: Object.fromEntries(Object.entries(policy.people).filter(([each]) => each !== id)) }))
|
|
3886
|
+
};
|
|
3887
|
+
}),
|
|
3888
|
+
...Object.entries(reply.chats).flatMap(([id, mode]) => {
|
|
3889
|
+
const room = rooms2?.find((each) => each.id === id && each.status === "member");
|
|
3890
|
+
if (!room) {
|
|
3891
|
+
return [];
|
|
3892
|
+
}
|
|
3893
|
+
const peer = DirectUtil.is(room) ? DirectUtil.peer(room) : undefined;
|
|
3894
|
+
return [
|
|
3895
|
+
{
|
|
3896
|
+
key: `c:${id}`,
|
|
3897
|
+
id: peer?.id ?? id,
|
|
3898
|
+
name: peer?.name ?? room.title,
|
|
3899
|
+
what: modeName(mode),
|
|
3900
|
+
open: undefined,
|
|
3901
|
+
reset: () => setReply((policy) => ReplyPolicyUtil.set(policy, "chats", id, undefined))
|
|
3902
|
+
}
|
|
3903
|
+
];
|
|
3904
|
+
})
|
|
3905
|
+
];
|
|
3906
|
+
if (!rows.length) {
|
|
3907
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
3908
|
+
className: "trm-note"
|
|
3909
|
+
}, rt("replyOwnNone"));
|
|
3910
|
+
}
|
|
3911
|
+
return /* @__PURE__ */ React.createElement("ul", {
|
|
3912
|
+
className: "trm-reply-own"
|
|
3913
|
+
}, rows.map((row) => /* @__PURE__ */ React.createElement("li", {
|
|
3914
|
+
key: row.key,
|
|
3915
|
+
className: "trm-reply-own-row"
|
|
3916
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3917
|
+
type: "button",
|
|
3918
|
+
className: "trm-reply-own-open",
|
|
3919
|
+
disabled: !row.open,
|
|
3920
|
+
onClick: row.open
|
|
3921
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
3922
|
+
id: row.id,
|
|
3923
|
+
name: row.name,
|
|
3924
|
+
size: 24
|
|
3925
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
3926
|
+
className: "trm-ellipsis trm-reply-own-name"
|
|
3927
|
+
}, row.name), /* @__PURE__ */ React.createElement("span", {
|
|
3928
|
+
className: "trm-note trm-ellipsis"
|
|
3929
|
+
}, row.what)), /* @__PURE__ */ React.createElement("button", {
|
|
3930
|
+
type: "button",
|
|
3931
|
+
className: "trm-icon",
|
|
3932
|
+
title: rt("replyOwnRemove"),
|
|
3933
|
+
"aria-label": `${rt("replyOwnRemove")} · ${row.name}`,
|
|
3934
|
+
onClick: () => void row.reset()
|
|
3935
|
+
}, /* @__PURE__ */ React.createElement(Remove, {
|
|
3936
|
+
size: 14
|
|
3937
|
+
})))));
|
|
3938
|
+
}
|
|
3939
|
+
var openPersonOf = () => {
|
|
3940
|
+
return;
|
|
3941
|
+
};
|
|
3942
|
+
function bindPersonOpener(open) {
|
|
3943
|
+
openPersonOf = open;
|
|
3944
|
+
}
|
|
3945
|
+
function Choice({
|
|
3946
|
+
value,
|
|
3947
|
+
options,
|
|
3948
|
+
name,
|
|
3949
|
+
label,
|
|
3950
|
+
onChange
|
|
3951
|
+
}) {
|
|
3952
|
+
return /* @__PURE__ */ React.createElement("select", {
|
|
3953
|
+
className: "trm-field",
|
|
3954
|
+
"aria-label": label,
|
|
3955
|
+
value,
|
|
3956
|
+
onChange: (event) => onChange(event.target.value)
|
|
3957
|
+
}, options.map((option) => /* @__PURE__ */ React.createElement("option", {
|
|
3958
|
+
key: option,
|
|
3959
|
+
value: option
|
|
3960
|
+
}, name(option))));
|
|
3961
|
+
}
|
|
3962
|
+
function taskName(mode) {
|
|
3963
|
+
return mode === "allow" ? rt("taskAllow") : mode === "ask" ? rt("taskAsk") : rt("taskDeny");
|
|
3964
|
+
}
|
|
3965
|
+
function inviteName(mode) {
|
|
3966
|
+
return mode === "join" ? rt("inviteJoin") : mode === "ask" ? rt("inviteAsk") : rt("inviteDeny");
|
|
3967
|
+
}
|
|
3968
|
+
function TasksFriends() {
|
|
3969
|
+
const { reply } = useDoubles();
|
|
3970
|
+
return /* @__PURE__ */ React.createElement(Choice, {
|
|
3971
|
+
value: reply.tasks.friends,
|
|
3972
|
+
options: TASK_MODES,
|
|
3973
|
+
name: taskName,
|
|
3974
|
+
label: rt("tasksFriends"),
|
|
3975
|
+
onChange: (friends) => void setReply((policy) => ({ ...policy, tasks: { ...policy.tasks, friends } }))
|
|
3976
|
+
});
|
|
3977
|
+
}
|
|
3978
|
+
function TasksOthers() {
|
|
3979
|
+
const { reply } = useDoubles();
|
|
3980
|
+
return /* @__PURE__ */ React.createElement(Choice, {
|
|
3981
|
+
value: reply.tasks.strangers,
|
|
3982
|
+
options: TASK_MODES,
|
|
3983
|
+
name: taskName,
|
|
3984
|
+
label: rt("tasksOthers"),
|
|
3985
|
+
onChange: (strangers) => void setReply((policy) => ({ ...policy, tasks: { ...policy.tasks, strangers } }))
|
|
3986
|
+
});
|
|
3987
|
+
}
|
|
3988
|
+
function InvitesAll() {
|
|
3989
|
+
const { reply } = useDoubles();
|
|
3990
|
+
return /* @__PURE__ */ React.createElement(Choice, {
|
|
3991
|
+
value: reply.invites,
|
|
3992
|
+
options: INVITE_MODES,
|
|
3993
|
+
name: inviteName,
|
|
3994
|
+
label: rt("invitesAll"),
|
|
3995
|
+
onChange: (invites) => void setReply((policy) => ({ ...policy, invites }))
|
|
3996
|
+
});
|
|
3997
|
+
}
|
|
3998
|
+
function replySettings() {
|
|
3999
|
+
return {
|
|
4000
|
+
title: () => rt("replyTitle"),
|
|
4001
|
+
icon: icon("MessageCircle"),
|
|
4002
|
+
group: "general",
|
|
4003
|
+
rows: [
|
|
4004
|
+
{ key: "reply-mode", label: () => rt("replyDefault"), description: () => rt("replyLead"), render: DefaultMode },
|
|
4005
|
+
{ key: "reply-away", label: () => rt("replyAway"), description: () => rt("replyAwayHint"), render: AwayMinutes },
|
|
4006
|
+
{ key: "reply-strangers", label: () => rt("replyStrangers"), description: () => rt("replyStrangersHint"), render: StrangersMode },
|
|
4007
|
+
{ key: "reply-quiet", label: () => rt("replyQuiet"), description: () => rt("replyQuietHint"), render: QuietHours, stacked: true },
|
|
4008
|
+
{ key: "tasks-friends", label: () => rt("tasksFriends"), description: () => rt("policyAllHint"), render: TasksFriends },
|
|
4009
|
+
{ key: "tasks-others", label: () => rt("tasksOthers"), render: TasksOthers },
|
|
4010
|
+
{ key: "invites", label: () => rt("invitesAll"), render: InvitesAll },
|
|
4011
|
+
{ key: "reply-own", label: () => rt("replyOwn"), description: () => rt("replyOwnHint"), render: OwnList, stacked: true },
|
|
4012
|
+
{ key: "reply-grants", label: () => dt("grantsTitle"), description: () => dt("grantsHint"), render: GrantList, stacked: true }
|
|
4013
|
+
]
|
|
4014
|
+
};
|
|
4015
|
+
}
|
|
4016
|
+
function DraftCard({ draft }) {
|
|
4017
|
+
const [editing, setEditing] = React.useState();
|
|
4018
|
+
const [busy, setBusy] = React.useState(false);
|
|
4019
|
+
const run = async (send, text) => {
|
|
4020
|
+
setBusy(true);
|
|
4021
|
+
try {
|
|
4022
|
+
await callDoubles(send ? { kind: "sendDraft", draft: draft.id, ...text !== undefined ? { text } : {} } : { kind: "dropDraft", draft: draft.id });
|
|
4023
|
+
} catch (error) {
|
|
4024
|
+
pi.ui.notify(message(error), "error");
|
|
4025
|
+
} finally {
|
|
4026
|
+
setBusy(false);
|
|
4027
|
+
}
|
|
4028
|
+
};
|
|
4029
|
+
const Bot = icon("Bot");
|
|
4030
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4031
|
+
className: `trm-draft${busy ? " ta-pending" : ""}`
|
|
4032
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
4033
|
+
className: "trm-draft-head"
|
|
4034
|
+
}, /* @__PURE__ */ React.createElement(Bot, {
|
|
4035
|
+
size: 14
|
|
4036
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
4037
|
+
className: "trm-ellipsis"
|
|
4038
|
+
}, rt("draftTitle", { name: draft.name }))), /* @__PURE__ */ React.createElement("div", {
|
|
4039
|
+
className: "trm-draft-asked trm-ellipsis"
|
|
4040
|
+
}, draft.asked), editing === undefined ? /* @__PURE__ */ React.createElement("div", {
|
|
4041
|
+
className: "trm-draft-text"
|
|
4042
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
4043
|
+
text: draft.text
|
|
4044
|
+
})) : /* @__PURE__ */ React.createElement("textarea", {
|
|
4045
|
+
className: "trm-draft-edit",
|
|
4046
|
+
value: editing,
|
|
4047
|
+
rows: 3,
|
|
4048
|
+
onChange: (event) => setEditing(event.target.value)
|
|
4049
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
4050
|
+
className: "trm-draft-actions"
|
|
4051
|
+
}, editing === undefined ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("button", {
|
|
4052
|
+
type: "button",
|
|
4053
|
+
className: "ta-button",
|
|
4054
|
+
disabled: busy,
|
|
4055
|
+
onClick: () => void run(false)
|
|
4056
|
+
}, rt("draftDrop")), /* @__PURE__ */ React.createElement("button", {
|
|
4057
|
+
type: "button",
|
|
4058
|
+
className: "ta-button",
|
|
4059
|
+
disabled: busy,
|
|
4060
|
+
onClick: () => setEditing(draft.text)
|
|
4061
|
+
}, rt("draftEdit")), /* @__PURE__ */ React.createElement("button", {
|
|
4062
|
+
type: "button",
|
|
4063
|
+
className: "ta-button ta-primary",
|
|
4064
|
+
disabled: busy,
|
|
4065
|
+
onClick: () => void run(true)
|
|
4066
|
+
}, rt("draftSend"))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("button", {
|
|
4067
|
+
type: "button",
|
|
4068
|
+
className: "ta-button",
|
|
4069
|
+
disabled: busy,
|
|
4070
|
+
onClick: () => setEditing(undefined)
|
|
4071
|
+
}, rt("draftCancel")), /* @__PURE__ */ React.createElement("button", {
|
|
4072
|
+
type: "button",
|
|
4073
|
+
className: "ta-button ta-primary",
|
|
4074
|
+
disabled: busy || !editing.trim(),
|
|
4075
|
+
onClick: () => void run(true, editing)
|
|
4076
|
+
}, rt("draftSave")))));
|
|
4077
|
+
}
|
|
4078
|
+
function Drafts({ room }) {
|
|
4079
|
+
const { drafts } = useDoubles();
|
|
4080
|
+
const mine = drafts.filter((draft) => draft.room === room.id);
|
|
4081
|
+
if (!mine.length) {
|
|
4082
|
+
return null;
|
|
4083
|
+
}
|
|
4084
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4085
|
+
className: "trm-drafts"
|
|
4086
|
+
}, mine.map((draft) => /* @__PURE__ */ React.createElement(DraftCard, {
|
|
4087
|
+
key: draft.id,
|
|
4088
|
+
draft
|
|
4089
|
+
})));
|
|
4090
|
+
}
|
|
4091
|
+
|
|
4092
|
+
// web-src/agents-view.tsx
|
|
4093
|
+
function agentOwner(room, agent) {
|
|
4094
|
+
const owner = room.members.find((member) => member.member === agent.member);
|
|
4095
|
+
return owner?.self ? dt("myAgent") : dt("agentOf", { name: owner?.name ?? "" });
|
|
4096
|
+
}
|
|
4097
|
+
function agentMentions(room, agents) {
|
|
4098
|
+
return agents.map((agent) => ({ name: agent.name, detail: agentOwner(room, agent) }));
|
|
4099
|
+
}
|
|
4100
|
+
function inviteAgent(room, agent) {
|
|
4101
|
+
const self = room.members.find((member) => member.self)?.member;
|
|
4102
|
+
const joining = { id: agent.id, name: agent.name, ...typeof agent.face === "number" ? { face: agent.face } : {} };
|
|
4103
|
+
const chat = book.chat(room.id);
|
|
4104
|
+
const before = new Set(chat?.lines.map((line) => line.id));
|
|
4105
|
+
book.setJoining(room.id, joining, true);
|
|
4106
|
+
callDoubles({ kind: "invite", room: room.id, agent: agent.id }).then(async (list) => {
|
|
4107
|
+
if (self && Array.isArray(list)) {
|
|
4108
|
+
book.putMine(room.id, self, list);
|
|
4109
|
+
}
|
|
4110
|
+
if (chat) {
|
|
4111
|
+
await saidHello(chat, (line) => !before.has(line.id) && line.agent?.id === agent.id && line.from === self);
|
|
4112
|
+
}
|
|
4113
|
+
}).catch((failure) => pi.ui.notify(dt("inviteFailed", { name: agent.name, error: message(failure) }), "error")).finally(() => book.setJoining(room.id, joining, false));
|
|
4114
|
+
}
|
|
4115
|
+
var HELLO_MS = 1e4;
|
|
4116
|
+
function saidHello(chat, hello) {
|
|
4117
|
+
return new Promise((resolve) => {
|
|
4118
|
+
const check = () => {
|
|
4119
|
+
if (chat.lines.some(hello)) {
|
|
4120
|
+
done();
|
|
4121
|
+
}
|
|
4122
|
+
};
|
|
4123
|
+
const stop = chat.subscribe(check);
|
|
4124
|
+
const timer = setTimeout(() => done(), HELLO_MS);
|
|
4125
|
+
const done = () => {
|
|
4126
|
+
stop();
|
|
4127
|
+
clearTimeout(timer);
|
|
4128
|
+
resolve();
|
|
4129
|
+
};
|
|
4130
|
+
check();
|
|
4131
|
+
});
|
|
4132
|
+
}
|
|
4133
|
+
function AgentPicker({ room, close }) {
|
|
4134
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
4135
|
+
const [agents, setAgents] = React.useState();
|
|
4136
|
+
const [error, setError] = React.useState();
|
|
4137
|
+
const inRoom = useAgents(room);
|
|
4138
|
+
const joining = useJoining(room);
|
|
4139
|
+
const self = room.members.find((member) => member.self)?.member;
|
|
4140
|
+
React.useEffect(() => {
|
|
4141
|
+
callDoubles({ kind: "agents" }).then((list) => setAgents(Array.isArray(list) ? list : []), (failure) => setError(message(failure)));
|
|
4142
|
+
}, []);
|
|
4143
|
+
const invite = (agent) => {
|
|
4144
|
+
inviteAgent(room, agent);
|
|
4145
|
+
close();
|
|
4146
|
+
};
|
|
4147
|
+
const Plus = icon("Plus");
|
|
4148
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
4149
|
+
title: dt("pickAgentTitle", { title: room.title }),
|
|
4150
|
+
onClose: close
|
|
4151
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
4152
|
+
className: "trm-dialog"
|
|
4153
|
+
}, /* @__PURE__ */ React.createElement("p", {
|
|
4154
|
+
className: "trm-note"
|
|
4155
|
+
}, dt("pickAgentLead")), !agents && !error && Loading && /* @__PURE__ */ React.createElement(Loading, null), agents?.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
4156
|
+
title: dt("noAgents"),
|
|
4157
|
+
hint: dt("noAgentsHint"),
|
|
4158
|
+
compact: true
|
|
4159
|
+
}), agents && agents.length > 0 && /* @__PURE__ */ React.createElement("ul", {
|
|
4160
|
+
className: "trm-rows trm-agent-pick"
|
|
4161
|
+
}, agents.map((agent) => {
|
|
4162
|
+
const joined = inRoom.some((each) => each.id === agent.id && each.member === self);
|
|
4163
|
+
const coming = joining.some((each) => each.id === agent.id);
|
|
4164
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
4165
|
+
key: agent.id
|
|
4166
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
4167
|
+
type: "button",
|
|
4168
|
+
className: "trm-member",
|
|
4169
|
+
disabled: joined || coming,
|
|
4170
|
+
onClick: () => invite(agent)
|
|
4171
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
4172
|
+
id: agent.id,
|
|
4173
|
+
name: agent.name,
|
|
4174
|
+
face: agent.face,
|
|
4175
|
+
size: 34
|
|
4176
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
4177
|
+
className: "trm-member-text"
|
|
4178
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4179
|
+
className: "trm-member-name trm-ellipsis"
|
|
4180
|
+
}, agent.name), /* @__PURE__ */ React.createElement("span", {
|
|
4181
|
+
className: "trm-member-detail trm-ellipsis"
|
|
4182
|
+
}, joined ? dt("inRoom") : coming ? dt("joining") : agent.role)), coming ? /* @__PURE__ */ React.createElement("span", {
|
|
4183
|
+
className: "ta-spinner"
|
|
4184
|
+
}) : !joined && /* @__PURE__ */ React.createElement(Plus, {
|
|
4185
|
+
size: 16
|
|
4186
|
+
})));
|
|
4187
|
+
})), error && /* @__PURE__ */ React.createElement("p", {
|
|
4188
|
+
className: "trm-error"
|
|
4189
|
+
}, error)));
|
|
4190
|
+
}
|
|
4191
|
+
function openAgentPicker(room) {
|
|
4192
|
+
show(({ close }) => /* @__PURE__ */ React.createElement(AgentPicker, {
|
|
4193
|
+
room,
|
|
4194
|
+
close
|
|
4195
|
+
}));
|
|
4196
|
+
}
|
|
4197
|
+
function JoiningRow({ agent }) {
|
|
4198
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
4199
|
+
className: "trm-member",
|
|
4200
|
+
"aria-busy": "true"
|
|
4201
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
4202
|
+
id: agent.id,
|
|
4203
|
+
name: agent.name,
|
|
4204
|
+
face: agent.face,
|
|
4205
|
+
size: 34
|
|
4206
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
4207
|
+
className: "trm-member-text"
|
|
4208
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4209
|
+
className: "trm-member-name trm-ellipsis"
|
|
4210
|
+
}, agent.name), /* @__PURE__ */ React.createElement("span", {
|
|
4211
|
+
className: "trm-member-detail trm-ellipsis"
|
|
4212
|
+
}, dt("joining"))), /* @__PURE__ */ React.createElement("span", {
|
|
4213
|
+
className: "ta-spinner trm-member-action"
|
|
4214
|
+
}));
|
|
4215
|
+
}
|
|
4216
|
+
function AgentRow({ room, agent }) {
|
|
4217
|
+
const Remove = icon("X");
|
|
4218
|
+
const mine = room.members.find((member) => member.self)?.member === agent.member;
|
|
4219
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
4220
|
+
className: "trm-member"
|
|
4221
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
4222
|
+
id: agent.id,
|
|
4223
|
+
name: agent.name,
|
|
4224
|
+
face: agent.face,
|
|
4225
|
+
size: 34
|
|
4226
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
4227
|
+
className: "trm-member-text"
|
|
4228
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4229
|
+
className: "trm-member-name"
|
|
4230
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4231
|
+
className: "trm-ellipsis"
|
|
4232
|
+
}, agent.name), /* @__PURE__ */ React.createElement("span", {
|
|
4233
|
+
className: "trm-tag trm-tag-agent"
|
|
4234
|
+
}, agentOwner(room, agent))), agent.role && /* @__PURE__ */ React.createElement("span", {
|
|
4235
|
+
className: "trm-member-detail trm-ellipsis"
|
|
4236
|
+
}, agent.role)), mine && /* @__PURE__ */ React.createElement("button", {
|
|
4237
|
+
type: "button",
|
|
4238
|
+
className: "trm-icon trm-danger trm-member-action",
|
|
4239
|
+
title: dt("dismiss"),
|
|
4240
|
+
"aria-label": dt("dismiss"),
|
|
4241
|
+
onClick: () => void confirmThen(dt("dismissTitle", { name: agent.name, title: room.title }), dt("dismissHint"), dt("dismiss"), () => callDoubles({ kind: "dismiss", room: room.id, agent: agent.id })).then(() => book.agents(room.id))
|
|
4242
|
+
}, /* @__PURE__ */ React.createElement(Remove, {
|
|
4243
|
+
size: 15
|
|
4244
|
+
})));
|
|
2856
4245
|
}
|
|
2857
4246
|
|
|
2858
4247
|
// web-src/tasks-view.tsx
|
|
@@ -2960,7 +4349,7 @@ class RoomTaskSource {
|
|
|
2960
4349
|
id: `for:${task.id}`,
|
|
2961
4350
|
title: dt("taskFor", { name: task.name, text: task.text }),
|
|
2962
4351
|
status: listed(task.status, true),
|
|
2963
|
-
detail: task.status === "permission" ? dt("taskNeedsYou") : open ? taskStatusWord(task.status) : oneLine(task.answer ?? task.detail ?? taskStatusWord(task.status)),
|
|
4352
|
+
detail: task.approval ? rt("approveWaiting") : task.status === "permission" ? dt("taskNeedsYou") : open ? taskStatusWord(task.status) : oneLine(task.answer ?? task.detail ?? taskStatusWord(task.status)),
|
|
2964
4353
|
startedAt: task.at,
|
|
2965
4354
|
...task.endedAt && !open ? { endedAt: task.endedAt } : {},
|
|
2966
4355
|
icon: ({ size }) => /* @__PURE__ */ React.createElement(Face, {
|
|
@@ -2970,7 +4359,9 @@ class RoomTaskSource {
|
|
|
2970
4359
|
}),
|
|
2971
4360
|
open: () => {
|
|
2972
4361
|
const ask = state.asks.find((each) => each.friend === task.friend);
|
|
2973
|
-
if (task.
|
|
4362
|
+
if (task.approval) {
|
|
4363
|
+
openApprove(task);
|
|
4364
|
+
} else if (task.status === "permission" && ask) {
|
|
2974
4365
|
openAsk(ask);
|
|
2975
4366
|
} else {
|
|
2976
4367
|
openRoom(task.room, true);
|
|
@@ -3089,6 +4480,10 @@ function leaveRoom(room) {
|
|
|
3089
4480
|
if (room.status !== "member") {
|
|
3090
4481
|
return (rooms()?.leave(room.id) ?? Promise.resolve()).then(() => book.load()).then(() => true);
|
|
3091
4482
|
}
|
|
4483
|
+
if (DirectUtil.is(room)) {
|
|
4484
|
+
const { name } = directPeer(room, book.get().friends);
|
|
4485
|
+
return confirmThen(rt("directDeleteTitle", { name }), room.owner ? rt("directDeleteOwn") : rt("directDeleteOther", { name }), rt("directDelete"), async () => rooms()?.leave(room.id));
|
|
4486
|
+
}
|
|
3092
4487
|
return confirmThen(room.owner ? t("closeTitle", { title: room.title }) : t("leaveTitle", { title: room.title }), room.owner ? t("closeHint") : t("leaveHint"), room.owner ? t("close") : t("leave"), async () => rooms()?.leave(room.id));
|
|
3093
4488
|
}
|
|
3094
4489
|
function speaker(line) {
|
|
@@ -3111,6 +4506,23 @@ function RoomHead({ room }) {
|
|
|
3111
4506
|
}, [room.id]);
|
|
3112
4507
|
const page = usePageOf(room);
|
|
3113
4508
|
const online = room.members.filter((member) => member.online).length;
|
|
4509
|
+
const { friends } = useBook();
|
|
4510
|
+
if (DirectUtil.is(room)) {
|
|
4511
|
+
const peer = DirectUtil.peer(room);
|
|
4512
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4513
|
+
className: "trm-room-head"
|
|
4514
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4515
|
+
className: "trm-room-head-title"
|
|
4516
|
+
}, /* @__PURE__ */ React.createElement("strong", {
|
|
4517
|
+
className: "trm-ellipsis"
|
|
4518
|
+
}, directPeer(room, friends).name), /* @__PURE__ */ React.createElement("span", {
|
|
4519
|
+
className: `trm-room-head-sub${room.connected && peer?.online ? "" : " trm-quiet"}`
|
|
4520
|
+
}, !room.connected ? t("connecting") : peer ? peer.online ? t("online") : t("offline") : rt("directWaiting", { name: directPeer(room, friends).name }))), /* @__PURE__ */ React.createElement(MemberFaces, {
|
|
4521
|
+
room,
|
|
4522
|
+
shown,
|
|
4523
|
+
onClick: () => void pi.ui.showView(MEMBERS_VIEW)
|
|
4524
|
+
}));
|
|
4525
|
+
}
|
|
3114
4526
|
return /* @__PURE__ */ React.createElement("div", {
|
|
3115
4527
|
className: "trm-room-head"
|
|
3116
4528
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
@@ -3178,7 +4590,14 @@ function RoomView({ room, head, onBack }) {
|
|
|
3178
4590
|
const personOf = (line) => room.members.find((member) => member.member === line.from)?.name ?? line.name;
|
|
3179
4591
|
const nameOf = (line) => line.agent ? line.agent.name : !line.double ? personOf(line) : line.from === self?.member ? dt("myDouble") : dt("doubleOf", { name: personOf(line) });
|
|
3180
4592
|
const tagOf = (line) => line.agent ? agentOwner(room, { member: line.from }) : line.double ? dt("doubleTag") : "";
|
|
3181
|
-
const
|
|
4593
|
+
const direct = DirectUtil.is(room);
|
|
4594
|
+
const { friends } = useBook();
|
|
4595
|
+
const mentions = React.useMemo(() => [...agentMentions(room, agents), ...direct ? [] : mentionable(room).map((member) => ({ name: member.name, detail: rt("mentionPerson") }))], [room, agents, direct]);
|
|
4596
|
+
React.useEffect(() => {
|
|
4597
|
+
if (direct && room.owner && !DirectUtil.peer(room)) {
|
|
4598
|
+
reinvite(room);
|
|
4599
|
+
}
|
|
4600
|
+
}, [direct, room]);
|
|
3182
4601
|
React.useLayoutEffect(() => {
|
|
3183
4602
|
const element = list.current;
|
|
3184
4603
|
if (element && stuck.current) {
|
|
@@ -3202,8 +4621,8 @@ function RoomView({ room, head, onBack }) {
|
|
|
3202
4621
|
throw new Error(t("connecting"));
|
|
3203
4622
|
}
|
|
3204
4623
|
stuck.current = true;
|
|
3205
|
-
const to = addressed(text, room, agents);
|
|
3206
|
-
await chat.say(text, self, to.length ? { to } : {});
|
|
4624
|
+
const { to, person } = addressed(text, room, agents);
|
|
4625
|
+
await chat.say(text, self, to.length ? { to, ...person ? { person: true } : {} } : {});
|
|
3207
4626
|
};
|
|
3208
4627
|
return /* @__PURE__ */ React.createElement("div", {
|
|
3209
4628
|
className: "trm-room-page"
|
|
@@ -3230,7 +4649,14 @@ function RoomView({ room, head, onBack }) {
|
|
|
3230
4649
|
}
|
|
3231
4650
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
3232
4651
|
className: "trm-chat-col"
|
|
3233
|
-
}, lines.length === 0 && /* @__PURE__ */ React.createElement("div", {
|
|
4652
|
+
}, lines.length === 0 && direct && /* @__PURE__ */ React.createElement("div", {
|
|
4653
|
+
className: "trm-chat-empty"
|
|
4654
|
+
}, /* @__PURE__ */ React.createElement(DirectFace, {
|
|
4655
|
+
room,
|
|
4656
|
+
size: 56
|
|
4657
|
+
}), /* @__PURE__ */ React.createElement("strong", null, rt("directEmpty", { name: directPeer(room, friends).name })), /* @__PURE__ */ React.createElement("span", {
|
|
4658
|
+
className: "trm-chat-hint"
|
|
4659
|
+
}, rt("directHint", { name: directPeer(room, friends).name }))), lines.length === 0 && !direct && /* @__PURE__ */ React.createElement("div", {
|
|
3234
4660
|
className: "trm-chat-empty"
|
|
3235
4661
|
}, /* @__PURE__ */ React.createElement(RoomFace, {
|
|
3236
4662
|
room,
|
|
@@ -3290,15 +4716,176 @@ function RoomView({ room, head, onBack }) {
|
|
|
3290
4716
|
className: "ta-spinner"
|
|
3291
4717
|
}), dt("joiningRoom", { name: agent.name }))))), /* @__PURE__ */ React.createElement("div", {
|
|
3292
4718
|
className: "trm-chat-bottom"
|
|
3293
|
-
}, /* @__PURE__ */ React.createElement(
|
|
4719
|
+
}, /* @__PURE__ */ React.createElement(Drafts, {
|
|
4720
|
+
room
|
|
4721
|
+
}), /* @__PURE__ */ React.createElement(pi.ui.Composer, {
|
|
3294
4722
|
placeholder: t("chatPlaceholder"),
|
|
3295
4723
|
draft: room.id,
|
|
3296
4724
|
onSend: say,
|
|
3297
4725
|
mentions,
|
|
3298
|
-
mentionLabel:
|
|
4726
|
+
mentionLabel: rt("mentionPerson")
|
|
3299
4727
|
})));
|
|
3300
4728
|
}
|
|
3301
4729
|
|
|
4730
|
+
// web-src/person-view.tsx
|
|
4731
|
+
function OwnSelect({
|
|
4732
|
+
value,
|
|
4733
|
+
options,
|
|
4734
|
+
name,
|
|
4735
|
+
inherit,
|
|
4736
|
+
label,
|
|
4737
|
+
onChange
|
|
4738
|
+
}) {
|
|
4739
|
+
return /* @__PURE__ */ React.createElement("select", {
|
|
4740
|
+
className: "trm-field",
|
|
4741
|
+
"aria-label": label,
|
|
4742
|
+
value: value ?? "",
|
|
4743
|
+
onChange: (event) => onChange(event.target.value || undefined)
|
|
4744
|
+
}, /* @__PURE__ */ React.createElement("option", {
|
|
4745
|
+
value: ""
|
|
4746
|
+
}, rt("modeDefault")), options.map((option) => /* @__PURE__ */ React.createElement("option", {
|
|
4747
|
+
key: option,
|
|
4748
|
+
value: option
|
|
4749
|
+
}, name(option))));
|
|
4750
|
+
}
|
|
4751
|
+
function PolicyRow({ label, hint, children }) {
|
|
4752
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4753
|
+
className: "trm-reply-row"
|
|
4754
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4755
|
+
className: "trm-grant-text"
|
|
4756
|
+
}, /* @__PURE__ */ React.createElement("span", null, label), /* @__PURE__ */ React.createElement("span", {
|
|
4757
|
+
className: "trm-note"
|
|
4758
|
+
}, hint)), children);
|
|
4759
|
+
}
|
|
4760
|
+
function PersonPolicy({ person, friend, room }) {
|
|
4761
|
+
const { reply, grants } = useDoubles();
|
|
4762
|
+
const own = reply.people[person.id] ?? {};
|
|
4763
|
+
const replyAll = friend ? reply.mode : reply.strangers;
|
|
4764
|
+
const taskAll = friend ? reply.tasks.friends : reply.tasks.strangers;
|
|
4765
|
+
const work = mayLine(grantsOf(grants, person.id, room?.id));
|
|
4766
|
+
const Key = pi.ui.icons.KeyRound ?? icon("Bot");
|
|
4767
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4768
|
+
className: "trm-person-policy"
|
|
4769
|
+
}, /* @__PURE__ */ React.createElement(PolicyRow, {
|
|
4770
|
+
label: rt("replyThem", { name: person.name }),
|
|
4771
|
+
hint: modeHint(own.reply ?? replyAll, reply)
|
|
4772
|
+
}, /* @__PURE__ */ React.createElement(ModeSelect, {
|
|
4773
|
+
value: own.reply,
|
|
4774
|
+
inherit: replyAll,
|
|
4775
|
+
label: rt("replyThem", { name: person.name }),
|
|
4776
|
+
onChange: (mode) => void setReply((policy) => ReplyPolicyUtil.setPerson(policy, person.id, "reply", mode))
|
|
4777
|
+
})), /* @__PURE__ */ React.createElement(PolicyRow, {
|
|
4778
|
+
label: rt("workFor"),
|
|
4779
|
+
hint: work || rt("workNone")
|
|
4780
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4781
|
+
className: "trm-person-work"
|
|
4782
|
+
}, work && /* @__PURE__ */ React.createElement("button", {
|
|
4783
|
+
type: "button",
|
|
4784
|
+
className: "ta-button",
|
|
4785
|
+
onClick: () => void revokeAll(person.id, person.name)
|
|
4786
|
+
}, rt("workStop")), /* @__PURE__ */ React.createElement("button", {
|
|
4787
|
+
type: "button",
|
|
4788
|
+
className: "ta-button",
|
|
4789
|
+
onClick: () => openGrant(person, room)
|
|
4790
|
+
}, /* @__PURE__ */ React.createElement(Key, {
|
|
4791
|
+
size: 14
|
|
4792
|
+
}), rt("workGive")))), /* @__PURE__ */ React.createElement(PolicyRow, {
|
|
4793
|
+
label: rt("tasksFrom"),
|
|
4794
|
+
hint: taskName(own.tasks ?? taskAll)
|
|
4795
|
+
}, /* @__PURE__ */ React.createElement(OwnSelect, {
|
|
4796
|
+
value: own.tasks,
|
|
4797
|
+
options: TASK_MODES,
|
|
4798
|
+
name: taskName,
|
|
4799
|
+
inherit: taskAll,
|
|
4800
|
+
label: rt("tasksFrom"),
|
|
4801
|
+
onChange: (mode) => void setReply((policy) => ReplyPolicyUtil.setPerson(policy, person.id, "tasks", mode))
|
|
4802
|
+
})), friend && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PolicyRow, {
|
|
4803
|
+
label: rt("invitesFrom"),
|
|
4804
|
+
hint: inviteName(own.invites ?? reply.invites)
|
|
4805
|
+
}, /* @__PURE__ */ React.createElement(OwnSelect, {
|
|
4806
|
+
value: own.invites,
|
|
4807
|
+
options: INVITE_MODES,
|
|
4808
|
+
name: inviteName,
|
|
4809
|
+
inherit: reply.invites,
|
|
4810
|
+
label: rt("invitesFrom"),
|
|
4811
|
+
onChange: (mode) => void setReply((policy) => ReplyPolicyUtil.setPerson(policy, person.id, "invites", mode))
|
|
4812
|
+
})), /* @__PURE__ */ React.createElement(PolicyRow, {
|
|
4813
|
+
label: rt("momentsTo"),
|
|
4814
|
+
hint: own.moments === false ? rt("momentsHidden") : rt("momentsShown")
|
|
4815
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
4816
|
+
checked: own.moments !== false,
|
|
4817
|
+
label: rt("momentsTo"),
|
|
4818
|
+
onChange: (on) => void setReply((policy) => ReplyPolicyUtil.setPerson(policy, person.id, "moments", on ? undefined : false))
|
|
4819
|
+
}))));
|
|
4820
|
+
}
|
|
4821
|
+
function PersonDialog({ person, room, close }) {
|
|
4822
|
+
const { friends } = useBook();
|
|
4823
|
+
const friend = friends?.find((each) => each.id === person.id);
|
|
4824
|
+
const isFriend = friend?.status === "friend";
|
|
4825
|
+
const line = friend?.status === "adding" ? t("friendAdding") : friend?.online ? t("online") : undefined;
|
|
4826
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
4827
|
+
title: isFriend ? t("friends") : rt("personTitle"),
|
|
4828
|
+
onClose: close
|
|
4829
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
4830
|
+
className: "trm-dialog"
|
|
4831
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
4832
|
+
className: "trm-join"
|
|
4833
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
4834
|
+
id: person.id,
|
|
4835
|
+
name: person.name,
|
|
4836
|
+
size: 56,
|
|
4837
|
+
online: isFriend ? friend.online : undefined
|
|
4838
|
+
}), /* @__PURE__ */ React.createElement("strong", {
|
|
4839
|
+
className: "trm-join-name"
|
|
4840
|
+
}, friend?.name ?? person.name), line && /* @__PURE__ */ React.createElement("p", {
|
|
4841
|
+
className: "trm-lead"
|
|
4842
|
+
}, line)), isFriend && /* @__PURE__ */ React.createElement("button", {
|
|
4843
|
+
type: "button",
|
|
4844
|
+
className: "ta-button ta-primary trm-friend-message",
|
|
4845
|
+
onClick: () => {
|
|
4846
|
+
close();
|
|
4847
|
+
openDirect(friend);
|
|
4848
|
+
}
|
|
4849
|
+
}, rt("message")), /* @__PURE__ */ React.createElement(PersonPolicy, {
|
|
4850
|
+
person,
|
|
4851
|
+
friend: isFriend,
|
|
4852
|
+
room
|
|
4853
|
+
}), friend && /* @__PURE__ */ React.createElement("div", {
|
|
4854
|
+
className: "trm-actions trm-center"
|
|
4855
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
4856
|
+
type: "button",
|
|
4857
|
+
className: "ta-button ta-danger",
|
|
4858
|
+
onClick: () => void confirmThen(t("removeFriendTitle", { name: friend.name }), t("removeFriendHint"), t("removeFriend"), async () => {
|
|
4859
|
+
await rooms()?.removeFriend(friend.id);
|
|
4860
|
+
close();
|
|
4861
|
+
await book.load();
|
|
4862
|
+
})
|
|
4863
|
+
}, rt("removeFriendLong")))));
|
|
4864
|
+
}
|
|
4865
|
+
function openPerson(person, room) {
|
|
4866
|
+
show(({ close }) => /* @__PURE__ */ React.createElement(PersonDialog, {
|
|
4867
|
+
person,
|
|
4868
|
+
room,
|
|
4869
|
+
close
|
|
4870
|
+
}));
|
|
4871
|
+
}
|
|
4872
|
+
bindPersonOpener(openPerson);
|
|
4873
|
+
function personOf(member) {
|
|
4874
|
+
return member.self || member.guest ? undefined : { id: member.id, name: member.name };
|
|
4875
|
+
}
|
|
4876
|
+
function DirectPolicy({ room }) {
|
|
4877
|
+
const { friends } = useBook();
|
|
4878
|
+
const peer = DirectUtil.peer(room);
|
|
4879
|
+
if (!peer) {
|
|
4880
|
+
return null;
|
|
4881
|
+
}
|
|
4882
|
+
return /* @__PURE__ */ React.createElement(PersonPolicy, {
|
|
4883
|
+
person: { id: peer.id, name: peer.name },
|
|
4884
|
+
friend: !!friends?.some((each) => each.id === peer.id && each.status === "friend"),
|
|
4885
|
+
room: { id: room.id, title: room.title }
|
|
4886
|
+
});
|
|
4887
|
+
}
|
|
4888
|
+
|
|
3302
4889
|
// web-src/friends-view.tsx
|
|
3303
4890
|
function isFriendLink(text) {
|
|
3304
4891
|
return RelayHubUtil.is(text) && RelayFriendsUtil.isKind(RelayHubUtil.parse(text).kind);
|
|
@@ -3356,6 +4943,11 @@ function FriendRow({ friend }) {
|
|
|
3356
4943
|
});
|
|
3357
4944
|
return /* @__PURE__ */ React.createElement("li", {
|
|
3358
4945
|
className: "trm-friend"
|
|
4946
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
4947
|
+
type: "button",
|
|
4948
|
+
className: "trm-friend-open",
|
|
4949
|
+
disabled: friend.status !== "friend",
|
|
4950
|
+
onClick: () => void openDirect(friend)
|
|
3359
4951
|
}, /* @__PURE__ */ React.createElement(Face, {
|
|
3360
4952
|
id: friend.id,
|
|
3361
4953
|
name: friend.name,
|
|
@@ -3367,7 +4959,7 @@ function FriendRow({ friend }) {
|
|
|
3367
4959
|
className: "trm-room-name trm-ellipsis"
|
|
3368
4960
|
}, friend.name), friend.status === "adding" && /* @__PURE__ */ React.createElement("span", {
|
|
3369
4961
|
className: "trm-room-preview trm-ellipsis"
|
|
3370
|
-
}, t("friendAdding"))), /* @__PURE__ */ React.createElement("button", {
|
|
4962
|
+
}, t("friendAdding")))), /* @__PURE__ */ React.createElement("button", {
|
|
3371
4963
|
type: "button",
|
|
3372
4964
|
className: "trm-icon trm-danger",
|
|
3373
4965
|
title: t("removeFriend"),
|
|
@@ -3508,52 +5100,11 @@ function openFriendLink(text) {
|
|
|
3508
5100
|
}));
|
|
3509
5101
|
return true;
|
|
3510
5102
|
}
|
|
3511
|
-
function FriendDialog({ id, close }) {
|
|
3512
|
-
const { friends } = useBook();
|
|
3513
|
-
const friend = friends?.find((each) => each.id === id);
|
|
3514
|
-
React.useEffect(() => {
|
|
3515
|
-
if (friends && !friend) {
|
|
3516
|
-
close();
|
|
3517
|
-
}
|
|
3518
|
-
}, [friends, friend, close]);
|
|
3519
|
-
if (!friend) {
|
|
3520
|
-
return null;
|
|
3521
|
-
}
|
|
3522
|
-
const line = friend.status === "adding" ? t("friendAdding") : friend.online ? t("online") : undefined;
|
|
3523
|
-
const remove = () => void confirmThen(t("removeFriendTitle", { name: friend.name }), t("removeFriendHint"), t("removeFriend"), async () => {
|
|
3524
|
-
await rooms()?.removeFriend(friend.id);
|
|
3525
|
-
close();
|
|
3526
|
-
await book.load();
|
|
3527
|
-
});
|
|
3528
|
-
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
3529
|
-
title: t("friends"),
|
|
3530
|
-
onClose: close
|
|
3531
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
3532
|
-
className: "trm-dialog"
|
|
3533
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
3534
|
-
className: "trm-join"
|
|
3535
|
-
}, /* @__PURE__ */ React.createElement(Face, {
|
|
3536
|
-
id: friend.id,
|
|
3537
|
-
name: friend.name,
|
|
3538
|
-
size: 56,
|
|
3539
|
-
online: friend.status === "friend" ? friend.online : undefined
|
|
3540
|
-
}), /* @__PURE__ */ React.createElement("strong", {
|
|
3541
|
-
className: "trm-join-name"
|
|
3542
|
-
}, friend.name), line && /* @__PURE__ */ React.createElement("p", {
|
|
3543
|
-
className: "trm-lead"
|
|
3544
|
-
}, line)), /* @__PURE__ */ React.createElement("div", {
|
|
3545
|
-
className: "trm-actions trm-center"
|
|
3546
|
-
}, /* @__PURE__ */ React.createElement("button", {
|
|
3547
|
-
type: "button",
|
|
3548
|
-
className: "ta-button ta-danger",
|
|
3549
|
-
onClick: remove
|
|
3550
|
-
}, t("removeFriend")))));
|
|
3551
|
-
}
|
|
3552
5103
|
function openFriend(id) {
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
}
|
|
5104
|
+
const friend = book.get().friends?.find((each) => each.id === id);
|
|
5105
|
+
if (friend) {
|
|
5106
|
+
openPerson({ id: friend.id, name: friend.name });
|
|
5107
|
+
}
|
|
3557
5108
|
}
|
|
3558
5109
|
function FriendRequestsDialog({ close }) {
|
|
3559
5110
|
const { friendRequests } = useBook();
|
|
@@ -3607,6 +5158,41 @@ async function offerFriend(room, member, name) {
|
|
|
3607
5158
|
}
|
|
3608
5159
|
}
|
|
3609
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
|
+
|
|
3610
5196
|
// web-src/dialogs.tsx
|
|
3611
5197
|
function show(component) {
|
|
3612
5198
|
if (!pi.ui.custom) {
|
|
@@ -3760,7 +5346,7 @@ function InviteDialog({ room, close }) {
|
|
|
3760
5346
|
const [error, setError] = React.useState();
|
|
3761
5347
|
const make = React.useCallback((renew) => {
|
|
3762
5348
|
setError(undefined);
|
|
3763
|
-
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)));
|
|
3764
5350
|
}, [room.id]);
|
|
3765
5351
|
React.useEffect(() => make(false), [make]);
|
|
3766
5352
|
return /* @__PURE__ */ React.createElement(ShareSheetCompat, {
|
|
@@ -4081,6 +5667,123 @@ function openFriendPicker(room) {
|
|
|
4081
5667
|
close
|
|
4082
5668
|
}));
|
|
4083
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
|
+
}
|
|
4084
5787
|
function InviteDialog2({ invite, close }) {
|
|
4085
5788
|
const [busy, setBusy] = React.useState(false);
|
|
4086
5789
|
const [error, setError] = React.useState();
|
|
@@ -4135,55 +5838,390 @@ function InviteDialog2({ invite, close }) {
|
|
|
4135
5838
|
className: "ta-spinner"
|
|
4136
5839
|
}) : t("groupInviteJoin")))));
|
|
4137
5840
|
}
|
|
4138
|
-
function GroupInviteRow({ invite }) {
|
|
5841
|
+
function GroupInviteRow({ invite }) {
|
|
5842
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
5843
|
+
className: "trm-row"
|
|
5844
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
5845
|
+
id: invite.by.id,
|
|
5846
|
+
name: invite.by.name
|
|
5847
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
5848
|
+
className: "trm-row-text"
|
|
5849
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5850
|
+
className: "trm-row-title"
|
|
5851
|
+
}, invite.title), /* @__PURE__ */ React.createElement("span", {
|
|
5852
|
+
className: "trm-row-line"
|
|
5853
|
+
}, t("groupInviteLine", { name: invite.by.name }))), /* @__PURE__ */ React.createElement("div", {
|
|
5854
|
+
className: "trm-answers"
|
|
5855
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
5856
|
+
type: "button",
|
|
5857
|
+
className: "ta-button ta-primary",
|
|
5858
|
+
onClick: () => openGroupInvite(invite)
|
|
5859
|
+
}, t("groupInviteJoin"))));
|
|
5860
|
+
}
|
|
5861
|
+
function openGroupInvite(invite) {
|
|
5862
|
+
show(({ close }) => /* @__PURE__ */ React.createElement(InviteDialog2, {
|
|
5863
|
+
invite,
|
|
5864
|
+
close
|
|
5865
|
+
}));
|
|
5866
|
+
}
|
|
5867
|
+
|
|
5868
|
+
// web-src/room-rules.ts
|
|
5869
|
+
var ROOM_RULES = ["agents", "doubles", "tasks"];
|
|
5870
|
+
var RoomRulesUtil;
|
|
5871
|
+
((RoomRulesUtil) => {
|
|
5872
|
+
function allows(room, rule) {
|
|
5873
|
+
return room?.rules?.[rule] !== false;
|
|
5874
|
+
}
|
|
5875
|
+
RoomRulesUtil.allows = allows;
|
|
5876
|
+
function approves(room) {
|
|
5877
|
+
return room?.rules?.approve === true;
|
|
5878
|
+
}
|
|
5879
|
+
RoomRulesUtil.approves = approves;
|
|
5880
|
+
function refused(rule, language) {
|
|
5881
|
+
return TaLanguageUtil.pick(language, {
|
|
5882
|
+
agents: {
|
|
5883
|
+
"zh-CN": "群主没有允许在这个群里用智能体",
|
|
5884
|
+
"zh-TW": "群主沒有允許在這個群裡用智慧體",
|
|
5885
|
+
"en-US": "the owner allows no agents in this group chat",
|
|
5886
|
+
"ja-JP": "このグループチャットではグループ主がエージェントを許可していません"
|
|
5887
|
+
},
|
|
5888
|
+
doubles: {
|
|
5889
|
+
"zh-CN": "群主没有允许分身在这个群里代答",
|
|
5890
|
+
"zh-TW": "群主沒有允許分身在這個群裡代答",
|
|
5891
|
+
"en-US": "the owner allows no double to answer in this group chat",
|
|
5892
|
+
"ja-JP": "このグループチャットではグループ主が分身の代理応答を許可していません"
|
|
5893
|
+
},
|
|
5894
|
+
tasks: {
|
|
5895
|
+
"zh-CN": "群主没有允许在这个群里给分身派任务",
|
|
5896
|
+
"zh-TW": "群主沒有允許在這個群裡給分身派任務",
|
|
5897
|
+
"en-US": "the owner allows no tasks for doubles in this group chat",
|
|
5898
|
+
"ja-JP": "このグループチャットではグループ主が分身へのタスクを許可していません"
|
|
5899
|
+
}
|
|
5900
|
+
}[rule]);
|
|
5901
|
+
}
|
|
5902
|
+
RoomRulesUtil.refused = refused;
|
|
5903
|
+
})(RoomRulesUtil ||= {});
|
|
5904
|
+
|
|
5905
|
+
// web-src/rules-i18n.ts
|
|
5906
|
+
var EN4 = {
|
|
5907
|
+
rulesManage: "Manage the group chat",
|
|
5908
|
+
rulesView: "Rules of the group chat",
|
|
5909
|
+
rulesSome: "{n} set",
|
|
5910
|
+
rulesNone: "None",
|
|
5911
|
+
adminTag: "Admin",
|
|
5912
|
+
admins: "Admins",
|
|
5913
|
+
adminsHint: "They let people in, invite and take members out, as you do, also while you are away. At most {n}.",
|
|
5914
|
+
adminsNone: "Members in the group chat with Ta can be made admins.",
|
|
5915
|
+
adminOf: "Admin",
|
|
5916
|
+
adminFull: "At most {n} admins.",
|
|
5917
|
+
rules: "Rules",
|
|
5918
|
+
rulesLead: "For everyone in the group chat; each one’s Ta keeps them. They only forbid: each person may still be stricter for themselves.",
|
|
5919
|
+
rulesOthers: "Set by the owner; everyone’s Ta keeps them.",
|
|
5920
|
+
approve: "Invited friends ask too",
|
|
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.",
|
|
5932
|
+
agents: "Agents may be invited",
|
|
5933
|
+
agentsHint: "Members may bring their agents in to help",
|
|
5934
|
+
doubles: "Doubles may answer for people",
|
|
5935
|
+
doublesHint: "When someone is @ed, their double may answer as they set it; off, they are only told",
|
|
5936
|
+
tasks: "Doubles may be handed tasks",
|
|
5937
|
+
tasksHint: "Members may hand each other’s doubles work to do"
|
|
5938
|
+
};
|
|
5939
|
+
var ZH4 = {
|
|
5940
|
+
rulesManage: "群管理",
|
|
5941
|
+
rulesView: "群规",
|
|
5942
|
+
rulesSome: "{n} 项",
|
|
5943
|
+
rulesNone: "无",
|
|
5944
|
+
adminTag: "管理员",
|
|
5945
|
+
admins: "管理员",
|
|
5946
|
+
adminsHint: "可以放人进群、邀请和移出成员,和你一样;你不在时也行。最多 {n} 位。",
|
|
5947
|
+
adminsNone: "群里装了 Ta 的成员可以设为管理员。",
|
|
5948
|
+
adminOf: "管理员",
|
|
5949
|
+
adminFull: "最多 {n} 位管理员。",
|
|
5950
|
+
rules: "群规",
|
|
5951
|
+
rulesLead: "对群里所有人有效,由每个人的 Ta 执行。群规只能禁止,每个人还可以对自己更严。",
|
|
5952
|
+
rulesOthers: "由群主设置,每个人的 Ta 都按这个执行。",
|
|
5953
|
+
approve: "受邀的好友也要同意",
|
|
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: "会生成新链接,之前的链接失效。",
|
|
5965
|
+
agents: "允许邀请智能体",
|
|
5966
|
+
agentsHint: "成员可以请自己的智能体进群帮忙",
|
|
5967
|
+
doubles: "允许分身代答",
|
|
5968
|
+
doublesHint: "有人被 @ 时,他的分身可以按他的设置代答;关掉后只提醒本人",
|
|
5969
|
+
tasks: "允许给分身派任务",
|
|
5970
|
+
tasksHint: "成员之间可以把事情交给对方的分身去做"
|
|
5971
|
+
};
|
|
5972
|
+
var ZH_TW4 = {
|
|
5973
|
+
rulesManage: "群管理",
|
|
5974
|
+
rulesView: "群規",
|
|
5975
|
+
rulesSome: "{n} 項",
|
|
5976
|
+
rulesNone: "無",
|
|
5977
|
+
adminTag: "管理員",
|
|
5978
|
+
admins: "管理員",
|
|
5979
|
+
adminsHint: "可以放人進群、邀請和移出成員,和你一樣;你不在時也行。最多 {n} 位。",
|
|
5980
|
+
adminsNone: "群裡裝了 Ta 的成員可以設為管理員。",
|
|
5981
|
+
adminOf: "管理員",
|
|
5982
|
+
adminFull: "最多 {n} 位管理員。",
|
|
5983
|
+
rules: "群規",
|
|
5984
|
+
rulesLead: "對群裡所有人有效,由每個人的 Ta 執行。群規只能禁止,每個人還可以對自己更嚴。",
|
|
5985
|
+
rulesOthers: "由群主設定,每個人的 Ta 都按這個執行。",
|
|
5986
|
+
approve: "受邀的好友也要同意",
|
|
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: "會產生新連結,之前的連結失效。",
|
|
5998
|
+
agents: "允許邀請智慧體",
|
|
5999
|
+
agentsHint: "成員可以請自己的智慧體進群幫忙",
|
|
6000
|
+
doubles: "允許分身代答",
|
|
6001
|
+
doublesHint: "有人被 @ 時,他的分身可以按他的設定代答;關掉後只提醒本人",
|
|
6002
|
+
tasks: "允許給分身派任務",
|
|
6003
|
+
tasksHint: "成員之間可以把事情交給對方的分身去做"
|
|
6004
|
+
};
|
|
6005
|
+
var JA4 = {
|
|
6006
|
+
rulesManage: "グループ管理",
|
|
6007
|
+
rulesView: "グループのルール",
|
|
6008
|
+
rulesSome: "{n} 件",
|
|
6009
|
+
rulesNone: "なし",
|
|
6010
|
+
adminTag: "管理者",
|
|
6011
|
+
admins: "管理者",
|
|
6012
|
+
adminsHint: "あなたと同じように参加の許可、招待、メンバーの削除ができます。あなたが不在でも可能です。最大 {n} 人。",
|
|
6013
|
+
adminsNone: "Ta を使っているメンバーを管理者にできます。",
|
|
6014
|
+
adminOf: "管理者",
|
|
6015
|
+
adminFull: "管理者は最大 {n} 人です。",
|
|
6016
|
+
rules: "ルール",
|
|
6017
|
+
rulesLead: "グループ全員に適用され、各自の Ta が守ります。ルールは禁止するだけで、各自はさらに厳しくできます。",
|
|
6018
|
+
rulesOthers: "グループ主が設定し、全員の Ta が守ります。",
|
|
6019
|
+
approve: "招待した友だちも承認が必要",
|
|
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: "新しいリンクを作成し、以前のリンクは無効になります。",
|
|
6031
|
+
agents: "エージェントの招待を許可",
|
|
6032
|
+
agentsHint: "メンバーは自分のエージェントを招待して手伝わせることができます",
|
|
6033
|
+
doubles: "分身の代理応答を許可",
|
|
6034
|
+
doublesHint: "誰かが @ されたとき、その人の設定どおりに分身が応答できます。オフにすると本人に通知するだけです",
|
|
6035
|
+
tasks: "分身へのタスクを許可",
|
|
6036
|
+
tasksHint: "メンバー同士で相手の分身に作業を任せられます"
|
|
6037
|
+
};
|
|
6038
|
+
var RULES_WORDS = { "zh-CN": ZH4, "zh-TW": ZH_TW4, "en-US": EN4, "ja-JP": JA4 };
|
|
6039
|
+
function gt(key, values = {}) {
|
|
6040
|
+
return TaLanguageUtil.pick(pi.ui.language, RULES_WORDS)[key].replace(/\{(\w+)\}/g, (whole, name) => (name in values) ? String(values[name]) : whole);
|
|
6041
|
+
}
|
|
6042
|
+
|
|
6043
|
+
// web-src/group-rules-view.tsx
|
|
6044
|
+
var ADMINS_MAX = 8;
|
|
6045
|
+
var GUESTS_PER_HOUR = 30;
|
|
6046
|
+
var OWN_RULES = ["approve", "guests"];
|
|
6047
|
+
var SWITCHES = [
|
|
6048
|
+
{ rule: "approve", label: () => gt("approve"), hint: () => gt("approveHint") },
|
|
6049
|
+
{ rule: "guests", label: () => gt("guests"), hint: () => gt("guestsHint", { n: GUESTS_PER_HOUR }) },
|
|
6050
|
+
...ROOM_RULES.map((rule) => ({ rule, label: () => gt(rule), hint: () => gt(`${rule}Hint`) }))
|
|
6051
|
+
];
|
|
6052
|
+
var isOwn = (rule) => OWN_RULES.includes(rule);
|
|
6053
|
+
function isOn(room, rule) {
|
|
6054
|
+
return isOwn(rule) ? room.rules?.[rule] === true : room.rules?.[rule] !== false;
|
|
6055
|
+
}
|
|
6056
|
+
function countSet(room) {
|
|
6057
|
+
return SWITCHES.filter(({ rule }) => isOn(room, rule) !== !isOwn(rule)).length;
|
|
6058
|
+
}
|
|
6059
|
+
function GroupRulesRow({ room }) {
|
|
6060
|
+
const Chevron = icon("ChevronRight");
|
|
6061
|
+
const set = countSet(room);
|
|
6062
|
+
if (!room.owner && set === 0) {
|
|
6063
|
+
return null;
|
|
6064
|
+
}
|
|
6065
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
6066
|
+
type: "button",
|
|
6067
|
+
className: "trm-setting",
|
|
6068
|
+
onClick: () => book.set({ sub: { room: room.id, app: "rules" } })
|
|
6069
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
6070
|
+
className: "trm-setting-label"
|
|
6071
|
+
}, room.owner ? gt("rulesManage") : gt("rulesView")), /* @__PURE__ */ React.createElement("span", {
|
|
6072
|
+
className: "trm-setting-value trm-ellipsis"
|
|
6073
|
+
}, set ? gt("rulesSome", { n: set }) : gt("rulesNone")), /* @__PURE__ */ React.createElement(Chevron, {
|
|
6074
|
+
size: 15
|
|
6075
|
+
}));
|
|
6076
|
+
}
|
|
6077
|
+
function configure(room, options) {
|
|
6078
|
+
const call = rooms()?.configureRoom(room.id, options);
|
|
6079
|
+
return (call ?? Promise.resolve()).catch((error) => {
|
|
6080
|
+
pi.ui.notify(message(error), "error");
|
|
6081
|
+
throw error;
|
|
6082
|
+
});
|
|
6083
|
+
}
|
|
6084
|
+
function AdminRow({ room, member, admins }) {
|
|
6085
|
+
const on = !!member.admin;
|
|
4139
6086
|
return /* @__PURE__ */ React.createElement("li", {
|
|
4140
|
-
className: "trm-
|
|
6087
|
+
className: "trm-member"
|
|
4141
6088
|
}, /* @__PURE__ */ React.createElement(Face, {
|
|
4142
|
-
id:
|
|
4143
|
-
name:
|
|
4144
|
-
|
|
4145
|
-
|
|
6089
|
+
id: member.id,
|
|
6090
|
+
name: member.name,
|
|
6091
|
+
size: 30,
|
|
6092
|
+
online: member.online
|
|
6093
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
6094
|
+
className: "trm-member-text"
|
|
4146
6095
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
4147
|
-
className: "trm-
|
|
4148
|
-
},
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
className: "ta-button ta-primary",
|
|
4155
|
-
onClick: () => openGroupInvite(invite)
|
|
4156
|
-
}, t("groupInviteJoin"))));
|
|
6096
|
+
className: "trm-member-name trm-ellipsis"
|
|
6097
|
+
}, member.name)), /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
6098
|
+
checked: on,
|
|
6099
|
+
label: `${gt("adminOf")} · ${member.name}`,
|
|
6100
|
+
disabled: !on && admins.length >= ADMINS_MAX,
|
|
6101
|
+
onChange: (next) => configure(room, { admins: next ? [...admins, member.member] : admins.filter((id) => id !== member.member) })
|
|
6102
|
+
}));
|
|
4157
6103
|
}
|
|
4158
|
-
function
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
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
|
|
4162
6148
|
}));
|
|
4163
6149
|
}
|
|
6150
|
+
function GroupRulesView({ room }) {
|
|
6151
|
+
const candidates = room.members.filter((member) => !member.owner && !member.guest && !member.self);
|
|
6152
|
+
const admins = room.members.filter((member) => member.admin).map((member) => member.member);
|
|
6153
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
6154
|
+
className: "trm-rules"
|
|
6155
|
+
}, room.owner && /* @__PURE__ */ React.createElement(Joining, {
|
|
6156
|
+
room
|
|
6157
|
+
}), room.owner && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
6158
|
+
className: "trm-panel-label"
|
|
6159
|
+
}, gt("admins")), /* @__PURE__ */ React.createElement("p", {
|
|
6160
|
+
className: "trm-note trm-panel-note"
|
|
6161
|
+
}, gt("adminsHint", { n: ADMINS_MAX })), candidates.length ? /* @__PURE__ */ React.createElement("ul", {
|
|
6162
|
+
className: "trm-panel-members"
|
|
6163
|
+
}, candidates.map((member) => /* @__PURE__ */ React.createElement(AdminRow, {
|
|
6164
|
+
key: member.member,
|
|
6165
|
+
room,
|
|
6166
|
+
member,
|
|
6167
|
+
admins
|
|
6168
|
+
}))) : /* @__PURE__ */ React.createElement("p", {
|
|
6169
|
+
className: "trm-note trm-panel-note"
|
|
6170
|
+
}, gt("adminsNone")), /* @__PURE__ */ React.createElement("div", {
|
|
6171
|
+
className: "trm-panel-sep"
|
|
6172
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
6173
|
+
className: "trm-panel-label"
|
|
6174
|
+
}, gt("rules")), /* @__PURE__ */ React.createElement("p", {
|
|
6175
|
+
className: "trm-note trm-panel-note"
|
|
6176
|
+
}, room.owner ? gt("rulesLead") : gt("rulesOthers")), SWITCHES.map(({ rule, label, hint }) => /* @__PURE__ */ React.createElement("div", {
|
|
6177
|
+
key: rule,
|
|
6178
|
+
className: "trm-double-switch"
|
|
6179
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
6180
|
+
className: "trm-grant-text"
|
|
6181
|
+
}, /* @__PURE__ */ React.createElement("span", null, label()), /* @__PURE__ */ React.createElement("span", {
|
|
6182
|
+
className: "trm-note"
|
|
6183
|
+
}, hint())), /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
6184
|
+
checked: isOn(room, rule),
|
|
6185
|
+
label: label(),
|
|
6186
|
+
disabled: !room.owner,
|
|
6187
|
+
onChange: (next) => configure(room, { rules: { ...room.rules, [rule]: next } })
|
|
6188
|
+
}))));
|
|
6189
|
+
}
|
|
4164
6190
|
|
|
4165
6191
|
// web-src/members-view.tsx
|
|
4166
6192
|
function MemberRow({ room, member }) {
|
|
4167
6193
|
const Remove = icon("X");
|
|
4168
6194
|
const Key = pi.ui.icons.KeyRound ?? icon("Bot");
|
|
4169
|
-
const may = useMayLine(member);
|
|
6195
|
+
const may = useMayLine(member, room.id);
|
|
4170
6196
|
const { friends } = useBook();
|
|
4171
6197
|
const friend = friends?.find((each) => each.id === member.id);
|
|
4172
6198
|
const Add = icon("UserPlus");
|
|
4173
6199
|
const tags = [
|
|
4174
6200
|
member.self ? t("you") : "",
|
|
4175
6201
|
member.owner ? t("owner") : "",
|
|
6202
|
+
member.admin ? gt("adminTag") : "",
|
|
4176
6203
|
member.guest ? t("guestTag") : "",
|
|
4177
6204
|
friend?.status === "friend" ? t("friendTag") : ""
|
|
4178
6205
|
].filter(Boolean);
|
|
4179
6206
|
return /* @__PURE__ */ React.createElement("li", {
|
|
4180
6207
|
className: "trm-member"
|
|
6208
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
6209
|
+
type: "button",
|
|
6210
|
+
className: "trm-member-open",
|
|
6211
|
+
disabled: !personOf(member),
|
|
6212
|
+
"aria-label": member.name,
|
|
6213
|
+
onClick: () => {
|
|
6214
|
+
const person = personOf(member);
|
|
6215
|
+
if (person) {
|
|
6216
|
+
openPerson(person, { id: room.id, title: room.title });
|
|
6217
|
+
}
|
|
6218
|
+
}
|
|
4181
6219
|
}, /* @__PURE__ */ React.createElement(Face, {
|
|
4182
6220
|
id: member.id,
|
|
4183
6221
|
name: member.name,
|
|
4184
6222
|
size: 34,
|
|
4185
6223
|
online: member.online
|
|
4186
|
-
}), /* @__PURE__ */ React.createElement("span", {
|
|
6224
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
4187
6225
|
className: "trm-member-text"
|
|
4188
6226
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
4189
6227
|
className: "trm-member-name"
|
|
@@ -4207,12 +6245,12 @@ function MemberRow({ room, member }) {
|
|
|
4207
6245
|
})), !member.self && !member.guest && /* @__PURE__ */ React.createElement("button", {
|
|
4208
6246
|
type: "button",
|
|
4209
6247
|
className: `trm-icon trm-member-action${may ? " trm-on-icon" : ""}`,
|
|
4210
|
-
title:
|
|
4211
|
-
"aria-label":
|
|
4212
|
-
onClick: () =>
|
|
6248
|
+
title: rt("personPolicy"),
|
|
6249
|
+
"aria-label": `${rt("personPolicy")} · ${member.name}`,
|
|
6250
|
+
onClick: () => openPerson({ id: member.id, name: member.name }, { id: room.id, title: room.title })
|
|
4213
6251
|
}, /* @__PURE__ */ React.createElement(Key, {
|
|
4214
6252
|
size: 15
|
|
4215
|
-
})), room.owner && !member.self && /* @__PURE__ */ React.createElement("button", {
|
|
6253
|
+
})), (room.owner || room.admin && !member.owner && !member.admin) && !member.self && !DirectUtil.is(room) && /* @__PURE__ */ React.createElement("button", {
|
|
4216
6254
|
type: "button",
|
|
4217
6255
|
className: "trm-icon trm-danger trm-member-action",
|
|
4218
6256
|
title: t("remove"),
|
|
@@ -4277,7 +6315,7 @@ function SubPage({ title, onBack, children }) {
|
|
|
4277
6315
|
}, children));
|
|
4278
6316
|
}
|
|
4279
6317
|
function MembersView() {
|
|
4280
|
-
const { identity } = useBook();
|
|
6318
|
+
const { identity, friends } = useBook();
|
|
4281
6319
|
const shownPage = !!pi.ui.useView?.(ROOMS_VIEW)?.shown;
|
|
4282
6320
|
const opened = useOpened();
|
|
4283
6321
|
const room = shownPage ? opened : undefined;
|
|
@@ -4294,6 +6332,14 @@ function MembersView() {
|
|
|
4294
6332
|
}
|
|
4295
6333
|
const pushed = sub?.room === room.id ? sub.app : undefined;
|
|
4296
6334
|
const back = () => book.set({ sub: undefined });
|
|
6335
|
+
if (pushed === "rules") {
|
|
6336
|
+
return /* @__PURE__ */ React.createElement(SubPage, {
|
|
6337
|
+
title: room.owner ? gt("rulesManage") : gt("rulesView"),
|
|
6338
|
+
onBack: back
|
|
6339
|
+
}, /* @__PURE__ */ React.createElement(GroupRulesView, {
|
|
6340
|
+
room
|
|
6341
|
+
}));
|
|
6342
|
+
}
|
|
4297
6343
|
if (pushed === "doubles") {
|
|
4298
6344
|
return /* @__PURE__ */ React.createElement(SubPage, {
|
|
4299
6345
|
title: dt("log"),
|
|
@@ -4314,22 +6360,27 @@ function MembersView() {
|
|
|
4314
6360
|
const Contact = icon("Contact");
|
|
4315
6361
|
const online = room.members.filter((member) => member.online).length;
|
|
4316
6362
|
const self = room.members.find((member) => member.self)?.member;
|
|
6363
|
+
const direct = DirectUtil.is(room);
|
|
6364
|
+
const peerFriend = direct ? friends?.find((each) => each.id === DirectUtil.peer(room)?.id && each.status === "friend") : undefined;
|
|
4317
6365
|
return /* @__PURE__ */ React.createElement("div", {
|
|
4318
6366
|
className: "trm-panel"
|
|
4319
6367
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
4320
6368
|
className: "trm-panel-scroll"
|
|
4321
6369
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
4322
6370
|
className: "trm-panel-top"
|
|
4323
|
-
}, /* @__PURE__ */ React.createElement(
|
|
6371
|
+
}, direct ? /* @__PURE__ */ React.createElement(DirectFace, {
|
|
6372
|
+
room,
|
|
6373
|
+
size: 44
|
|
6374
|
+
}) : /* @__PURE__ */ React.createElement(RoomFace, {
|
|
4324
6375
|
room,
|
|
4325
6376
|
size: 44
|
|
4326
6377
|
}), /* @__PURE__ */ React.createElement("span", {
|
|
4327
6378
|
className: "trm-panel-title"
|
|
4328
6379
|
}, /* @__PURE__ */ React.createElement("strong", {
|
|
4329
6380
|
className: "trm-ellipsis"
|
|
4330
|
-
}, room.title), /* @__PURE__ */ React.createElement("span", {
|
|
6381
|
+
}, direct ? directPeer(room, friends).name : room.title), /* @__PURE__ */ React.createElement("span", {
|
|
4331
6382
|
className: "trm-ellipsis"
|
|
4332
|
-
}, room.owner ? t("ownRoom") : t("roomOf", { name: room.ownerName })))), apps.length > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
6383
|
+
}, direct ? rt("directEmpty", { name: directPeer(room, friends).name }) : room.owner ? t("ownRoom") : t("roomOf", { name: room.ownerName })))), apps.length > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
4333
6384
|
className: "trm-panel-label"
|
|
4334
6385
|
}, t("apps")), /* @__PURE__ */ React.createElement(AppTiles, {
|
|
4335
6386
|
room,
|
|
@@ -4338,7 +6389,21 @@ function MembersView() {
|
|
|
4338
6389
|
className: "trm-panel-label"
|
|
4339
6390
|
}, t("membersCount", { n: room.members.length, online })), /* @__PURE__ */ React.createElement("ul", {
|
|
4340
6391
|
className: "trm-panel-members"
|
|
4341
|
-
},
|
|
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", {
|
|
4342
6407
|
type: "button",
|
|
4343
6408
|
className: "trm-member trm-member-add",
|
|
4344
6409
|
onClick: () => openFriendPicker(room)
|
|
@@ -4352,7 +6417,7 @@ function MembersView() {
|
|
|
4352
6417
|
className: "trm-member-name"
|
|
4353
6418
|
}, t("inviteFriends")), /* @__PURE__ */ React.createElement("span", {
|
|
4354
6419
|
className: "trm-member-detail"
|
|
4355
|
-
}, t("inviteFriendsLine"))))), room.owner && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
6420
|
+
}, t("inviteFriendsLine"))))), (room.owner || room.admin) && !direct && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
4356
6421
|
type: "button",
|
|
4357
6422
|
className: "trm-member trm-member-add",
|
|
4358
6423
|
onClick: () => openInvite(room)
|
|
@@ -4374,7 +6439,9 @@ function MembersView() {
|
|
|
4374
6439
|
className: "trm-panel-label"
|
|
4375
6440
|
}, agents.length ? `${dt("agentsTitle")} · ${agents.length}` : dt("agentsTitle")), /* @__PURE__ */ React.createElement("ul", {
|
|
4376
6441
|
className: "trm-panel-members"
|
|
4377
|
-
},
|
|
6442
|
+
}, !RoomRulesUtil.allows(room, "agents") && /* @__PURE__ */ React.createElement("li", {
|
|
6443
|
+
className: "trm-note trm-panel-note"
|
|
6444
|
+
}, RoomRulesUtil.refused("agents", pi.ui.language)), RoomRulesUtil.allows(room, "agents") && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
4378
6445
|
type: "button",
|
|
4379
6446
|
className: "trm-member trm-member-add",
|
|
4380
6447
|
onClick: () => openAgentPicker(room)
|
|
@@ -4397,24 +6464,32 @@ function MembersView() {
|
|
|
4397
6464
|
agent
|
|
4398
6465
|
}))), /* @__PURE__ */ React.createElement("div", {
|
|
4399
6466
|
className: "trm-panel-sep"
|
|
4400
|
-
}), /* @__PURE__ */ React.createElement(
|
|
6467
|
+
}), !direct && /* @__PURE__ */ React.createElement(GroupRulesRow, {
|
|
6468
|
+
room
|
|
6469
|
+
}), direct ? /* @__PURE__ */ React.createElement(DirectPolicy, {
|
|
6470
|
+
room
|
|
6471
|
+
}) : /* @__PURE__ */ React.createElement(ReplyHere, {
|
|
4401
6472
|
room
|
|
4402
6473
|
}), /* @__PURE__ */ React.createElement(SettingRow, {
|
|
4403
6474
|
label: dt("log"),
|
|
4404
6475
|
onClick: () => book.set({ sub: { room: room.id, app: "doubles" } })
|
|
4405
|
-
}), /* @__PURE__ */ React.createElement("div", {
|
|
6476
|
+
}), !direct && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
4406
6477
|
className: "trm-panel-sep"
|
|
4407
6478
|
}), /* @__PURE__ */ React.createElement(SettingRow, {
|
|
4408
6479
|
label: t("me"),
|
|
4409
6480
|
value: identity?.name,
|
|
4410
6481
|
onClick: () => void rename()
|
|
4411
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
6482
|
+
}))), /* @__PURE__ */ React.createElement("div", {
|
|
4412
6483
|
className: "trm-panel-foot"
|
|
4413
6484
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
4414
6485
|
type: "button",
|
|
4415
6486
|
className: "trm-link trm-danger",
|
|
4416
6487
|
onClick: () => void leaveRoom(room).then((left2) => left2 && book.set({ opened: undefined }))
|
|
4417
|
-
}, room.owner ? t("close") : t("leave"))
|
|
6488
|
+
}, direct ? rt("directDelete") : room.owner ? t("close") : t("leave")), peerFriend && /* @__PURE__ */ React.createElement("button", {
|
|
6489
|
+
type: "button",
|
|
6490
|
+
className: "trm-link trm-danger",
|
|
6491
|
+
onClick: () => void confirmThen(t("removeFriendTitle", { name: peerFriend.name }), t("removeFriendHint"), t("removeFriend"), async () => rooms()?.removeFriend(peerFriend.id))
|
|
6492
|
+
}, rt("removeFriendLong"))));
|
|
4418
6493
|
}
|
|
4419
6494
|
|
|
4420
6495
|
// web-src/friend-shares.tsx
|
|
@@ -4509,10 +6584,14 @@ function plain(text) {
|
|
|
4509
6584
|
return text.replace(/```[\s\S]*?(```|$)/g, " ").replace(/[*_~`>#]+/g, "").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\s+/g, " ").trim();
|
|
4510
6585
|
}
|
|
4511
6586
|
function roomPreview(room, last) {
|
|
6587
|
+
const direct = DirectUtil.is(room) && room.status === "member";
|
|
4512
6588
|
if (!last) {
|
|
4513
|
-
return statusLine(room);
|
|
6589
|
+
return direct && !DirectUtil.peer(room) ? rt("directWaiting", { name: directPeer(room, book.get().friends).name }) : direct ? "" : statusLine(room);
|
|
4514
6590
|
}
|
|
4515
6591
|
const self = room.members.find((each) => each.self)?.member;
|
|
6592
|
+
if (direct && !last.agent && !last.double) {
|
|
6593
|
+
return plain(last.text);
|
|
6594
|
+
}
|
|
4516
6595
|
const person = room.members.find((each) => each.member === last.from)?.name ?? last.name;
|
|
4517
6596
|
const name = last.agent?.name ?? (!last.double ? person : last.from === self ? dt("myDouble") : dt("doubleOf", { name: person }));
|
|
4518
6597
|
return last.from === self && !last.agent && !last.double ? plain(last.text) : t("said", { name, text: plain(last.text) });
|
|
@@ -4562,7 +6641,11 @@ function RoomRow({ room, active, seen, openMenu }) {
|
|
|
4562
6641
|
"aria-current": active || undefined,
|
|
4563
6642
|
onClick: (event) => member ? openRoom(room.id) : openMenu(event, menu),
|
|
4564
6643
|
onContextMenu: (event) => openMenu(event, menu)
|
|
4565
|
-
}, /* @__PURE__ */ React.createElement(
|
|
6644
|
+
}, DirectUtil.is(room) ? /* @__PURE__ */ React.createElement(DirectFace, {
|
|
6645
|
+
room,
|
|
6646
|
+
size: 40,
|
|
6647
|
+
unread
|
|
6648
|
+
}) : /* @__PURE__ */ React.createElement(RoomFace, {
|
|
4566
6649
|
room,
|
|
4567
6650
|
unread
|
|
4568
6651
|
}), /* @__PURE__ */ React.createElement("span", {
|
|
@@ -4571,7 +6654,7 @@ function RoomRow({ room, active, seen, openMenu }) {
|
|
|
4571
6654
|
className: "trm-room-line"
|
|
4572
6655
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
4573
6656
|
className: "trm-room-name trm-ellipsis"
|
|
4574
|
-
}, room.title), /* @__PURE__ */ React.createElement("span", {
|
|
6657
|
+
}, DirectUtil.is(room) ? directPeer(room, book.get().friends).name : room.title), /* @__PURE__ */ React.createElement("span", {
|
|
4575
6658
|
className: "trm-room-time"
|
|
4576
6659
|
}, when(lastAt(room)))), /* @__PURE__ */ React.createElement("span", {
|
|
4577
6660
|
className: `trm-room-preview trm-ellipsis${member ? "" : " trm-quiet"}`
|
|
@@ -4579,9 +6662,15 @@ function RoomRow({ room, active, seen, openMenu }) {
|
|
|
4579
6662
|
}
|
|
4580
6663
|
function RoomList({ openMenu }) {
|
|
4581
6664
|
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
4582
|
-
const { identity, rooms: list, requests, groupInvites, opened, seen } = useBook();
|
|
6665
|
+
const { identity, rooms: list, requests, groupInvites: invites, opened, seen } = useBook();
|
|
6666
|
+
const groupInvites = invites.filter((invite) => !DirectUtil.is(invite));
|
|
4583
6667
|
const { asks } = useDoubles();
|
|
4584
|
-
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);
|
|
4585
6674
|
return /* @__PURE__ */ React.createElement("div", {
|
|
4586
6675
|
className: "trm-list"
|
|
4587
6676
|
}, asks.length > 0 && /* @__PURE__ */ React.createElement("section", {
|
|
@@ -4630,7 +6719,7 @@ function RoomList({ openMenu }) {
|
|
|
4630
6719
|
function addMenu() {
|
|
4631
6720
|
return [
|
|
4632
6721
|
[
|
|
4633
|
-
{ 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() },
|
|
4634
6723
|
{ key: "link", label: t("joinByLink"), icon: icon("Link"), run: () => void pasteLink() },
|
|
4635
6724
|
...pi.ui.scanCode ? [{ key: "scan", label: t("scan"), icon: icon("ScanLine"), run: () => void scanLink() }] : []
|
|
4636
6725
|
],
|
|
@@ -4781,7 +6870,10 @@ var HOME_KEY = "home.rooms";
|
|
|
4781
6870
|
function homeFace(id) {
|
|
4782
6871
|
return function HomeFace({ size }) {
|
|
4783
6872
|
const room = React.useSyncExternalStore((listener) => book.subscribe(listener), () => book.get().rooms?.find((each) => each.id === id));
|
|
4784
|
-
return room ? /* @__PURE__ */ React.createElement(
|
|
6873
|
+
return room ? DirectUtil.is(room) ? /* @__PURE__ */ React.createElement(DirectFace, {
|
|
6874
|
+
room,
|
|
6875
|
+
size
|
|
6876
|
+
}) : /* @__PURE__ */ React.createElement(RoomFace, {
|
|
4785
6877
|
room,
|
|
4786
6878
|
size
|
|
4787
6879
|
}) : null;
|
|
@@ -4806,6 +6898,7 @@ class RoomsHome {
|
|
|
4806
6898
|
};
|
|
4807
6899
|
start() {
|
|
4808
6900
|
const stopBook = book.subscribe(() => this.refresh());
|
|
6901
|
+
const stopDirects = directs.subscribe(() => this.refresh());
|
|
4809
6902
|
const stopShares = this.partners ? FriendShares.subscribe(() => this.refresh()) : () => {
|
|
4810
6903
|
return;
|
|
4811
6904
|
};
|
|
@@ -4817,6 +6910,7 @@ class RoomsHome {
|
|
|
4817
6910
|
this.refresh();
|
|
4818
6911
|
return () => {
|
|
4819
6912
|
stopBook();
|
|
6913
|
+
stopDirects();
|
|
4820
6914
|
stopShares();
|
|
4821
6915
|
stopSharesLoad();
|
|
4822
6916
|
stopStorage();
|
|
@@ -4835,9 +6929,12 @@ class RoomsHome {
|
|
|
4835
6929
|
});
|
|
4836
6930
|
}
|
|
4837
6931
|
refresh() {
|
|
4838
|
-
const { rooms: rooms2 = [], seen, friends, friendRequests, requests
|
|
6932
|
+
const { rooms: rooms2 = [], seen, friends, friendRequests, requests } = book.get();
|
|
6933
|
+
const groupInvites = book.get().groupInvites.filter((invite) => !DirectUtil.is(invite));
|
|
4839
6934
|
const sent = this.partners ? FriendShares.get() : [];
|
|
4840
|
-
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)) : [];
|
|
4841
6938
|
this.follow(joined);
|
|
4842
6939
|
const rows = joined.map((room) => ({ room, lines: book.chat(room.id)?.lines ?? [] })).sort((a, b) => lastAt(b.room) - lastAt(a.room));
|
|
4843
6940
|
const signature = [
|
|
@@ -4848,7 +6945,14 @@ class RoomsHome {
|
|
|
4848
6945
|
...groupInvites.map((invite) => invite.room),
|
|
4849
6946
|
...sent.map((share) => `${share.id}/${share.seen ? 1 : 0}`)
|
|
4850
6947
|
].join(",") : "",
|
|
4851
|
-
...rows.map(({ room, lines }) => [
|
|
6948
|
+
...rows.map(({ room, lines }) => [
|
|
6949
|
+
room.id,
|
|
6950
|
+
DirectUtil.is(room) ? directPeer(room, friends).name : room.title,
|
|
6951
|
+
lines.at(-1)?.id ?? "",
|
|
6952
|
+
unseen(room, lines, seen) ? 1 : 0,
|
|
6953
|
+
room.connected ? 1 : 0,
|
|
6954
|
+
room.members.length
|
|
6955
|
+
].join(":"))
|
|
4852
6956
|
].join("|");
|
|
4853
6957
|
if (signature === this.signature) {
|
|
4854
6958
|
return;
|
|
@@ -4872,11 +6976,12 @@ class RoomsHome {
|
|
|
4872
6976
|
face = homeFace(room.id);
|
|
4873
6977
|
this.faces.set(room.id, face);
|
|
4874
6978
|
}
|
|
6979
|
+
const direct = DirectUtil.is(room);
|
|
4875
6980
|
return {
|
|
4876
6981
|
id: room.id,
|
|
4877
|
-
title: room.title,
|
|
6982
|
+
title: direct ? directPeer(room, book.get().friends).name : room.title,
|
|
4878
6983
|
detail: roomPreview(room, lines.at(-1)),
|
|
4879
|
-
icon: icon("Users"),
|
|
6984
|
+
icon: icon(direct ? "MessageCircle" : "Users"),
|
|
4880
6985
|
face,
|
|
4881
6986
|
section: t("roomsTitle"),
|
|
4882
6987
|
...this.partners ? { place: "groups" } : {},
|
|
@@ -4917,7 +7022,7 @@ class RoomsHome {
|
|
|
4917
7022
|
}),
|
|
4918
7023
|
section: t("friends"),
|
|
4919
7024
|
place: "partners",
|
|
4920
|
-
open: () => openFriend(friend.id)
|
|
7025
|
+
open: () => friend.status === "friend" ? void openDirect(friend) : openFriend(friend.id)
|
|
4921
7026
|
};
|
|
4922
7027
|
}
|
|
4923
7028
|
asking(request) {
|
|
@@ -5034,6 +7139,233 @@ function roomsSettings() {
|
|
|
5034
7139
|
};
|
|
5035
7140
|
}
|
|
5036
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
|
+
|
|
5037
7369
|
// web-src/style.ts
|
|
5038
7370
|
var STYLE = `
|
|
5039
7371
|
.trm-ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
@@ -5184,7 +7516,7 @@ button.trm-member { cursor: pointer; }
|
|
|
5184
7516
|
.trm-setting > svg { flex: none; color: var(--ta-muted); }
|
|
5185
7517
|
.trm-setting-label { flex: 1; min-width: 0; }
|
|
5186
7518
|
.trm-setting-value { flex: none; max-width: 55%; text-align: right; color: var(--ta-muted); }
|
|
5187
|
-
.trm-panel-foot { display: flex; justify-content: center; flex: none; padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--ta-border-muted); }
|
|
7519
|
+
.trm-panel-foot { display: flex; flex-direction: column; align-items: stretch; gap: 2px; justify-content: center; flex: none; padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--ta-border-muted); }
|
|
5188
7520
|
.trm-panel-foot .trm-link { width: 100%; min-height: 36px; border-radius: 10px; font-weight: 500; }
|
|
5189
7521
|
/* Dialogs */
|
|
5190
7522
|
.trm-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 10px; }
|
|
@@ -5248,9 +7580,49 @@ button.trm-member { cursor: pointer; }
|
|
|
5248
7580
|
.trm-try-alone { margin-top: 12px; }
|
|
5249
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)); }
|
|
5250
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; }
|
|
5251
7588
|
.trm-agent-pick .trm-member:disabled .trm-member-detail { color: var(--ta-green); }
|
|
5252
7589
|
.trm-member-may { color: var(--ta-secondary); }
|
|
5253
7590
|
.trm-member-action.trm-on-icon { opacity: 1; color: var(--ta-green); }
|
|
7591
|
+
.trm-field { height: 32px; max-width: 100%; padding: 0 8px; border: 1px solid var(--ta-border-field); border-radius: 8px; background: transparent; color: var(--ta-text); font: inherit; font-size: calc(13px * var(--ta-font-scale)); }
|
|
7592
|
+
.trm-field-time { width: 96px; }
|
|
7593
|
+
.trm-reply-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; }
|
|
7594
|
+
.trm-reply-row .trm-field { flex: none; max-width: 52%; }
|
|
7595
|
+
.trm-dialog .trm-reply-row { padding: 8px 0; }
|
|
7596
|
+
.trm-friend-message { align-self: stretch; margin: 4px 0; }
|
|
7597
|
+
.trm-person-policy { display: flex; flex-direction: column; }
|
|
7598
|
+
.trm-person-work { display: flex; gap: 6px; flex: none; }
|
|
7599
|
+
.trm-person-work .ta-button { display: inline-flex; align-items: center; gap: 4px; }
|
|
7600
|
+
.trm-member-open { flex: none; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; }
|
|
7601
|
+
.trm-member-open:disabled { cursor: default; }
|
|
7602
|
+
.trm-friend-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
7603
|
+
.trm-friend-open:disabled { cursor: default; }
|
|
7604
|
+
.trm-quiet-hours { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
|
|
7605
|
+
.trm-reply-own:only-child, .trm-quiet-hours + * { align-self: stretch; }
|
|
7606
|
+
.trm-quiet-line { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; color: var(--ta-muted); font-size: calc(13px * var(--ta-font-scale)); }
|
|
7607
|
+
.trm-reply-own { align-self: stretch; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
7608
|
+
.trm-reply-own-row { display: flex; align-items: center; gap: 8px; min-height: 36px; }
|
|
7609
|
+
.trm-reply-own-name { flex: none; max-width: 40%; }
|
|
7610
|
+
.trm-reply-own-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
|
7611
|
+
.trm-reply-own-open:disabled { cursor: default; }
|
|
7612
|
+
.trm-grants { align-self: stretch; width: 100%; max-width: 100%; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
7613
|
+
.trm-grants .trm-rows, .trm-grants .trm-row { min-width: 0; max-width: 100%; }
|
|
7614
|
+
.trm-grants .trm-row { padding: 6px 0; }
|
|
7615
|
+
.trm-grants .trm-row-line { display: block; }
|
|
7616
|
+
.trm-grants .trm-panel-note { margin: 4px 0 0; align-self: flex-start; }
|
|
7617
|
+
.trm-drafts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
|
|
7618
|
+
.trm-draft { border: 1px dashed var(--ta-border-field); border-radius: 12px; padding: 10px 12px; background: var(--ta-bg-elevated, transparent); display: flex; flex-direction: column; gap: 6px; }
|
|
7619
|
+
.trm-draft-head { display: flex; align-items: center; gap: 6px; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
7620
|
+
.trm-draft-head > svg { flex: none; }
|
|
7621
|
+
.trm-draft-asked { color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
7622
|
+
.trm-draft-text { font-size: calc(14px * var(--ta-font-scale)); }
|
|
7623
|
+
.trm-draft-text p { margin: 0; }
|
|
7624
|
+
.trm-draft-edit { width: 100%; box-sizing: border-box; resize: vertical; padding: 8px; border: 1px solid var(--ta-border-field); border-radius: 8px; background: transparent; color: var(--ta-text); font: inherit; }
|
|
7625
|
+
.trm-draft-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
5254
7626
|
.trm-double-switch, .trm-grant-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; }
|
|
5255
7627
|
.trm-grant-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
|
|
5256
7628
|
.trm-grant-who { display: flex; align-items: center; gap: 12px; }
|
|
@@ -5339,7 +7711,13 @@ function activate(pi2) {
|
|
|
5339
7711
|
order: 79
|
|
5340
7712
|
});
|
|
5341
7713
|
pi2.registerView("add-friend", { title: () => t("addFriend"), icon: icon("UserPlus"), render: AddFriendPage, head: AddFriendHead, navigation: false });
|
|
5342
|
-
pi2.registerView("members", {
|
|
7714
|
+
pi2.registerView("members", {
|
|
7715
|
+
title: () => DirectUtil.is(book.get().rooms?.find((room) => room.id === book.get().opened)) ? rt("chatInfo") : t("membersTitle"),
|
|
7716
|
+
icon: icon("Users"),
|
|
7717
|
+
render: MembersView,
|
|
7718
|
+
location: "panel",
|
|
7719
|
+
order: 90
|
|
7720
|
+
});
|
|
5343
7721
|
pi2.registerView(DOUBLES_VIEW.slice(DOUBLES_VIEW.lastIndexOf("/") + 1), {
|
|
5344
7722
|
title: () => dt("logTitle"),
|
|
5345
7723
|
icon: icon("Bot"),
|
|
@@ -5350,11 +7728,22 @@ function activate(pi2) {
|
|
|
5350
7728
|
if (!partners2) {
|
|
5351
7729
|
pi2.registerSettings(roomsSettings());
|
|
5352
7730
|
}
|
|
5353
|
-
|
|
5354
|
-
|
|
7731
|
+
if (pi2.rooms) {
|
|
7732
|
+
pi2.registerSettings(replySettings());
|
|
7733
|
+
}
|
|
7734
|
+
const stopDirects = pi2.rooms ? directs.start() : () => {
|
|
5355
7735
|
return;
|
|
5356
7736
|
};
|
|
5357
|
-
|
|
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 ? () => {
|
|
7740
|
+
return;
|
|
7741
|
+
} : shared ? shared.start() : home?.start() ?? (() => {
|
|
7742
|
+
return;
|
|
7743
|
+
});
|
|
7744
|
+
if (shared) {
|
|
7745
|
+
pi2.registerPartners(shared);
|
|
7746
|
+
} else if (pi2.rooms && home) {
|
|
5358
7747
|
pi2.registerHomeItems?.(home);
|
|
5359
7748
|
}
|
|
5360
7749
|
const stopAsks = pi2.rooms ? listenAsks() : () => {
|
|
@@ -5398,6 +7787,7 @@ function activate(pi2) {
|
|
|
5398
7787
|
return () => {
|
|
5399
7788
|
stop?.();
|
|
5400
7789
|
stopAsks();
|
|
7790
|
+
stopDirects();
|
|
5401
7791
|
stopHome();
|
|
5402
7792
|
book.onChange = undefined;
|
|
5403
7793
|
removeStyle();
|