@celljs/ta-rooms 4.20.0 → 4.21.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 +64 -8
- package/host/index.mjs +537 -61
- package/package.json +4 -4
- package/web/index.js +2201 -463
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,129 @@ var RelayFriendsUtil;
|
|
|
509
653
|
RelayFriendsUtil2.migrate = migrate;
|
|
510
654
|
})(RelayFriendsUtil || (RelayFriendsUtil = {}));
|
|
511
655
|
|
|
656
|
+
// web-src/double-protocol.ts
|
|
657
|
+
var DIRECT_KIND = "ta-direct";
|
|
658
|
+
var ROOM_AGENTS_KEY = "agents:";
|
|
659
|
+
var RoomAgentsUtil;
|
|
660
|
+
((RoomAgentsUtil) => {
|
|
661
|
+
function key(member) {
|
|
662
|
+
return `${ROOM_AGENTS_KEY}${member}`;
|
|
663
|
+
}
|
|
664
|
+
RoomAgentsUtil.key = key;
|
|
665
|
+
function address(member, agent) {
|
|
666
|
+
return `${member}/${agent}`;
|
|
667
|
+
}
|
|
668
|
+
RoomAgentsUtil.address = address;
|
|
669
|
+
function list(member, value, by) {
|
|
670
|
+
if (by !== member || !Array.isArray(value)) {
|
|
671
|
+
return [];
|
|
672
|
+
}
|
|
673
|
+
return value.filter((agent) => agent && typeof agent.id === "string" && agent.id && typeof agent.name === "string").slice(0, 16).map((agent) => ({
|
|
674
|
+
id: agent.id,
|
|
675
|
+
name: agent.name,
|
|
676
|
+
...typeof agent.role === "string" && agent.role ? { role: agent.role } : {},
|
|
677
|
+
...Number.isInteger(agent.face) && agent.face >= 0 && agent.face < 64 ? { face: agent.face } : {}
|
|
678
|
+
}));
|
|
679
|
+
}
|
|
680
|
+
RoomAgentsUtil.list = list;
|
|
681
|
+
function of(state) {
|
|
682
|
+
return Object.entries(state).flatMap(([key2, value]) => {
|
|
683
|
+
if (!key2.startsWith(ROOM_AGENTS_KEY) || value.value === null) {
|
|
684
|
+
return [];
|
|
685
|
+
}
|
|
686
|
+
const member = key2.slice(ROOM_AGENTS_KEY.length);
|
|
687
|
+
return list(member, value.value, value.by).map((agent) => ({ ...agent, member }));
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
RoomAgentsUtil.of = of;
|
|
691
|
+
})(RoomAgentsUtil ||= {});
|
|
692
|
+
var TASK_STATUSES = ["queued", "running", "permission", "done", "failed", "stopped", "declined"];
|
|
693
|
+
var ROOM_TASKS_KEY = "tasks:";
|
|
694
|
+
var ROOM_CANCEL_KEY = "cancel:";
|
|
695
|
+
var ROOM_TASKS_SHOWN = 30;
|
|
696
|
+
var RoomTasksUtil;
|
|
697
|
+
((RoomTasksUtil) => {
|
|
698
|
+
function key(member) {
|
|
699
|
+
return `${ROOM_TASKS_KEY}${member}`;
|
|
700
|
+
}
|
|
701
|
+
RoomTasksUtil.key = key;
|
|
702
|
+
function cancelKey(member) {
|
|
703
|
+
return `${ROOM_CANCEL_KEY}${member}`;
|
|
704
|
+
}
|
|
705
|
+
RoomTasksUtil.cancelKey = cancelKey;
|
|
706
|
+
function ended(status) {
|
|
707
|
+
return status === "done" || status === "failed" || status === "stopped" || status === "declined";
|
|
708
|
+
}
|
|
709
|
+
RoomTasksUtil.ended = ended;
|
|
710
|
+
function of(member, value, by) {
|
|
711
|
+
if (by !== member || !value || typeof value !== "object" || Array.isArray(value)) {
|
|
712
|
+
return {};
|
|
713
|
+
}
|
|
714
|
+
const tasks = {};
|
|
715
|
+
for (const [id, task] of Object.entries(value).slice(-ROOM_TASKS_SHOWN)) {
|
|
716
|
+
if (task && TASK_STATUSES.includes(task.status) && typeof task.at === "number") {
|
|
717
|
+
tasks[id] = {
|
|
718
|
+
status: task.status,
|
|
719
|
+
at: task.at,
|
|
720
|
+
...typeof task.detail === "string" && task.detail ? { detail: task.detail.slice(0, 200) } : {}
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
return tasks;
|
|
725
|
+
}
|
|
726
|
+
RoomTasksUtil.of = of;
|
|
727
|
+
function cancelled(member, value, by) {
|
|
728
|
+
return by === member && Array.isArray(value) ? value.filter((id) => typeof id === "string").slice(-ROOM_TASKS_SHOWN) : [];
|
|
729
|
+
}
|
|
730
|
+
RoomTasksUtil.cancelled = cancelled;
|
|
731
|
+
})(RoomTasksUtil ||= {});
|
|
732
|
+
var TASK_MESSAGE_TYPE = "ta-rooms:task";
|
|
733
|
+
var ROOM_CAPABILITIES = ["files", "commands"];
|
|
734
|
+
var DoubleKeys;
|
|
735
|
+
((DoubleKeys) => {
|
|
736
|
+
DoubleKeys.QUIET = "doubles.quiet";
|
|
737
|
+
DoubleKeys.REPLY = "doubles.reply";
|
|
738
|
+
DoubleKeys.DRAFTS = "doubles.drafts";
|
|
739
|
+
DoubleKeys.DONE = "doubles.done";
|
|
740
|
+
DoubleKeys.GRANTS = "doubles.grants";
|
|
741
|
+
DoubleKeys.ASKS = "doubles.asks";
|
|
742
|
+
DoubleKeys.LOG = "doubles.log";
|
|
743
|
+
DoubleKeys.SESSIONS = "doubles.sessions";
|
|
744
|
+
DoubleKeys.READ = "doubles.read";
|
|
745
|
+
DoubleKeys.TASKS = "doubles.tasks";
|
|
746
|
+
DoubleKeys.HANDED = "doubles.handed";
|
|
747
|
+
DoubleKeys.DEVICE = "doubles.device";
|
|
748
|
+
})(DoubleKeys ||= {});
|
|
749
|
+
var DRAFT_MS = 24 * 60 * 60 * 1000;
|
|
750
|
+
var GRANT_HOURS = [1, 24, 24 * 7];
|
|
751
|
+
|
|
752
|
+
// web-src/direct.ts
|
|
753
|
+
var DIRECT_KEY = "direct";
|
|
754
|
+
var DirectUtil;
|
|
755
|
+
((DirectUtil) => {
|
|
756
|
+
function is(room) {
|
|
757
|
+
return room?.kind === DIRECT_KIND;
|
|
758
|
+
}
|
|
759
|
+
DirectUtil.is = is;
|
|
760
|
+
function peer(room) {
|
|
761
|
+
return room.members.find((member) => !member.self);
|
|
762
|
+
}
|
|
763
|
+
DirectUtil.peer = peer;
|
|
764
|
+
function parse(value) {
|
|
765
|
+
return value && typeof value === "object" ? Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string")) : {};
|
|
766
|
+
}
|
|
767
|
+
DirectUtil.parse = parse;
|
|
768
|
+
function friendOf(room, kept) {
|
|
769
|
+
return peer(room)?.id ?? Object.entries(kept).find(([, id]) => id === room.id)?.[0];
|
|
770
|
+
}
|
|
771
|
+
DirectUtil.friendOf = friendOf;
|
|
772
|
+
function find(rooms, kept, friend) {
|
|
773
|
+
const mine = rooms.filter((room) => is(room) && room.status === "member");
|
|
774
|
+
return mine.find((room) => room.id === kept[friend]) ?? mine.find((room) => peer(room)?.id === friend);
|
|
775
|
+
}
|
|
776
|
+
DirectUtil.find = find;
|
|
777
|
+
})(DirectUtil ||= {});
|
|
778
|
+
|
|
512
779
|
// ../ta-relay/esm/common/relay-room-chat.js
|
|
513
780
|
var RELAY_CHAT_KEY = "chat:";
|
|
514
781
|
var RELAY_CHAT_PART_BYTES = 8 * 1024;
|
|
@@ -546,6 +813,7 @@ var RelayRoomChatUtil;
|
|
|
546
813
|
...line.double === true ? { double: true } : {},
|
|
547
814
|
...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
815
|
...to.length ? { to } : {},
|
|
816
|
+
...line.person === true && to.length && line.double !== true && !line.agent ? { person: true } : {},
|
|
549
817
|
...typeof line.re === "string" ? { re: line.re } : {},
|
|
550
818
|
...line.task === true && to.length ? { task: true } : {}
|
|
551
819
|
};
|
|
@@ -671,97 +939,6 @@ class RelayRoomChat {
|
|
|
671
939
|
}
|
|
672
940
|
}
|
|
673
941
|
|
|
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
942
|
// web-src/i18n.ts
|
|
766
943
|
var EN = {
|
|
767
944
|
friendShareTitle: "From {name}",
|
|
@@ -881,7 +1058,7 @@ var EN = {
|
|
|
881
1058
|
roomOfName: "{name}’s group chat",
|
|
882
1059
|
back: "Back",
|
|
883
1060
|
openPage: "Open {name}",
|
|
884
|
-
apps: "Apps
|
|
1061
|
+
apps: "Apps",
|
|
885
1062
|
pageLine: "A group chat of {name}: play in it together",
|
|
886
1063
|
chatEmpty: "Nothing said yet. Only those in the group chat read it: the relay keeps it sealed.",
|
|
887
1064
|
chatPlaceholder: "Message",
|
|
@@ -1020,7 +1197,7 @@ var ZH = {
|
|
|
1020
1197
|
roomOfName: "{name}的群聊",
|
|
1021
1198
|
back: "返回",
|
|
1022
1199
|
openPage: "打开{name}",
|
|
1023
|
-
apps: "
|
|
1200
|
+
apps: "应用",
|
|
1024
1201
|
pageLine: "{name}的群聊,大家可以一起玩",
|
|
1025
1202
|
chatEmpty: "还没有人说话。只有群里的人能看到,中继保存的是密文。",
|
|
1026
1203
|
chatPlaceholder: "发消息",
|
|
@@ -1159,7 +1336,7 @@ var ZH_TW = {
|
|
|
1159
1336
|
roomOfName: "{name}的群聊",
|
|
1160
1337
|
back: "返回",
|
|
1161
1338
|
openPage: "開啟{name}",
|
|
1162
|
-
apps: "
|
|
1339
|
+
apps: "應用",
|
|
1163
1340
|
pageLine: "{name}的群聊,大家可以一起玩",
|
|
1164
1341
|
chatEmpty: "還沒有人說話。只有群裡的人能看到,中繼儲存的是密文。",
|
|
1165
1342
|
chatPlaceholder: "發訊息",
|
|
@@ -1298,7 +1475,7 @@ var JA = {
|
|
|
1298
1475
|
roomOfName: "{name}のグループチャット",
|
|
1299
1476
|
back: "戻る",
|
|
1300
1477
|
openPage: "{name} を開く",
|
|
1301
|
-
apps: "
|
|
1478
|
+
apps: "アプリ",
|
|
1302
1479
|
pageLine: "{name} のグループチャット:一緒にプレイします",
|
|
1303
1480
|
chatEmpty: "まだ何も言われていません。グループ内の人だけが見ることができます。リレーは暗号化されて保存します。",
|
|
1304
1481
|
chatPlaceholder: "メッセージ",
|
|
@@ -1851,23 +2028,151 @@ function MemberFaces({ room, onClick, shown }) {
|
|
|
1851
2028
|
}, "+", members.length - 5));
|
|
1852
2029
|
}
|
|
1853
2030
|
|
|
1854
|
-
// web-src/
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
2031
|
+
// web-src/direct-view.tsx
|
|
2032
|
+
class DirectBook {
|
|
2033
|
+
kept = {};
|
|
2034
|
+
listeners = new Set;
|
|
2035
|
+
started = false;
|
|
2036
|
+
get() {
|
|
2037
|
+
return this.kept;
|
|
2038
|
+
}
|
|
2039
|
+
subscribe(listener) {
|
|
2040
|
+
this.listeners.add(listener);
|
|
2041
|
+
return () => this.listeners.delete(listener);
|
|
2042
|
+
}
|
|
2043
|
+
start() {
|
|
2044
|
+
if (this.started || !pi.storage) {
|
|
2045
|
+
return () => {
|
|
2046
|
+
return;
|
|
2047
|
+
};
|
|
2048
|
+
}
|
|
2049
|
+
this.started = true;
|
|
2050
|
+
const stop = pi.storage.onChange((keys) => keys.includes(DIRECT_KEY) && void this.read());
|
|
2051
|
+
this.read();
|
|
2052
|
+
return () => {
|
|
2053
|
+
stop();
|
|
2054
|
+
this.started = false;
|
|
2055
|
+
};
|
|
2056
|
+
}
|
|
2057
|
+
async keep(friend, room) {
|
|
2058
|
+
await this.read();
|
|
2059
|
+
if (this.kept[friend] !== room) {
|
|
2060
|
+
this.put({ ...this.kept, [friend]: room });
|
|
2061
|
+
await pi.storage.set(DIRECT_KEY, this.kept);
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
async read() {
|
|
2065
|
+
this.put(DirectUtil.parse(await pi.storage.get(DIRECT_KEY).catch(() => {
|
|
2066
|
+
return;
|
|
2067
|
+
})));
|
|
2068
|
+
}
|
|
2069
|
+
put(kept) {
|
|
2070
|
+
this.kept = kept;
|
|
2071
|
+
for (const listener of this.listeners) {
|
|
2072
|
+
listener();
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
var directs = new DirectBook;
|
|
2077
|
+
function useDirects() {
|
|
2078
|
+
return React.useSyncExternalStore((listener) => directs.subscribe(listener), () => directs.get());
|
|
2079
|
+
}
|
|
2080
|
+
function directPeer(room, friends, kept = directs.get()) {
|
|
2081
|
+
const peer = DirectUtil.peer(room);
|
|
2082
|
+
if (peer) {
|
|
2083
|
+
return { id: peer.id, name: peer.name };
|
|
2084
|
+
}
|
|
2085
|
+
const id = DirectUtil.friendOf(room, kept);
|
|
2086
|
+
const friend = id ? friends?.find((each) => each.id === id) : undefined;
|
|
2087
|
+
return { id: id ?? room.id, name: friend?.name ?? room.title };
|
|
2088
|
+
}
|
|
2089
|
+
function DirectFace({ room, size, unread }) {
|
|
2090
|
+
const { friends } = React.useSyncExternalStore((listener) => book.subscribe(listener), () => book.get());
|
|
2091
|
+
const kept = useDirects();
|
|
2092
|
+
const peer = directPeer(room, friends, kept);
|
|
2093
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
2094
|
+
className: "trm-room-face",
|
|
2095
|
+
style: { width: size, height: size },
|
|
2096
|
+
"aria-hidden": "true"
|
|
2097
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
2098
|
+
id: peer.id,
|
|
2099
|
+
name: peer.name,
|
|
2100
|
+
size
|
|
2101
|
+
}), unread && /* @__PURE__ */ React.createElement("i", {
|
|
2102
|
+
className: "trm-unread"
|
|
2103
|
+
}));
|
|
2104
|
+
}
|
|
2105
|
+
async function openDirect(friend) {
|
|
2106
|
+
const server = rooms();
|
|
2107
|
+
if (!server?.inviteFriends) {
|
|
2108
|
+
return;
|
|
2109
|
+
}
|
|
2110
|
+
try {
|
|
2111
|
+
await book.load();
|
|
2112
|
+
const { rooms: list = [] } = book.get();
|
|
2113
|
+
let room = DirectUtil.find(list, directs.get(), friend.id);
|
|
2114
|
+
const invite = !room ? (await server.listGroupInvites().catch(() => [])).find((each) => each.kind === DIRECT_KIND && each.by.id === friend.id) : undefined;
|
|
2115
|
+
if (invite) {
|
|
2116
|
+
await server.answerGroupInvite(invite.room, true);
|
|
2117
|
+
room = (await server.listRooms()).find((each) => each.id === invite.room && each.status === "member");
|
|
2118
|
+
}
|
|
2119
|
+
if (!room) {
|
|
2120
|
+
room = await server.createRoom({ kind: DIRECT_KIND, title: friend.name });
|
|
2121
|
+
await server.configureRoom(room.id, { members: 2 }).catch(() => {
|
|
2122
|
+
return;
|
|
2123
|
+
});
|
|
2124
|
+
await server.inviteFriends(room.id, [friend.id]);
|
|
2125
|
+
} else if (room.owner && !DirectUtil.peer(room)) {
|
|
2126
|
+
await server.inviteFriends(room.id, [friend.id]).catch(() => {
|
|
2127
|
+
return;
|
|
2128
|
+
});
|
|
2129
|
+
}
|
|
2130
|
+
await directs.keep(friend.id, room.id);
|
|
2131
|
+
await book.load();
|
|
2132
|
+
openRoom(room.id, true);
|
|
2133
|
+
} catch (error) {
|
|
2134
|
+
pi.ui.notify(message(error), "error");
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
var reinvited = new Set;
|
|
2138
|
+
function reinvite(room) {
|
|
2139
|
+
const friend = DirectUtil.friendOf(room, directs.get());
|
|
2140
|
+
if (!friend || reinvited.has(room.id)) {
|
|
2141
|
+
return;
|
|
2142
|
+
}
|
|
2143
|
+
reinvited.add(room.id);
|
|
2144
|
+
rooms()?.inviteFriends?.(room.id, [friend]).catch(() => {
|
|
2145
|
+
return;
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
// web-src/double-i18n.ts
|
|
2150
|
+
var EN2 = {
|
|
2151
|
+
scope: "Where",
|
|
2152
|
+
scopeHere: "Only in {place}",
|
|
2153
|
+
placeGroup: "“{title}”",
|
|
2154
|
+
placeDirect: "the chat with {name}",
|
|
2155
|
+
scopeAll: "All chats with {name}",
|
|
2156
|
+
scopeHereShort: "in {place}",
|
|
2157
|
+
scopeAllShort: "all chats",
|
|
2158
|
+
grantsTitle: "What your double does for others",
|
|
2159
|
+
grantsHint: "Besides chatting: given by you, for a person, in one chat or all of them",
|
|
2160
|
+
grantsInSettings: "Taken back in Settings → Others and your double",
|
|
2161
|
+
doubleOf: "{name}'s double",
|
|
2162
|
+
myDouble: "Your double",
|
|
2163
|
+
doubleTag: "Double",
|
|
2164
|
+
mentionLabel: "Ask a double",
|
|
2165
|
+
mentionDetail: "Ask their double",
|
|
2166
|
+
answersHere: "Your double answers here",
|
|
2167
|
+
answersHint: "When someone asks it with @, your double answers in this room. It only chats and reads the room, unless you let it do more for someone.",
|
|
2168
|
+
permissions: "Let the double work for them",
|
|
2169
|
+
grantTitle: "Let your double work for {name}",
|
|
2170
|
+
grantLead: "When {name} asks your double in a room, it may also do this on your computer:",
|
|
2171
|
+
files: "Read and change files",
|
|
2172
|
+
filesHint: "Only inside the directory below.",
|
|
2173
|
+
commands: "Run commands",
|
|
2174
|
+
commandsHint: "In that directory, though a command can reach beyond it: only for someone you trust.",
|
|
2175
|
+
directory: "Directory",
|
|
1871
2176
|
pick: "Choose",
|
|
1872
2177
|
duration: "For",
|
|
1873
2178
|
hours1: "1 hour",
|
|
@@ -1951,6 +2256,16 @@ var EN2 = {
|
|
|
1951
2256
|
taskLog: "{name} handed a task"
|
|
1952
2257
|
};
|
|
1953
2258
|
var ZH2 = {
|
|
2259
|
+
scope: "在哪",
|
|
2260
|
+
scopeHere: "只在{place}",
|
|
2261
|
+
placeGroup: "「{title}」",
|
|
2262
|
+
placeDirect: "和{name}的私聊",
|
|
2263
|
+
scopeAll: "和{name}的所有聊天",
|
|
2264
|
+
scopeHereShort: "在{place}",
|
|
2265
|
+
scopeAllShort: "所有聊天",
|
|
2266
|
+
grantsTitle: "分身替别人做的事",
|
|
2267
|
+
grantsHint: "聊天之外的事:由你给,按人给,可以只在一个聊天里",
|
|
2268
|
+
grantsInSettings: "在 设置 → 别人与我的分身 里查看和收回",
|
|
1954
2269
|
doubleOf: "{name}的分身",
|
|
1955
2270
|
myDouble: "我的分身",
|
|
1956
2271
|
doubleTag: "分身",
|
|
@@ -2049,6 +2364,16 @@ var ZH2 = {
|
|
|
2049
2364
|
taskLog: "{name}交来任务"
|
|
2050
2365
|
};
|
|
2051
2366
|
var ZH_TW2 = {
|
|
2367
|
+
scope: "在哪",
|
|
2368
|
+
scopeHere: "只在{place}",
|
|
2369
|
+
placeGroup: "「{title}」",
|
|
2370
|
+
placeDirect: "和{name}的私聊",
|
|
2371
|
+
scopeAll: "和{name}的所有聊天",
|
|
2372
|
+
scopeHereShort: "在{place}",
|
|
2373
|
+
scopeAllShort: "所有聊天",
|
|
2374
|
+
grantsTitle: "分身替別人做的事",
|
|
2375
|
+
grantsHint: "聊天之外的事:由你給,按人給,可以只在一個聊天裡",
|
|
2376
|
+
grantsInSettings: "在 設定 → 別人與我的分身 裡查看和收回",
|
|
2052
2377
|
doubleOf: "{name}的分身",
|
|
2053
2378
|
myDouble: "我的分身",
|
|
2054
2379
|
doubleTag: "分身",
|
|
@@ -2147,6 +2472,16 @@ var ZH_TW2 = {
|
|
|
2147
2472
|
taskLog: "{name}交來任務"
|
|
2148
2473
|
};
|
|
2149
2474
|
var JA2 = {
|
|
2475
|
+
scope: "場所",
|
|
2476
|
+
scopeHere: "{place}だけ",
|
|
2477
|
+
placeGroup: "「{title}」",
|
|
2478
|
+
placeDirect: "{name}との個別チャット",
|
|
2479
|
+
scopeAll: "{name}とのすべてのチャット",
|
|
2480
|
+
scopeHereShort: "{place}で",
|
|
2481
|
+
scopeAllShort: "すべてのチャット",
|
|
2482
|
+
grantsTitle: "分身が他の人のためにすること",
|
|
2483
|
+
grantsHint: "チャット以外のこと:あなたが人ごとに許可し、1 つのチャットに限ることもできます",
|
|
2484
|
+
grantsInSettings: "設定 → ほかの人と分身 で確認・取り消しできます",
|
|
2150
2485
|
doubleOf: "{name}の分身",
|
|
2151
2486
|
myDouble: "私の分身",
|
|
2152
2487
|
doubleTag: "分身",
|
|
@@ -2256,13 +2591,137 @@ function dt(key, values = {}) {
|
|
|
2256
2591
|
return DoubleWordsUtil.of(pi.ui.language)[key].replace(/\{(\w+)\}/g, (whole, name) => (name in values) ? String(values[name]) : whole);
|
|
2257
2592
|
}
|
|
2258
2593
|
|
|
2594
|
+
// web-src/reply-policy.ts
|
|
2595
|
+
var REPLY_MODES = ["away", "draft", "always", "notify"];
|
|
2596
|
+
var TASK_MODES = ["allow", "ask", "deny"];
|
|
2597
|
+
var INVITE_MODES = ["join", "ask", "deny"];
|
|
2598
|
+
var AWAY_MINUTES = [3, 10, 30, 60];
|
|
2599
|
+
var ReplyPolicyUtil;
|
|
2600
|
+
((ReplyPolicyUtil) => {
|
|
2601
|
+
ReplyPolicyUtil.DEFAULT = {
|
|
2602
|
+
mode: "away",
|
|
2603
|
+
awayMinutes: 10,
|
|
2604
|
+
strangers: "notify",
|
|
2605
|
+
tasks: { friends: "allow", strangers: "ask" },
|
|
2606
|
+
invites: "ask",
|
|
2607
|
+
chats: {},
|
|
2608
|
+
people: {}
|
|
2609
|
+
};
|
|
2610
|
+
function isTaskMode(value) {
|
|
2611
|
+
return typeof value === "string" && TASK_MODES.includes(value);
|
|
2612
|
+
}
|
|
2613
|
+
ReplyPolicyUtil.isTaskMode = isTaskMode;
|
|
2614
|
+
function isInviteMode(value) {
|
|
2615
|
+
return typeof value === "string" && INVITE_MODES.includes(value);
|
|
2616
|
+
}
|
|
2617
|
+
ReplyPolicyUtil.isInviteMode = isInviteMode;
|
|
2618
|
+
function person(value) {
|
|
2619
|
+
if (isMode(value)) {
|
|
2620
|
+
return { reply: value };
|
|
2621
|
+
}
|
|
2622
|
+
const kept = value && typeof value === "object" ? value : undefined;
|
|
2623
|
+
const policy = {
|
|
2624
|
+
...isMode(kept?.reply) ? { reply: kept.reply } : {},
|
|
2625
|
+
...isTaskMode(kept?.tasks) ? { tasks: kept.tasks } : {},
|
|
2626
|
+
...isInviteMode(kept?.invites) ? { invites: kept.invites } : {},
|
|
2627
|
+
...kept?.moments === false ? { moments: false } : {}
|
|
2628
|
+
};
|
|
2629
|
+
return Object.keys(policy).length ? policy : undefined;
|
|
2630
|
+
}
|
|
2631
|
+
ReplyPolicyUtil.person = person;
|
|
2632
|
+
function isMode(value) {
|
|
2633
|
+
return typeof value === "string" && REPLY_MODES.includes(value);
|
|
2634
|
+
}
|
|
2635
|
+
ReplyPolicyUtil.isMode = isMode;
|
|
2636
|
+
function parse(value, quiet) {
|
|
2637
|
+
const kept = value && typeof value === "object" ? value : {};
|
|
2638
|
+
const modes = (map, max) => map && typeof map === "object" ? Object.fromEntries(Object.entries(map).filter((entry) => isMode(entry[1])).slice(0, max)) : {};
|
|
2639
|
+
const off = quiet && typeof quiet === "object" ? Object.fromEntries(Object.entries(quiet).filter(([, on]) => on === true).map(([room]) => [room, "notify"])) : {};
|
|
2640
|
+
const minutes2 = Number(kept.awayMinutes);
|
|
2641
|
+
const q = kept.quiet;
|
|
2642
|
+
const tasks = kept.tasks;
|
|
2643
|
+
const minute = (each) => Number.isInteger(each) && each >= 0 && each < 24 * 60;
|
|
2644
|
+
return {
|
|
2645
|
+
mode: isMode(kept.mode) ? kept.mode : ReplyPolicyUtil.DEFAULT.mode,
|
|
2646
|
+
awayMinutes: Number.isFinite(minutes2) && minutes2 >= 1 && minutes2 <= 24 * 60 ? Math.round(minutes2) : ReplyPolicyUtil.DEFAULT.awayMinutes,
|
|
2647
|
+
strangers: isMode(kept.strangers) ? kept.strangers : ReplyPolicyUtil.DEFAULT.strangers,
|
|
2648
|
+
...q && minute(q.from) && minute(q.to) && q.from !== q.to && isMode(q.mode) ? { quiet: { from: q.from, to: q.to, mode: q.mode } } : {},
|
|
2649
|
+
tasks: {
|
|
2650
|
+
friends: isTaskMode(tasks?.friends) ? tasks.friends : ReplyPolicyUtil.DEFAULT.tasks.friends,
|
|
2651
|
+
strangers: isTaskMode(tasks?.strangers) ? tasks.strangers : ReplyPolicyUtil.DEFAULT.tasks.strangers
|
|
2652
|
+
},
|
|
2653
|
+
invites: isInviteMode(kept.invites) ? kept.invites : ReplyPolicyUtil.DEFAULT.invites,
|
|
2654
|
+
chats: { ...off, ...modes(kept.chats, 500) },
|
|
2655
|
+
people: Object.fromEntries(Object.entries(kept.people && typeof kept.people === "object" ? kept.people : {}).slice(0, 500).flatMap(([id, value2]) => {
|
|
2656
|
+
const one = person(value2);
|
|
2657
|
+
return one ? [[id, one]] : [];
|
|
2658
|
+
}))
|
|
2659
|
+
};
|
|
2660
|
+
}
|
|
2661
|
+
ReplyPolicyUtil.parse = parse;
|
|
2662
|
+
function within(quiet, date) {
|
|
2663
|
+
const now = date.getHours() * 60 + date.getMinutes();
|
|
2664
|
+
return quiet.from < quiet.to ? now >= quiet.from && now < quiet.to : now >= quiet.from || now < quiet.to;
|
|
2665
|
+
}
|
|
2666
|
+
ReplyPolicyUtil.within = within;
|
|
2667
|
+
function modeOf(policy, input) {
|
|
2668
|
+
const person2 = policy.people[input.person]?.reply;
|
|
2669
|
+
if (person2) {
|
|
2670
|
+
return { mode: person2, source: "person" };
|
|
2671
|
+
}
|
|
2672
|
+
const chat = policy.chats[input.room];
|
|
2673
|
+
if (chat) {
|
|
2674
|
+
return { mode: chat, source: "chat" };
|
|
2675
|
+
}
|
|
2676
|
+
if (!input.friend) {
|
|
2677
|
+
return { mode: policy.strangers, source: "strangers" };
|
|
2678
|
+
}
|
|
2679
|
+
if (policy.quiet && within(policy.quiet, input.date)) {
|
|
2680
|
+
return { mode: policy.quiet.mode, source: "quiet" };
|
|
2681
|
+
}
|
|
2682
|
+
return { mode: policy.mode, source: "default" };
|
|
2683
|
+
}
|
|
2684
|
+
ReplyPolicyUtil.modeOf = modeOf;
|
|
2685
|
+
function taskOf(policy, person2, friend) {
|
|
2686
|
+
return policy.people[person2]?.tasks ?? (friend ? policy.tasks.friends : policy.tasks.strangers);
|
|
2687
|
+
}
|
|
2688
|
+
ReplyPolicyUtil.taskOf = taskOf;
|
|
2689
|
+
function inviteOf(policy, person2) {
|
|
2690
|
+
return policy.people[person2]?.invites ?? policy.invites;
|
|
2691
|
+
}
|
|
2692
|
+
ReplyPolicyUtil.inviteOf = inviteOf;
|
|
2693
|
+
function set(policy, where, id, mode) {
|
|
2694
|
+
const { [id]: _was, ...rest } = policy[where];
|
|
2695
|
+
return { ...policy, [where]: mode ? { ...rest, [id]: mode } : rest };
|
|
2696
|
+
}
|
|
2697
|
+
ReplyPolicyUtil.set = set;
|
|
2698
|
+
function setPerson(policy, id, key, value) {
|
|
2699
|
+
const { [key]: _was, ...others } = policy.people[id] ?? {};
|
|
2700
|
+
const next = value === undefined ? others : { ...others, [key]: value };
|
|
2701
|
+
const { [id]: _person, ...rest } = policy.people;
|
|
2702
|
+
return { ...policy, people: Object.keys(next).length ? { ...rest, [id]: next } : rest };
|
|
2703
|
+
}
|
|
2704
|
+
ReplyPolicyUtil.setPerson = setPerson;
|
|
2705
|
+
function clock(minutes2) {
|
|
2706
|
+
return `${String(Math.floor(minutes2 / 60)).padStart(2, "0")}:${String(minutes2 % 60).padStart(2, "0")}`;
|
|
2707
|
+
}
|
|
2708
|
+
ReplyPolicyUtil.clock = clock;
|
|
2709
|
+
function minutes(clock2) {
|
|
2710
|
+
const match = /^(\d{1,2}):(\d{2})$/.exec(clock2.trim());
|
|
2711
|
+
const value = match ? Number(match[1]) * 60 + Number(match[2]) : Number.NaN;
|
|
2712
|
+
return Number.isInteger(value) && value >= 0 && value < 24 * 60 ? value : undefined;
|
|
2713
|
+
}
|
|
2714
|
+
ReplyPolicyUtil.minutes = minutes;
|
|
2715
|
+
})(ReplyPolicyUtil ||= {});
|
|
2716
|
+
|
|
2259
2717
|
// web-src/doubles-store.ts
|
|
2260
|
-
var KEYS = [DoubleKeys.QUIET, DoubleKeys.GRANTS, DoubleKeys.ASKS, DoubleKeys.LOG, DoubleKeys.TASKS, DoubleKeys.HANDED];
|
|
2718
|
+
var KEYS = [DoubleKeys.QUIET, DoubleKeys.REPLY, DoubleKeys.DRAFTS, DoubleKeys.GRANTS, DoubleKeys.ASKS, DoubleKeys.LOG, DoubleKeys.TASKS, DoubleKeys.HANDED];
|
|
2261
2719
|
|
|
2262
2720
|
class DoublesStore {
|
|
2263
|
-
state = { quiet: {}, grants: [], asks: [], log: [], tasks: [], handed: [] };
|
|
2721
|
+
state = { quiet: {}, reply: ReplyPolicyUtil.DEFAULT, drafts: [], grants: [], asks: [], log: [], tasks: [], handed: [] };
|
|
2264
2722
|
listeners = new Set;
|
|
2265
2723
|
started = false;
|
|
2724
|
+
replyValue;
|
|
2266
2725
|
onAsk;
|
|
2267
2726
|
get() {
|
|
2268
2727
|
return this.state;
|
|
@@ -2295,10 +2754,15 @@ class DoublesStore {
|
|
|
2295
2754
|
return;
|
|
2296
2755
|
})));
|
|
2297
2756
|
const next = { ...this.state };
|
|
2757
|
+
let replyValue = this.replyValue;
|
|
2298
2758
|
keys.forEach((key, index) => {
|
|
2299
2759
|
const value = values[index];
|
|
2300
2760
|
if (key === DoubleKeys.QUIET) {
|
|
2301
2761
|
next.quiet = value && typeof value === "object" ? value : {};
|
|
2762
|
+
} else if (key === DoubleKeys.REPLY) {
|
|
2763
|
+
replyValue = value;
|
|
2764
|
+
} else if (key === DoubleKeys.DRAFTS) {
|
|
2765
|
+
next.drafts = Array.isArray(value) ? value : [];
|
|
2302
2766
|
} else if (key === DoubleKeys.GRANTS) {
|
|
2303
2767
|
next.grants = Array.isArray(value) ? value : [];
|
|
2304
2768
|
} else if (key === DoubleKeys.ASKS) {
|
|
@@ -2311,6 +2775,8 @@ class DoublesStore {
|
|
|
2311
2775
|
next.handed = Array.isArray(value) ? value : [];
|
|
2312
2776
|
}
|
|
2313
2777
|
});
|
|
2778
|
+
this.replyValue = replyValue;
|
|
2779
|
+
next.reply = ReplyPolicyUtil.parse(replyValue, next.quiet);
|
|
2314
2780
|
const known = new Set(this.state.asks.map((ask) => ask.id));
|
|
2315
2781
|
const fresh = keys.includes(DoubleKeys.ASKS) ? next.asks.filter((ask) => !known.has(ask.id)) : [];
|
|
2316
2782
|
this.state = next;
|
|
@@ -2334,24 +2800,20 @@ async function callDoubles(request) {
|
|
|
2334
2800
|
throw new Error(/no method|no host/i.test(text) ? dt("oldServer") : text);
|
|
2335
2801
|
}
|
|
2336
2802
|
}
|
|
2337
|
-
function
|
|
2338
|
-
return
|
|
2339
|
-
}
|
|
2340
|
-
function askable(room) {
|
|
2341
|
-
return room.members.filter((member) => !member.self && !member.guest);
|
|
2803
|
+
function mentionable(room) {
|
|
2804
|
+
return room.members.filter((member) => !member.self);
|
|
2342
2805
|
}
|
|
2343
2806
|
function names(text, name) {
|
|
2344
2807
|
const quoted = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2345
2808
|
return new RegExp(`@${quoted}(?![\\p{L}\\p{N}_])`, "u").test(text);
|
|
2346
2809
|
}
|
|
2347
2810
|
function addressed(text, room, agents = []) {
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
];
|
|
2811
|
+
const people = mentionable(room).filter((member) => names(text, member.name)).map((member) => member.member);
|
|
2812
|
+
const named = agents.filter((agent) => names(text, agent.name)).map((agent) => RoomAgentsUtil.address(agent.member, agent.id));
|
|
2813
|
+
return { to: [...people, ...named], person: people.length > 0 };
|
|
2352
2814
|
}
|
|
2353
|
-
function grantsOf(grants, friend, now = Date.now()) {
|
|
2354
|
-
return grants.filter((grant) => grant.friend === friend && grant.expiresAt > now);
|
|
2815
|
+
function grantsOf(grants, friend, room, now = Date.now()) {
|
|
2816
|
+
return grants.filter((grant) => grant.friend === friend && grant.expiresAt > now && (room === undefined || grant.room === undefined || grant.room === room));
|
|
2355
2817
|
}
|
|
2356
2818
|
function left(until, now = Date.now()) {
|
|
2357
2819
|
const minutes = Math.max(1, Math.round((until - now) / 60000));
|
|
@@ -2372,215 +2834,404 @@ function mayLine(grants) {
|
|
|
2372
2834
|
return dt("may", { what: TaLanguageUtil.list(pi.ui.language, what), left: left(Math.min(...grants.map((grant) => grant.expiresAt))) });
|
|
2373
2835
|
}
|
|
2374
2836
|
|
|
2375
|
-
// web-src/
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2837
|
+
// web-src/reply-i18n.ts
|
|
2838
|
+
var EN3 = {
|
|
2839
|
+
replyTitle: "Others and your double",
|
|
2840
|
+
replyLead: "When someone @s you in a group chat or writes to you, who answers.",
|
|
2841
|
+
modeAway: "Your double, once you are away",
|
|
2842
|
+
modeAwayHint: "You are told; if you neither look nor answer within {n} min, your double answers for you",
|
|
2843
|
+
modeDraft: "Your double drafts, you send",
|
|
2844
|
+
modeDraftHint: "Your double writes an answer at once; you send it, change it or drop it",
|
|
2845
|
+
modeAlways: "Your double, at once",
|
|
2846
|
+
modeAlwaysHint: "Your double answers at once, and you are told",
|
|
2847
|
+
modeNotify: "Only you",
|
|
2848
|
+
modeNotifyHint: "You are told; your double keeps quiet",
|
|
2849
|
+
modeDefault: "As for everyone",
|
|
2850
|
+
replyDefault: "Who answers",
|
|
2851
|
+
replyAway: "Away after",
|
|
2852
|
+
replyAwayHint: "Unread and unanswered this long, you count as away",
|
|
2853
|
+
minutes: "{n} min",
|
|
2854
|
+
replyStrangers: "People who are not your friends",
|
|
2855
|
+
replyStrangersHint: "In group chats: what they @ you with",
|
|
2856
|
+
replyQuiet: "Quiet hours",
|
|
2857
|
+
replyQuietHint: "In these hours, for friends, instead of the above",
|
|
2858
|
+
replyQuietOff: "Off",
|
|
2859
|
+
replyQuietFrom: "From",
|
|
2860
|
+
replyQuietTo: "to",
|
|
2861
|
+
replyOwn: "Set on their own",
|
|
2862
|
+
replyOwnHint: "Chats and people set apart, in the members of a chat or on a friend",
|
|
2863
|
+
replyOwnNone: "None yet",
|
|
2864
|
+
replyOwnRemove: "Back to as for everyone",
|
|
2865
|
+
replyHere: "Who answers here",
|
|
2866
|
+
replyThem: "When {name} reaches you",
|
|
2867
|
+
replyPick: "Who answers",
|
|
2868
|
+
draftTitle: "Your double drafted an answer to {name}",
|
|
2869
|
+
draftSend: "Send",
|
|
2870
|
+
draftEdit: "Change",
|
|
2871
|
+
draftDrop: "Drop",
|
|
2872
|
+
draftSave: "Send it",
|
|
2873
|
+
draftCancel: "Cancel",
|
|
2874
|
+
drafted: "Drafted",
|
|
2875
|
+
message: "Message",
|
|
2876
|
+
directEmpty: "Your chat with {name}",
|
|
2877
|
+
directHint: "Only the two of you, end to end. When {name} is away, their double may answer, as they set it.",
|
|
2878
|
+
directWaiting: "{name} gets it in their Ta",
|
|
2879
|
+
directDelete: "Delete the chat",
|
|
2880
|
+
directDeleteTitle: "Delete your chat with {name}?",
|
|
2881
|
+
directDeleteOwn: "It is gone for both of you. Messages sent later start a new one.",
|
|
2882
|
+
directDeleteOther: "You leave it. A message from {name} later starts a new one.",
|
|
2883
|
+
chatsSection: "Chats",
|
|
2884
|
+
mentionPerson: "Member",
|
|
2885
|
+
chatInfo: "Chat info",
|
|
2886
|
+
removeFriendLong: "Remove from friends",
|
|
2887
|
+
workFor: "Your double works for them",
|
|
2888
|
+
workNone: "Only chats with them",
|
|
2889
|
+
workGive: "Allow",
|
|
2890
|
+
workStop: "Stop all",
|
|
2891
|
+
tasksFrom: "Tasks they hand your double",
|
|
2892
|
+
taskAllow: "Take them",
|
|
2893
|
+
taskAsk: "Ask me first",
|
|
2894
|
+
taskDeny: "Turn them down",
|
|
2895
|
+
invitesFrom: "Their invitations to group chats",
|
|
2896
|
+
inviteJoin: "Join at once",
|
|
2897
|
+
inviteAsk: "Ask me",
|
|
2898
|
+
inviteDeny: "Turn them down",
|
|
2899
|
+
momentsTo: "They see your posts",
|
|
2900
|
+
momentsShown: "Your posts show to them",
|
|
2901
|
+
momentsHidden: "Your new posts do not show to them",
|
|
2902
|
+
personTitle: "Member",
|
|
2903
|
+
personPolicy: "What they may do",
|
|
2904
|
+
tasksShort: "Tasks:",
|
|
2905
|
+
invitesShort: "Invites:",
|
|
2906
|
+
momentsHiddenShort: "Posts hidden",
|
|
2907
|
+
policyAll: "What others may do",
|
|
2908
|
+
policyAllHint: "For all, unless set for someone in their info",
|
|
2909
|
+
tasksFriends: "Tasks from friends",
|
|
2910
|
+
tasksOthers: "Tasks from others",
|
|
2911
|
+
invitesAll: "Invitations of friends to group chats",
|
|
2912
|
+
approveTitle: "{name} hands your double a task",
|
|
2913
|
+
approveTake: "Take it",
|
|
2914
|
+
approveDecline: "Not this time",
|
|
2915
|
+
approveWaiting: "Waits for you to take it"
|
|
2916
|
+
};
|
|
2917
|
+
var ZH3 = {
|
|
2918
|
+
replyTitle: "别人与我的分身",
|
|
2919
|
+
replyLead: "有人在群聊里 @ 你、或者给你发消息时,由谁来回。",
|
|
2920
|
+
modeAway: "我不在时分身回",
|
|
2921
|
+
modeAwayHint: "先提醒你;{n} 分钟内没看也没回,分身替你回",
|
|
2922
|
+
modeDraft: "分身拟稿我确认",
|
|
2923
|
+
modeDraftHint: "分身马上写好回复,你点发送、改一下或者不发",
|
|
2924
|
+
modeAlways: "分身直接回",
|
|
2925
|
+
modeAlwaysHint: "分身立刻回,你也会收到提醒",
|
|
2926
|
+
modeNotify: "只提醒我",
|
|
2927
|
+
modeNotifyHint: "只提醒你,分身不回",
|
|
2928
|
+
modeDefault: "跟随默认",
|
|
2929
|
+
replyDefault: "谁来回",
|
|
2930
|
+
replyAway: "多久算不在",
|
|
2931
|
+
replyAwayHint: "这么久没看也没回,就算你不在",
|
|
2932
|
+
minutes: "{n} 分钟",
|
|
2933
|
+
replyStrangers: "不是好友的人",
|
|
2934
|
+
replyStrangersHint: "群聊里不是你好友的人 @ 你时",
|
|
2935
|
+
replyQuiet: "勿扰时段",
|
|
2936
|
+
replyQuietHint: "这段时间里,好友找你时按这里来,不按上面",
|
|
2937
|
+
replyQuietOff: "不开",
|
|
2938
|
+
replyQuietFrom: "从",
|
|
2939
|
+
replyQuietTo: "到",
|
|
2940
|
+
replyOwn: "单独设置",
|
|
2941
|
+
replyOwnHint: "在聊天的成员页或好友资料里,可以给某个聊天、某个人单独设",
|
|
2942
|
+
replyOwnNone: "还没有",
|
|
2943
|
+
replyOwnRemove: "改回跟随默认",
|
|
2944
|
+
replyHere: "这里谁来回",
|
|
2945
|
+
replyThem: "{name}找我时",
|
|
2946
|
+
replyPick: "谁来回",
|
|
2947
|
+
draftTitle: "分身拟好了给{name}的回复",
|
|
2948
|
+
draftSend: "发送",
|
|
2949
|
+
draftEdit: "改一下",
|
|
2950
|
+
draftDrop: "不发",
|
|
2951
|
+
draftSave: "发送",
|
|
2952
|
+
draftCancel: "取消",
|
|
2953
|
+
drafted: "已拟稿",
|
|
2954
|
+
message: "发消息",
|
|
2955
|
+
directEmpty: "和{name}的聊天",
|
|
2956
|
+
directHint: "只有你们两个人,端到端加密。{name}不在时,TA 的分身可能会按 TA 的设置替 TA 回。",
|
|
2957
|
+
directWaiting: "{name}会在自己的 Ta 里收到",
|
|
2958
|
+
directDelete: "删除聊天",
|
|
2959
|
+
directDeleteTitle: "删除和{name}的聊天?",
|
|
2960
|
+
directDeleteOwn: "你们两边都会删掉。之后再发消息会开始新的聊天。",
|
|
2961
|
+
directDeleteOther: "你会离开这个聊天。{name}之后再发消息会开始新的聊天。",
|
|
2962
|
+
chatsSection: "聊天",
|
|
2963
|
+
mentionPerson: "成员",
|
|
2964
|
+
chatInfo: "聊天信息",
|
|
2965
|
+
removeFriendLong: "删除好友",
|
|
2966
|
+
workFor: "分身替 TA 做事",
|
|
2967
|
+
workNone: "只聊天",
|
|
2968
|
+
workGive: "授权",
|
|
2969
|
+
workStop: "全部停掉",
|
|
2970
|
+
tasksFrom: "TA 给我的分身派任务",
|
|
2971
|
+
taskAllow: "直接接",
|
|
2972
|
+
taskAsk: "先问我",
|
|
2973
|
+
taskDeny: "不接",
|
|
2974
|
+
invitesFrom: "TA 拉我进群",
|
|
2975
|
+
inviteJoin: "直接进",
|
|
2976
|
+
inviteAsk: "先问我",
|
|
2977
|
+
inviteDeny: "不进",
|
|
2978
|
+
momentsTo: "TA 能看我的动态",
|
|
2979
|
+
momentsShown: "我的动态对 TA 可见",
|
|
2980
|
+
momentsHidden: "之后发的动态不给 TA 看",
|
|
2981
|
+
personTitle: "成员",
|
|
2982
|
+
personPolicy: "TA 能做什么",
|
|
2983
|
+
tasksShort: "派任务",
|
|
2984
|
+
invitesShort: "拉群",
|
|
2985
|
+
momentsHiddenShort: "不给看动态",
|
|
2986
|
+
policyAll: "别人能做什么",
|
|
2987
|
+
policyAllHint: "对所有人生效;在某人的资料里可以单独设",
|
|
2988
|
+
tasksFriends: "好友派任务",
|
|
2989
|
+
tasksOthers: "其他人派任务",
|
|
2990
|
+
invitesAll: "好友拉我进群",
|
|
2991
|
+
approveTitle: "{name}给你的分身派了任务",
|
|
2992
|
+
approveTake: "接",
|
|
2993
|
+
approveDecline: "这次不接",
|
|
2994
|
+
approveWaiting: "等你决定接不接"
|
|
2995
|
+
};
|
|
2996
|
+
var ZH_TW3 = {
|
|
2997
|
+
replyTitle: "別人與我的分身",
|
|
2998
|
+
replyLead: "有人在群聊裡 @ 你、或者傳訊息給你時,由誰來回。",
|
|
2999
|
+
modeAway: "我不在時分身回",
|
|
3000
|
+
modeAwayHint: "先提醒你;{n} 分鐘內沒看也沒回,分身替你回",
|
|
3001
|
+
modeDraft: "分身擬稿我確認",
|
|
3002
|
+
modeDraftHint: "分身馬上寫好回覆,你點傳送、改一下或者不傳",
|
|
3003
|
+
modeAlways: "分身直接回",
|
|
3004
|
+
modeAlwaysHint: "分身立刻回,你也會收到提醒",
|
|
3005
|
+
modeNotify: "只提醒我",
|
|
3006
|
+
modeNotifyHint: "只提醒你,分身不回",
|
|
3007
|
+
modeDefault: "跟隨預設",
|
|
3008
|
+
replyDefault: "誰來回",
|
|
3009
|
+
replyAway: "多久算不在",
|
|
3010
|
+
replyAwayHint: "這麼久沒看也沒回,就算你不在",
|
|
3011
|
+
minutes: "{n} 分鐘",
|
|
3012
|
+
replyStrangers: "不是好友的人",
|
|
3013
|
+
replyStrangersHint: "群聊裡不是你好友的人 @ 你時",
|
|
3014
|
+
replyQuiet: "勿擾時段",
|
|
3015
|
+
replyQuietHint: "這段時間裡,好友找你時按這裡來,不按上面",
|
|
3016
|
+
replyQuietOff: "不開",
|
|
3017
|
+
replyQuietFrom: "從",
|
|
3018
|
+
replyQuietTo: "到",
|
|
3019
|
+
replyOwn: "單獨設定",
|
|
3020
|
+
replyOwnHint: "在聊天的成員頁或好友資料裡,可以給某個聊天、某個人單獨設",
|
|
3021
|
+
replyOwnNone: "還沒有",
|
|
3022
|
+
replyOwnRemove: "改回跟隨預設",
|
|
3023
|
+
replyHere: "這裡誰來回",
|
|
3024
|
+
replyThem: "{name}找我時",
|
|
3025
|
+
replyPick: "誰來回",
|
|
3026
|
+
draftTitle: "分身擬好了給{name}的回覆",
|
|
3027
|
+
draftSend: "傳送",
|
|
3028
|
+
draftEdit: "改一下",
|
|
3029
|
+
draftDrop: "不傳",
|
|
3030
|
+
draftSave: "傳送",
|
|
3031
|
+
draftCancel: "取消",
|
|
3032
|
+
drafted: "已擬稿",
|
|
3033
|
+
message: "傳訊息",
|
|
3034
|
+
directEmpty: "和{name}的聊天",
|
|
3035
|
+
directHint: "只有你們兩個人,端對端加密。{name}不在時,TA 的分身可能會按 TA 的設定替 TA 回。",
|
|
3036
|
+
directWaiting: "{name}會在自己的 Ta 裡收到",
|
|
3037
|
+
directDelete: "刪除聊天",
|
|
3038
|
+
directDeleteTitle: "刪除和{name}的聊天?",
|
|
3039
|
+
directDeleteOwn: "你們兩邊都會刪掉。之後再傳訊息會開始新的聊天。",
|
|
3040
|
+
directDeleteOther: "你會離開這個聊天。{name}之後再傳訊息會開始新的聊天。",
|
|
3041
|
+
chatsSection: "聊天",
|
|
3042
|
+
mentionPerson: "成員",
|
|
3043
|
+
chatInfo: "聊天資訊",
|
|
3044
|
+
removeFriendLong: "刪除好友",
|
|
3045
|
+
workFor: "分身替 TA 做事",
|
|
3046
|
+
workNone: "只聊天",
|
|
3047
|
+
workGive: "授權",
|
|
3048
|
+
workStop: "全部停掉",
|
|
3049
|
+
tasksFrom: "TA 給我的分身派任務",
|
|
3050
|
+
taskAllow: "直接接",
|
|
3051
|
+
taskAsk: "先問我",
|
|
3052
|
+
taskDeny: "不接",
|
|
3053
|
+
invitesFrom: "TA 拉我進群",
|
|
3054
|
+
inviteJoin: "直接進",
|
|
3055
|
+
inviteAsk: "先問我",
|
|
3056
|
+
inviteDeny: "不進",
|
|
3057
|
+
momentsTo: "TA 能看我的動態",
|
|
3058
|
+
momentsShown: "我的動態對 TA 可見",
|
|
3059
|
+
momentsHidden: "之後發的動態不給 TA 看",
|
|
3060
|
+
personTitle: "成員",
|
|
3061
|
+
personPolicy: "TA 能做什麼",
|
|
3062
|
+
tasksShort: "派任務",
|
|
3063
|
+
invitesShort: "拉群",
|
|
3064
|
+
momentsHiddenShort: "不給看動態",
|
|
3065
|
+
policyAll: "別人能做什麼",
|
|
3066
|
+
policyAllHint: "對所有人生效;在某人的資料裡可以單獨設",
|
|
3067
|
+
tasksFriends: "好友派任務",
|
|
3068
|
+
tasksOthers: "其他人派任務",
|
|
3069
|
+
invitesAll: "好友拉我進群",
|
|
3070
|
+
approveTitle: "{name}給你的分身派了任務",
|
|
3071
|
+
approveTake: "接",
|
|
3072
|
+
approveDecline: "這次不接",
|
|
3073
|
+
approveWaiting: "等你決定接不接"
|
|
3074
|
+
};
|
|
3075
|
+
var JA3 = {
|
|
3076
|
+
replyTitle: "ほかの人と分身",
|
|
3077
|
+
replyLead: "グループチャットで @ されたときや、メッセージが届いたときに、誰が返信するか。",
|
|
3078
|
+
modeAway: "不在のときは分身が返信",
|
|
3079
|
+
modeAwayHint: "まず通知し、{n} 分以内に見ても返信してもいなければ分身が代わりに返信します",
|
|
3080
|
+
modeDraft: "分身が下書き、自分で送信",
|
|
3081
|
+
modeDraftHint: "分身がすぐに返信を書き、送信・修正・破棄はあなたが決めます",
|
|
3082
|
+
modeAlways: "すぐに分身が返信",
|
|
3083
|
+
modeAlwaysHint: "分身がすぐに返信し、あなたにも通知します",
|
|
3084
|
+
modeNotify: "自分だけに通知",
|
|
3085
|
+
modeNotifyHint: "通知のみで、分身は返信しません",
|
|
3086
|
+
modeDefault: "デフォルトに従う",
|
|
3087
|
+
replyDefault: "誰が返信するか",
|
|
3088
|
+
replyAway: "不在とみなすまで",
|
|
3089
|
+
replyAwayHint: "この時間見ずに返信もしなければ、不在とみなします",
|
|
3090
|
+
minutes: "{n} 分",
|
|
3091
|
+
replyStrangers: "友だちではない人",
|
|
3092
|
+
replyStrangersHint: "グループチャットで友だちではない人に @ されたとき",
|
|
3093
|
+
replyQuiet: "おやすみ時間",
|
|
3094
|
+
replyQuietHint: "この時間帯は、友だちからの連絡に上の設定ではなくこちらを使います",
|
|
3095
|
+
replyQuietOff: "オフ",
|
|
3096
|
+
replyQuietFrom: "開始",
|
|
3097
|
+
replyQuietTo: "〜",
|
|
3098
|
+
replyOwn: "個別の設定",
|
|
3099
|
+
replyOwnHint: "チャットのメンバー画面や友だちのプロフィールで、チャットや人ごとに設定できます",
|
|
3100
|
+
replyOwnNone: "まだありません",
|
|
3101
|
+
replyOwnRemove: "デフォルトに戻す",
|
|
3102
|
+
replyHere: "ここでは誰が返信するか",
|
|
3103
|
+
replyThem: "{name} から連絡が来たとき",
|
|
3104
|
+
replyPick: "誰が返信するか",
|
|
3105
|
+
draftTitle: "分身が {name} への返信を下書きしました",
|
|
3106
|
+
draftSend: "送信",
|
|
3107
|
+
draftEdit: "修正",
|
|
3108
|
+
draftDrop: "破棄",
|
|
3109
|
+
draftSave: "送信",
|
|
3110
|
+
draftCancel: "キャンセル",
|
|
3111
|
+
drafted: "下書き済み",
|
|
3112
|
+
message: "メッセージ",
|
|
3113
|
+
directEmpty: "{name} とのチャット",
|
|
3114
|
+
directHint: "ふたりだけの、エンドツーエンド暗号化されたチャットです。{name} が不在のときは、設定に応じて分身が代わりに返信することがあります。",
|
|
3115
|
+
directWaiting: "{name} の Ta に届きます",
|
|
3116
|
+
directDelete: "チャットを削除",
|
|
3117
|
+
directDeleteTitle: "{name} とのチャットを削除しますか?",
|
|
3118
|
+
directDeleteOwn: "ふたりとも削除されます。あとでメッセージを送ると新しいチャットが始まります。",
|
|
3119
|
+
directDeleteOther: "このチャットから退出します。{name} があとでメッセージを送ると新しいチャットが始まります。",
|
|
3120
|
+
chatsSection: "チャット",
|
|
3121
|
+
mentionPerson: "メンバー",
|
|
3122
|
+
chatInfo: "チャット情報",
|
|
3123
|
+
removeFriendLong: "友だちから削除",
|
|
3124
|
+
workFor: "分身が代わりに作業",
|
|
3125
|
+
workNone: "チャットのみ",
|
|
3126
|
+
workGive: "許可",
|
|
3127
|
+
workStop: "すべて停止",
|
|
3128
|
+
tasksFrom: "分身へのタスク依頼",
|
|
3129
|
+
taskAllow: "すぐ受ける",
|
|
3130
|
+
taskAsk: "先に確認",
|
|
3131
|
+
taskDeny: "受けない",
|
|
3132
|
+
invitesFrom: "グループチャットへの招待",
|
|
3133
|
+
inviteJoin: "すぐ参加",
|
|
3134
|
+
inviteAsk: "先に確認",
|
|
3135
|
+
inviteDeny: "参加しない",
|
|
3136
|
+
momentsTo: "投稿を見られる",
|
|
3137
|
+
momentsShown: "あなたの投稿が表示されます",
|
|
3138
|
+
momentsHidden: "今後の投稿は表示されません",
|
|
3139
|
+
personTitle: "メンバー",
|
|
3140
|
+
personPolicy: "できること",
|
|
3141
|
+
tasksShort: "タスク",
|
|
3142
|
+
invitesShort: "招待",
|
|
3143
|
+
momentsHiddenShort: "投稿非表示",
|
|
3144
|
+
policyAll: "ほかの人ができること",
|
|
3145
|
+
policyAllHint: "全員に適用。各人のプロフィールで個別に設定できます",
|
|
3146
|
+
tasksFriends: "友だちからのタスク",
|
|
3147
|
+
tasksOthers: "ほかの人からのタスク",
|
|
3148
|
+
invitesAll: "友だちからのグループ招待",
|
|
3149
|
+
approveTitle: "{name}があなたの分身にタスクを依頼しました",
|
|
3150
|
+
approveTake: "受ける",
|
|
3151
|
+
approveDecline: "今回は受けない",
|
|
3152
|
+
approveWaiting: "受けるかどうか待っています"
|
|
3153
|
+
};
|
|
3154
|
+
var REPLY_WORDS = { "zh-CN": ZH3, "zh-TW": ZH_TW3, "en-US": EN3, "ja-JP": JA3 };
|
|
3155
|
+
function rt(key, values = {}) {
|
|
3156
|
+
return TaLanguageUtil.pick(pi.ui.language, REPLY_WORDS)[key].replace(/\{(\w+)\}/g, (whole, name) => (name in values) ? String(values[name]) : whole);
|
|
2382
3157
|
}
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
const
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
3158
|
+
|
|
3159
|
+
// web-src/doubles-view.tsx
|
|
3160
|
+
var DOUBLES_VIEW = "@celljs/ta-rooms/doubles";
|
|
3161
|
+
function useBusy() {
|
|
3162
|
+
const fallback = React.useState(false);
|
|
3163
|
+
const busy = pi.ui.useBusy?.();
|
|
3164
|
+
if (busy) {
|
|
3165
|
+
return busy;
|
|
3166
|
+
}
|
|
3167
|
+
const [on, set] = fallback;
|
|
3168
|
+
return [
|
|
3169
|
+
on,
|
|
3170
|
+
async (action) => {
|
|
3171
|
+
set(true);
|
|
3172
|
+
try {
|
|
3173
|
+
await action();
|
|
3174
|
+
} finally {
|
|
3175
|
+
set(false);
|
|
3176
|
+
}
|
|
2395
3177
|
}
|
|
2396
|
-
|
|
3178
|
+
];
|
|
2397
3179
|
}
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
return new Promise((resolve) => {
|
|
2401
|
-
const check = () => {
|
|
2402
|
-
if (chat.lines.some(hello)) {
|
|
2403
|
-
done();
|
|
2404
|
-
}
|
|
2405
|
-
};
|
|
2406
|
-
const stop = chat.subscribe(check);
|
|
2407
|
-
const timer = setTimeout(() => done(), HELLO_MS);
|
|
2408
|
-
const done = () => {
|
|
2409
|
-
stop();
|
|
2410
|
-
clearTimeout(timer);
|
|
2411
|
-
resolve();
|
|
2412
|
-
};
|
|
2413
|
-
check();
|
|
2414
|
-
});
|
|
3180
|
+
function hoursLabel(hours) {
|
|
3181
|
+
return hours === 1 ? dt("hours1") : hours === 24 ? dt("hours24") : dt("hours168");
|
|
2415
3182
|
}
|
|
2416
|
-
function
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
const
|
|
2427
|
-
|
|
2428
|
-
|
|
3183
|
+
function GrantDialog({
|
|
3184
|
+
friend,
|
|
3185
|
+
name,
|
|
3186
|
+
ask,
|
|
3187
|
+
room,
|
|
3188
|
+
close
|
|
3189
|
+
}) {
|
|
3190
|
+
const { rooms: rooms2 } = useBook();
|
|
3191
|
+
const at = ask ? { id: ask.room, title: ask.title } : room;
|
|
3192
|
+
const chat = at && rooms2?.find((each) => each.id === at.id);
|
|
3193
|
+
const here = at && {
|
|
3194
|
+
id: at.id,
|
|
3195
|
+
place: chat && DirectUtil.is(chat) ? dt("placeDirect", { name: DirectUtil.peer(chat)?.name ?? name }) : dt("placeGroup", { title: at.title })
|
|
2429
3196
|
};
|
|
2430
|
-
const
|
|
3197
|
+
const [everywhere, setEverywhere] = React.useState(!here);
|
|
3198
|
+
const cwd = pi.ui.useCwd();
|
|
3199
|
+
const [directory, setDirectory] = React.useState(cwd);
|
|
3200
|
+
const [picking, setPicking] = React.useState(false);
|
|
3201
|
+
const [hours, setHours] = React.useState(1);
|
|
3202
|
+
const [chosen, setChosen] = React.useState(ask ? [ask.capability] : ["files"]);
|
|
3203
|
+
const [error, setError] = React.useState();
|
|
3204
|
+
const [busy, run] = useBusy();
|
|
3205
|
+
const Folder = icon("Folder");
|
|
3206
|
+
const answer = (accept) => void run(async () => {
|
|
3207
|
+
setError(undefined);
|
|
3208
|
+
try {
|
|
3209
|
+
if (ask) {
|
|
3210
|
+
await callDoubles({ kind: "answer", ask: ask.id, accept, cwd: directory, hours, everywhere, ...here ? { place: here.place } : {} });
|
|
3211
|
+
} else if (accept) {
|
|
3212
|
+
await callDoubles({
|
|
3213
|
+
kind: "grant",
|
|
3214
|
+
friend,
|
|
3215
|
+
name,
|
|
3216
|
+
capabilities: chosen,
|
|
3217
|
+
cwd: directory,
|
|
3218
|
+
hours,
|
|
3219
|
+
...here && !everywhere ? { room: here.id, title: here.place } : {}
|
|
3220
|
+
});
|
|
3221
|
+
}
|
|
3222
|
+
close();
|
|
3223
|
+
} catch (failure) {
|
|
3224
|
+
setError(message(failure));
|
|
3225
|
+
}
|
|
3226
|
+
});
|
|
3227
|
+
const toggle = (capability, on) => setChosen((list) => on ? [...new Set([...list, capability])] : list.filter((each) => each !== capability));
|
|
2431
3228
|
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
2432
|
-
title: dt("
|
|
3229
|
+
title: ask ? dt("asksTitle") : dt("grantTitle", { name }),
|
|
2433
3230
|
onClose: close
|
|
2434
3231
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
2435
3232
|
className: "trm-dialog"
|
|
2436
|
-
}, /* @__PURE__ */ React.createElement("
|
|
2437
|
-
className: "trm-
|
|
2438
|
-
}, dt("pickAgentLead")), !agents && !error && Loading && /* @__PURE__ */ React.createElement(Loading, null), agents?.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
2439
|
-
title: dt("noAgents"),
|
|
2440
|
-
hint: dt("noAgentsHint"),
|
|
2441
|
-
compact: true
|
|
2442
|
-
}), agents && agents.length > 0 && /* @__PURE__ */ React.createElement("ul", {
|
|
2443
|
-
className: "trm-rows trm-agent-pick"
|
|
2444
|
-
}, agents.map((agent) => {
|
|
2445
|
-
const joined = inRoom.some((each) => each.id === agent.id && each.member === self);
|
|
2446
|
-
const coming = joining.some((each) => each.id === agent.id);
|
|
2447
|
-
return /* @__PURE__ */ React.createElement("li", {
|
|
2448
|
-
key: agent.id
|
|
2449
|
-
}, /* @__PURE__ */ React.createElement("button", {
|
|
2450
|
-
type: "button",
|
|
2451
|
-
className: "trm-member",
|
|
2452
|
-
disabled: joined || coming,
|
|
2453
|
-
onClick: () => invite(agent)
|
|
2454
|
-
}, /* @__PURE__ */ React.createElement(Face, {
|
|
2455
|
-
id: agent.id,
|
|
2456
|
-
name: agent.name,
|
|
2457
|
-
face: agent.face,
|
|
2458
|
-
size: 34
|
|
2459
|
-
}), /* @__PURE__ */ React.createElement("span", {
|
|
2460
|
-
className: "trm-member-text"
|
|
2461
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
2462
|
-
className: "trm-member-name trm-ellipsis"
|
|
2463
|
-
}, agent.name), /* @__PURE__ */ React.createElement("span", {
|
|
2464
|
-
className: "trm-member-detail trm-ellipsis"
|
|
2465
|
-
}, joined ? dt("inRoom") : coming ? dt("joining") : agent.role)), coming ? /* @__PURE__ */ React.createElement("span", {
|
|
2466
|
-
className: "ta-spinner"
|
|
2467
|
-
}) : !joined && /* @__PURE__ */ React.createElement(Plus, {
|
|
2468
|
-
size: 16
|
|
2469
|
-
})));
|
|
2470
|
-
})), error && /* @__PURE__ */ React.createElement("p", {
|
|
2471
|
-
className: "trm-error"
|
|
2472
|
-
}, error)));
|
|
2473
|
-
}
|
|
2474
|
-
function openAgentPicker(room) {
|
|
2475
|
-
show(({ close }) => /* @__PURE__ */ React.createElement(AgentPicker, {
|
|
2476
|
-
room,
|
|
2477
|
-
close
|
|
2478
|
-
}));
|
|
2479
|
-
}
|
|
2480
|
-
function JoiningRow({ agent }) {
|
|
2481
|
-
return /* @__PURE__ */ React.createElement("li", {
|
|
2482
|
-
className: "trm-member",
|
|
2483
|
-
"aria-busy": "true"
|
|
2484
|
-
}, /* @__PURE__ */ React.createElement(Face, {
|
|
2485
|
-
id: agent.id,
|
|
2486
|
-
name: agent.name,
|
|
2487
|
-
face: agent.face,
|
|
2488
|
-
size: 34
|
|
2489
|
-
}), /* @__PURE__ */ React.createElement("span", {
|
|
2490
|
-
className: "trm-member-text"
|
|
2491
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
2492
|
-
className: "trm-member-name trm-ellipsis"
|
|
2493
|
-
}, agent.name), /* @__PURE__ */ React.createElement("span", {
|
|
2494
|
-
className: "trm-member-detail trm-ellipsis"
|
|
2495
|
-
}, dt("joining"))), /* @__PURE__ */ React.createElement("span", {
|
|
2496
|
-
className: "ta-spinner trm-member-action"
|
|
2497
|
-
}));
|
|
2498
|
-
}
|
|
2499
|
-
function AgentRow({ room, agent }) {
|
|
2500
|
-
const Remove = icon("X");
|
|
2501
|
-
const mine = room.members.find((member) => member.self)?.member === agent.member;
|
|
2502
|
-
return /* @__PURE__ */ React.createElement("li", {
|
|
2503
|
-
className: "trm-member"
|
|
2504
|
-
}, /* @__PURE__ */ React.createElement(Face, {
|
|
2505
|
-
id: agent.id,
|
|
2506
|
-
name: agent.name,
|
|
2507
|
-
face: agent.face,
|
|
2508
|
-
size: 34
|
|
2509
|
-
}), /* @__PURE__ */ React.createElement("span", {
|
|
2510
|
-
className: "trm-member-text"
|
|
2511
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
2512
|
-
className: "trm-member-name"
|
|
2513
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
2514
|
-
className: "trm-ellipsis"
|
|
2515
|
-
}, agent.name), /* @__PURE__ */ React.createElement("span", {
|
|
2516
|
-
className: "trm-tag trm-tag-agent"
|
|
2517
|
-
}, agentOwner(room, agent))), agent.role && /* @__PURE__ */ React.createElement("span", {
|
|
2518
|
-
className: "trm-member-detail trm-ellipsis"
|
|
2519
|
-
}, agent.role)), mine && /* @__PURE__ */ React.createElement("button", {
|
|
2520
|
-
type: "button",
|
|
2521
|
-
className: "trm-icon trm-danger trm-member-action",
|
|
2522
|
-
title: dt("dismiss"),
|
|
2523
|
-
"aria-label": dt("dismiss"),
|
|
2524
|
-
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))
|
|
2525
|
-
}, /* @__PURE__ */ React.createElement(Remove, {
|
|
2526
|
-
size: 15
|
|
2527
|
-
})));
|
|
2528
|
-
}
|
|
2529
|
-
|
|
2530
|
-
// web-src/doubles-view.tsx
|
|
2531
|
-
var DOUBLES_VIEW = "@celljs/ta-rooms/doubles";
|
|
2532
|
-
function useBusy() {
|
|
2533
|
-
const fallback = React.useState(false);
|
|
2534
|
-
const busy = pi.ui.useBusy?.();
|
|
2535
|
-
if (busy) {
|
|
2536
|
-
return busy;
|
|
2537
|
-
}
|
|
2538
|
-
const [on, set] = fallback;
|
|
2539
|
-
return [
|
|
2540
|
-
on,
|
|
2541
|
-
async (action) => {
|
|
2542
|
-
set(true);
|
|
2543
|
-
try {
|
|
2544
|
-
await action();
|
|
2545
|
-
} finally {
|
|
2546
|
-
set(false);
|
|
2547
|
-
}
|
|
2548
|
-
}
|
|
2549
|
-
];
|
|
2550
|
-
}
|
|
2551
|
-
function hoursLabel(hours) {
|
|
2552
|
-
return hours === 1 ? dt("hours1") : hours === 24 ? dt("hours24") : dt("hours168");
|
|
2553
|
-
}
|
|
2554
|
-
function GrantDialog({ friend, name, ask, close }) {
|
|
2555
|
-
const cwd = pi.ui.useCwd();
|
|
2556
|
-
const [directory, setDirectory] = React.useState(cwd);
|
|
2557
|
-
const [picking, setPicking] = React.useState(false);
|
|
2558
|
-
const [hours, setHours] = React.useState(1);
|
|
2559
|
-
const [chosen, setChosen] = React.useState(ask ? [ask.capability] : ["files"]);
|
|
2560
|
-
const [error, setError] = React.useState();
|
|
2561
|
-
const [busy, run] = useBusy();
|
|
2562
|
-
const Folder = icon("Folder");
|
|
2563
|
-
const answer = (accept) => void run(async () => {
|
|
2564
|
-
setError(undefined);
|
|
2565
|
-
try {
|
|
2566
|
-
if (ask) {
|
|
2567
|
-
await callDoubles({ kind: "answer", ask: ask.id, accept, cwd: directory, hours });
|
|
2568
|
-
} else if (accept) {
|
|
2569
|
-
await callDoubles({ kind: "grant", friend, name, capabilities: chosen, cwd: directory, hours });
|
|
2570
|
-
}
|
|
2571
|
-
close();
|
|
2572
|
-
} catch (failure) {
|
|
2573
|
-
setError(message(failure));
|
|
2574
|
-
}
|
|
2575
|
-
});
|
|
2576
|
-
const toggle = (capability, on) => setChosen((list) => on ? [...new Set([...list, capability])] : list.filter((each) => each !== capability));
|
|
2577
|
-
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
2578
|
-
title: ask ? dt("asksTitle") : dt("grantTitle", { name }),
|
|
2579
|
-
onClose: close
|
|
2580
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
2581
|
-
className: "trm-dialog"
|
|
2582
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
2583
|
-
className: "trm-grant-who"
|
|
3233
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3234
|
+
className: "trm-grant-who"
|
|
2584
3235
|
}, /* @__PURE__ */ React.createElement(Face, {
|
|
2585
3236
|
id: friend,
|
|
2586
3237
|
name,
|
|
@@ -2619,7 +3270,21 @@ function GrantDialog({ friend, name, ask, close }) {
|
|
|
2619
3270
|
size: 15
|
|
2620
3271
|
}), /* @__PURE__ */ React.createElement("span", {
|
|
2621
3272
|
className: "trm-ellipsis"
|
|
2622
|
-
}, directory || dt("pick")))), /* @__PURE__ */ React.createElement("div", {
|
|
3273
|
+
}, directory || dt("pick")))), here && /* @__PURE__ */ React.createElement("div", {
|
|
3274
|
+
className: "trm-grant-field"
|
|
3275
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3276
|
+
className: "trm-grant-label"
|
|
3277
|
+
}, dt("scope")), /* @__PURE__ */ React.createElement("span", {
|
|
3278
|
+
className: "trm-chips"
|
|
3279
|
+
}, [false, true].map((all) => /* @__PURE__ */ React.createElement("button", {
|
|
3280
|
+
key: String(all),
|
|
3281
|
+
type: "button",
|
|
3282
|
+
"aria-pressed": everywhere === all,
|
|
3283
|
+
className: `trm-chip${everywhere === all ? " trm-chip-on" : ""}`,
|
|
3284
|
+
onClick: () => setEverywhere(all)
|
|
3285
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3286
|
+
className: "trm-ellipsis"
|
|
3287
|
+
}, all ? dt("scopeAll", { name }) : dt("scopeHere", { place: here.place })))))), /* @__PURE__ */ React.createElement("div", {
|
|
2623
3288
|
className: "trm-grant-field"
|
|
2624
3289
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
2625
3290
|
className: "trm-grant-label"
|
|
@@ -2661,13 +3326,53 @@ function GrantDialog({ friend, name, ask, close }) {
|
|
|
2661
3326
|
onClose: () => setPicking(false)
|
|
2662
3327
|
}));
|
|
2663
3328
|
}
|
|
2664
|
-
function openGrant(member) {
|
|
3329
|
+
function openGrant(member, room) {
|
|
2665
3330
|
show(({ close }) => /* @__PURE__ */ React.createElement(GrantDialog, {
|
|
2666
3331
|
friend: member.id,
|
|
2667
3332
|
name: member.name,
|
|
3333
|
+
room,
|
|
3334
|
+
close
|
|
3335
|
+
}));
|
|
3336
|
+
}
|
|
3337
|
+
function openApprove(task) {
|
|
3338
|
+
show(({ close }) => /* @__PURE__ */ React.createElement(ApproveDialog, {
|
|
3339
|
+
task,
|
|
2668
3340
|
close
|
|
2669
3341
|
}));
|
|
2670
3342
|
}
|
|
3343
|
+
function ApproveDialog({ task, close }) {
|
|
3344
|
+
const [busy, run] = useBusy();
|
|
3345
|
+
const answer = (accept) => void run(async () => {
|
|
3346
|
+
await callDoubles({ kind: "approveTask", task: task.id, accept }).catch((error) => pi.ui.notify(message(error), "error"));
|
|
3347
|
+
close();
|
|
3348
|
+
});
|
|
3349
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
3350
|
+
title: rt("approveTitle", { name: task.name }),
|
|
3351
|
+
onClose: close
|
|
3352
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3353
|
+
className: "trm-dialog"
|
|
3354
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3355
|
+
className: "trm-grant-who"
|
|
3356
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
3357
|
+
id: task.friend,
|
|
3358
|
+
name: task.name,
|
|
3359
|
+
size: 36
|
|
3360
|
+
}), /* @__PURE__ */ React.createElement("p", {
|
|
3361
|
+
className: "trm-lead"
|
|
3362
|
+
}, task.text)), /* @__PURE__ */ React.createElement("div", {
|
|
3363
|
+
className: "trm-actions"
|
|
3364
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3365
|
+
type: "button",
|
|
3366
|
+
className: "ta-button",
|
|
3367
|
+
disabled: busy,
|
|
3368
|
+
onClick: () => answer(false)
|
|
3369
|
+
}, rt("approveDecline")), /* @__PURE__ */ React.createElement("button", {
|
|
3370
|
+
type: "button",
|
|
3371
|
+
className: "ta-button ta-primary",
|
|
3372
|
+
disabled: busy,
|
|
3373
|
+
onClick: () => answer(true)
|
|
3374
|
+
}, rt("approveTake")))));
|
|
3375
|
+
}
|
|
2671
3376
|
var asking;
|
|
2672
3377
|
function openAsk(ask) {
|
|
2673
3378
|
if (asking) {
|
|
@@ -2706,23 +3411,12 @@ function AskRow({ ask }) {
|
|
|
2706
3411
|
onClick: () => openAsk(ask)
|
|
2707
3412
|
}, dt("review"))));
|
|
2708
3413
|
}
|
|
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) {
|
|
3414
|
+
function useMayLine(member, room) {
|
|
2724
3415
|
const { grants } = useDoubles();
|
|
2725
|
-
return member.self || member.guest ? "" : mayLine(grantsOf(grants, member.id));
|
|
3416
|
+
return member.self || member.guest ? "" : mayLine(grantsOf(grants, member.id, room));
|
|
3417
|
+
}
|
|
3418
|
+
function scopeOf(grant) {
|
|
3419
|
+
return grant.room ? dt("scopeHereShort", { place: grant.title ?? "" }) : dt("scopeAllShort");
|
|
2726
3420
|
}
|
|
2727
3421
|
async function revokeAll(friend, name) {
|
|
2728
3422
|
if (await pi.ui.confirm(dt("revokeAllTitle", { name }), dt("revokeAllHint", { name }), { confirmLabel: dt("stop"), danger: true })) {
|
|
@@ -2758,7 +3452,7 @@ function GrantRow({ grant }) {
|
|
|
2758
3452
|
}, capabilityName(grant.capability))), /* @__PURE__ */ React.createElement("span", {
|
|
2759
3453
|
className: "trm-row-line trm-ellipsis",
|
|
2760
3454
|
title: grant.cwd
|
|
2761
|
-
}, grant.cwd, " · ", left(grant.expiresAt))), /* @__PURE__ */ React.createElement("button", {
|
|
3455
|
+
}, scopeOf(grant), " · ", grant.cwd, " · ", left(grant.expiresAt))), /* @__PURE__ */ React.createElement("button", {
|
|
2762
3456
|
type: "button",
|
|
2763
3457
|
className: "ta-button",
|
|
2764
3458
|
disabled: busy,
|
|
@@ -2766,7 +3460,7 @@ function GrantRow({ grant }) {
|
|
|
2766
3460
|
}, dt("revoke")));
|
|
2767
3461
|
}
|
|
2768
3462
|
function LogRow({ entry }) {
|
|
2769
|
-
const outcome = entry.outcome === "answered" ? dt("answered") : entry.outcome === "failed" ? dt("failed") : dt("limited");
|
|
3463
|
+
const outcome = entry.outcome === "answered" ? dt("answered") : entry.outcome === "drafted" ? rt("drafted") : entry.outcome === "failed" ? dt("failed") : dt("limited");
|
|
2770
3464
|
return /* @__PURE__ */ React.createElement("li", {
|
|
2771
3465
|
className: "trm-log"
|
|
2772
3466
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
@@ -2784,7 +3478,7 @@ function LogRow({ entry }) {
|
|
|
2784
3478
|
}, entry.asked), entry.answer && /* @__PURE__ */ React.createElement("div", {
|
|
2785
3479
|
className: "trm-log-answer"
|
|
2786
3480
|
}, entry.answer), /* @__PURE__ */ React.createElement("div", {
|
|
2787
|
-
className: `trm-log-meta${entry.outcome === "answered" ? "" : " trm-log-bad"}`
|
|
3481
|
+
className: `trm-log-meta${entry.outcome === "answered" || entry.outcome === "drafted" ? "" : " trm-log-bad"}`
|
|
2788
3482
|
}, [
|
|
2789
3483
|
outcome,
|
|
2790
3484
|
...entry.capabilities.length ? [entry.capabilities.map(capabilityName).join(" · ")] : [],
|
|
@@ -2792,11 +3486,33 @@ function LogRow({ entry }) {
|
|
|
2792
3486
|
...entry.error ? [entry.error] : []
|
|
2793
3487
|
].join(" · ")));
|
|
2794
3488
|
}
|
|
3489
|
+
function GrantList() {
|
|
3490
|
+
const { grants } = useDoubles();
|
|
3491
|
+
const now = Date.now();
|
|
3492
|
+
const live = grants.filter((grant) => grant.expiresAt > now);
|
|
3493
|
+
const friends = [...new Map(live.map((grant) => [grant.friend, grant.name])).entries()];
|
|
3494
|
+
if (live.length === 0) {
|
|
3495
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
3496
|
+
className: "trm-note"
|
|
3497
|
+
}, dt("noGrants"));
|
|
3498
|
+
}
|
|
3499
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3500
|
+
className: "trm-grants"
|
|
3501
|
+
}, /* @__PURE__ */ React.createElement("ul", {
|
|
3502
|
+
className: "trm-rows"
|
|
3503
|
+
}, live.map((grant) => /* @__PURE__ */ React.createElement(GrantRow, {
|
|
3504
|
+
key: grant.id,
|
|
3505
|
+
grant
|
|
3506
|
+
}))), friends.map(([friend, name]) => /* @__PURE__ */ React.createElement(RevokeAll, {
|
|
3507
|
+
key: friend,
|
|
3508
|
+
friend,
|
|
3509
|
+
name
|
|
3510
|
+
})));
|
|
3511
|
+
}
|
|
2795
3512
|
function DoublesView() {
|
|
2796
3513
|
const { grants, asks, log } = useDoubles();
|
|
2797
3514
|
const now = Date.now();
|
|
2798
3515
|
const live = grants.filter((grant) => grant.expiresAt > now);
|
|
2799
|
-
const friends = [...new Map(live.map((grant) => [grant.friend, grant.name])).entries()];
|
|
2800
3516
|
const recent = [...log].reverse();
|
|
2801
3517
|
return /* @__PURE__ */ React.createElement("div", {
|
|
2802
3518
|
className: "trm-panel"
|
|
@@ -2811,18 +3527,9 @@ function DoublesView() {
|
|
|
2811
3527
|
ask
|
|
2812
3528
|
})))), /* @__PURE__ */ React.createElement("div", {
|
|
2813
3529
|
className: "trm-panel-label"
|
|
2814
|
-
}, dt("grants")),
|
|
3530
|
+
}, dt("grants")), /* @__PURE__ */ React.createElement("p", {
|
|
2815
3531
|
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", {
|
|
3532
|
+
}, [live.length ? mayLine(live) : dt("noGrants"), dt("grantsInSettings")].join(" · ")), /* @__PURE__ */ React.createElement("div", {
|
|
2826
3533
|
className: "trm-panel-label trm-log-label"
|
|
2827
3534
|
}, /* @__PURE__ */ React.createElement("span", null, dt("logTitle")), recent.length > 0 && /* @__PURE__ */ React.createElement("button", {
|
|
2828
3535
|
type: "button",
|
|
@@ -2841,18 +3548,550 @@ function DoublesView() {
|
|
|
2841
3548
|
entry
|
|
2842
3549
|
})))));
|
|
2843
3550
|
}
|
|
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
|
-
};
|
|
3551
|
+
function listenAsks() {
|
|
3552
|
+
doubles.onAsk = (asks) => {
|
|
3553
|
+
const latest = asks[asks.length - 1];
|
|
3554
|
+
if (latest) {
|
|
3555
|
+
openAsk(latest);
|
|
3556
|
+
}
|
|
3557
|
+
};
|
|
3558
|
+
const stop = doubles.start();
|
|
3559
|
+
return () => {
|
|
3560
|
+
doubles.onAsk = undefined;
|
|
3561
|
+
stop();
|
|
3562
|
+
};
|
|
3563
|
+
}
|
|
3564
|
+
|
|
3565
|
+
// web-src/reply-view.tsx
|
|
3566
|
+
function modeName(mode) {
|
|
3567
|
+
switch (mode) {
|
|
3568
|
+
case "away":
|
|
3569
|
+
return rt("modeAway");
|
|
3570
|
+
case "draft":
|
|
3571
|
+
return rt("modeDraft");
|
|
3572
|
+
case "always":
|
|
3573
|
+
return rt("modeAlways");
|
|
3574
|
+
default:
|
|
3575
|
+
return rt("modeNotify");
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
function modeHint(mode, policy) {
|
|
3579
|
+
switch (mode) {
|
|
3580
|
+
case "away":
|
|
3581
|
+
return rt("modeAwayHint", { n: policy.awayMinutes });
|
|
3582
|
+
case "draft":
|
|
3583
|
+
return rt("modeDraftHint");
|
|
3584
|
+
case "always":
|
|
3585
|
+
return rt("modeAlwaysHint");
|
|
3586
|
+
default:
|
|
3587
|
+
return rt("modeNotifyHint");
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
async function setReply(change) {
|
|
3591
|
+
try {
|
|
3592
|
+
const { reply, quiet } = doubles.get();
|
|
3593
|
+
await pi.storage.set(DoubleKeys.REPLY, change(reply));
|
|
3594
|
+
if (Object.keys(quiet).length) {
|
|
3595
|
+
await pi.storage.set(DoubleKeys.QUIET, {});
|
|
3596
|
+
}
|
|
3597
|
+
} catch (error) {
|
|
3598
|
+
pi.ui.notify(message(error), "error");
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
function ModeSelect({
|
|
3602
|
+
value,
|
|
3603
|
+
onChange,
|
|
3604
|
+
inherit,
|
|
3605
|
+
label
|
|
3606
|
+
}) {
|
|
3607
|
+
return /* @__PURE__ */ React.createElement("select", {
|
|
3608
|
+
className: "trm-field",
|
|
3609
|
+
"aria-label": label,
|
|
3610
|
+
value: value ?? "",
|
|
3611
|
+
onChange: (event) => onChange(ReplyPolicyUtil.isMode(event.target.value) ? event.target.value : undefined)
|
|
3612
|
+
}, inherit && /* @__PURE__ */ React.createElement("option", {
|
|
3613
|
+
value: ""
|
|
3614
|
+
}, rt("modeDefault")), REPLY_MODES.map((mode) => /* @__PURE__ */ React.createElement("option", {
|
|
3615
|
+
key: mode,
|
|
3616
|
+
value: mode
|
|
3617
|
+
}, modeName(mode))));
|
|
3618
|
+
}
|
|
3619
|
+
function ReplyRow({
|
|
3620
|
+
label,
|
|
3621
|
+
value,
|
|
3622
|
+
inherit,
|
|
3623
|
+
onChange
|
|
3624
|
+
}) {
|
|
3625
|
+
const { reply } = useDoubles();
|
|
3626
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3627
|
+
className: "trm-reply-row"
|
|
3628
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3629
|
+
className: "trm-grant-text"
|
|
3630
|
+
}, /* @__PURE__ */ React.createElement("span", null, label), /* @__PURE__ */ React.createElement("span", {
|
|
3631
|
+
className: "trm-note"
|
|
3632
|
+
}, modeHint(value ?? inherit, reply))), /* @__PURE__ */ React.createElement(ModeSelect, {
|
|
3633
|
+
value,
|
|
3634
|
+
inherit,
|
|
3635
|
+
label,
|
|
3636
|
+
onChange
|
|
3637
|
+
}));
|
|
3638
|
+
}
|
|
3639
|
+
function ReplyHere({ room }) {
|
|
3640
|
+
const { reply } = useDoubles();
|
|
3641
|
+
const { friends } = useBook();
|
|
3642
|
+
const peer = DirectUtil.is(room) ? DirectUtil.peer(room) : undefined;
|
|
3643
|
+
const friend = !!peer && !!friends?.some((each) => each.id === peer.id && each.status === "friend");
|
|
3644
|
+
const inherit = peer && reply.people[peer.id]?.reply || (peer && !friend ? reply.strangers : reply.mode);
|
|
3645
|
+
return /* @__PURE__ */ React.createElement(ReplyRow, {
|
|
3646
|
+
label: rt("replyHere"),
|
|
3647
|
+
value: reply.chats[room.id],
|
|
3648
|
+
inherit,
|
|
3649
|
+
onChange: (mode) => void setReply((policy) => ReplyPolicyUtil.set(policy, "chats", room.id, mode))
|
|
3650
|
+
});
|
|
3651
|
+
}
|
|
3652
|
+
function DefaultMode() {
|
|
3653
|
+
const { reply } = useDoubles();
|
|
3654
|
+
return /* @__PURE__ */ React.createElement(ModeSelect, {
|
|
3655
|
+
value: reply.mode,
|
|
3656
|
+
label: rt("replyDefault"),
|
|
3657
|
+
onChange: (mode) => mode && void setReply((policy) => ({ ...policy, mode }))
|
|
3658
|
+
});
|
|
3659
|
+
}
|
|
3660
|
+
function AwayMinutes() {
|
|
3661
|
+
const { reply } = useDoubles();
|
|
3662
|
+
const choices = AWAY_MINUTES.includes(reply.awayMinutes) ? AWAY_MINUTES : [...AWAY_MINUTES, reply.awayMinutes].sort((a, b) => a - b);
|
|
3663
|
+
return /* @__PURE__ */ React.createElement("select", {
|
|
3664
|
+
className: "trm-field",
|
|
3665
|
+
"aria-label": rt("replyAway"),
|
|
3666
|
+
value: reply.awayMinutes,
|
|
3667
|
+
onChange: (event) => void setReply((policy) => ({ ...policy, awayMinutes: Number(event.target.value) }))
|
|
3668
|
+
}, choices.map((n) => /* @__PURE__ */ React.createElement("option", {
|
|
3669
|
+
key: n,
|
|
3670
|
+
value: n
|
|
3671
|
+
}, rt("minutes", { n }))));
|
|
3672
|
+
}
|
|
3673
|
+
function StrangersMode() {
|
|
3674
|
+
const { reply } = useDoubles();
|
|
3675
|
+
return /* @__PURE__ */ React.createElement(ModeSelect, {
|
|
3676
|
+
value: reply.strangers,
|
|
3677
|
+
label: rt("replyStrangers"),
|
|
3678
|
+
onChange: (mode) => mode && void setReply((policy) => ({ ...policy, strangers: mode }))
|
|
3679
|
+
});
|
|
3680
|
+
}
|
|
3681
|
+
var QUIET_DEFAULT = { from: 22 * 60, to: 8 * 60, mode: "draft" };
|
|
3682
|
+
function QuietHours() {
|
|
3683
|
+
const { reply } = useDoubles();
|
|
3684
|
+
const quiet = reply.quiet;
|
|
3685
|
+
const Switch = pi.ui.Switch;
|
|
3686
|
+
const change = (next) => void setReply((policy) => ({ ...policy, quiet: { ...policy.quiet ?? QUIET_DEFAULT, ...next } }));
|
|
3687
|
+
const time = (key, label) => /* @__PURE__ */ React.createElement("input", {
|
|
3688
|
+
className: "trm-field trm-field-time",
|
|
3689
|
+
type: "time",
|
|
3690
|
+
"aria-label": label,
|
|
3691
|
+
value: ReplyPolicyUtil.clock((quiet ?? QUIET_DEFAULT)[key]),
|
|
3692
|
+
onChange: (event) => {
|
|
3693
|
+
const minutes = ReplyPolicyUtil.minutes(event.target.value);
|
|
3694
|
+
if (minutes !== undefined) {
|
|
3695
|
+
change({ [key]: minutes });
|
|
3696
|
+
}
|
|
3697
|
+
}
|
|
3698
|
+
});
|
|
3699
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3700
|
+
className: "trm-quiet-hours"
|
|
3701
|
+
}, /* @__PURE__ */ React.createElement(Switch, {
|
|
3702
|
+
checked: !!quiet,
|
|
3703
|
+
label: rt("replyQuiet"),
|
|
3704
|
+
onChange: (on) => void setReply((policy) => {
|
|
3705
|
+
const { quiet: _was, ...rest } = policy;
|
|
3706
|
+
return on ? { ...rest, quiet: QUIET_DEFAULT } : rest;
|
|
3707
|
+
})
|
|
3708
|
+
}), quiet && /* @__PURE__ */ React.createElement("span", {
|
|
3709
|
+
className: "trm-quiet-line"
|
|
3710
|
+
}, 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, {
|
|
3711
|
+
value: quiet.mode,
|
|
3712
|
+
label: rt("replyQuiet"),
|
|
3713
|
+
onChange: (mode) => mode && change({ mode })
|
|
3714
|
+
})));
|
|
3715
|
+
}
|
|
3716
|
+
function OwnList() {
|
|
3717
|
+
const { reply } = useDoubles();
|
|
3718
|
+
const { rooms: rooms2, friends } = useBook();
|
|
3719
|
+
const Remove = icon("X");
|
|
3720
|
+
const rows = [
|
|
3721
|
+
...Object.entries(reply.people).map(([id, person]) => {
|
|
3722
|
+
const friend = friends?.find((each) => each.id === id);
|
|
3723
|
+
const what = [
|
|
3724
|
+
person.reply ? modeName(person.reply) : "",
|
|
3725
|
+
person.tasks ? `${rt("tasksShort")} ${taskName(person.tasks)}` : "",
|
|
3726
|
+
person.invites ? `${rt("invitesShort")} ${inviteName(person.invites)}` : "",
|
|
3727
|
+
person.moments === false ? rt("momentsHiddenShort") : ""
|
|
3728
|
+
].filter(Boolean);
|
|
3729
|
+
return {
|
|
3730
|
+
key: `p:${id}`,
|
|
3731
|
+
id,
|
|
3732
|
+
name: friend?.name ?? id.slice(0, 6),
|
|
3733
|
+
what: what.join(" · "),
|
|
3734
|
+
open: () => openPersonOf({ id, name: friend?.name ?? id.slice(0, 6) }),
|
|
3735
|
+
reset: () => setReply((policy) => ({ ...policy, people: Object.fromEntries(Object.entries(policy.people).filter(([each]) => each !== id)) }))
|
|
3736
|
+
};
|
|
3737
|
+
}),
|
|
3738
|
+
...Object.entries(reply.chats).flatMap(([id, mode]) => {
|
|
3739
|
+
const room = rooms2?.find((each) => each.id === id && each.status === "member");
|
|
3740
|
+
if (!room) {
|
|
3741
|
+
return [];
|
|
3742
|
+
}
|
|
3743
|
+
const peer = DirectUtil.is(room) ? DirectUtil.peer(room) : undefined;
|
|
3744
|
+
return [
|
|
3745
|
+
{
|
|
3746
|
+
key: `c:${id}`,
|
|
3747
|
+
id: peer?.id ?? id,
|
|
3748
|
+
name: peer?.name ?? room.title,
|
|
3749
|
+
what: modeName(mode),
|
|
3750
|
+
open: undefined,
|
|
3751
|
+
reset: () => setReply((policy) => ReplyPolicyUtil.set(policy, "chats", id, undefined))
|
|
3752
|
+
}
|
|
3753
|
+
];
|
|
3754
|
+
})
|
|
3755
|
+
];
|
|
3756
|
+
if (!rows.length) {
|
|
3757
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
3758
|
+
className: "trm-note"
|
|
3759
|
+
}, rt("replyOwnNone"));
|
|
3760
|
+
}
|
|
3761
|
+
return /* @__PURE__ */ React.createElement("ul", {
|
|
3762
|
+
className: "trm-reply-own"
|
|
3763
|
+
}, rows.map((row) => /* @__PURE__ */ React.createElement("li", {
|
|
3764
|
+
key: row.key,
|
|
3765
|
+
className: "trm-reply-own-row"
|
|
3766
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3767
|
+
type: "button",
|
|
3768
|
+
className: "trm-reply-own-open",
|
|
3769
|
+
disabled: !row.open,
|
|
3770
|
+
onClick: row.open
|
|
3771
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
3772
|
+
id: row.id,
|
|
3773
|
+
name: row.name,
|
|
3774
|
+
size: 24
|
|
3775
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
3776
|
+
className: "trm-ellipsis trm-reply-own-name"
|
|
3777
|
+
}, row.name), /* @__PURE__ */ React.createElement("span", {
|
|
3778
|
+
className: "trm-note trm-ellipsis"
|
|
3779
|
+
}, row.what)), /* @__PURE__ */ React.createElement("button", {
|
|
3780
|
+
type: "button",
|
|
3781
|
+
className: "trm-icon",
|
|
3782
|
+
title: rt("replyOwnRemove"),
|
|
3783
|
+
"aria-label": `${rt("replyOwnRemove")} · ${row.name}`,
|
|
3784
|
+
onClick: () => void row.reset()
|
|
3785
|
+
}, /* @__PURE__ */ React.createElement(Remove, {
|
|
3786
|
+
size: 14
|
|
3787
|
+
})))));
|
|
3788
|
+
}
|
|
3789
|
+
var openPersonOf = () => {
|
|
3790
|
+
return;
|
|
3791
|
+
};
|
|
3792
|
+
function bindPersonOpener(open) {
|
|
3793
|
+
openPersonOf = open;
|
|
3794
|
+
}
|
|
3795
|
+
function Choice({
|
|
3796
|
+
value,
|
|
3797
|
+
options,
|
|
3798
|
+
name,
|
|
3799
|
+
label,
|
|
3800
|
+
onChange
|
|
3801
|
+
}) {
|
|
3802
|
+
return /* @__PURE__ */ React.createElement("select", {
|
|
3803
|
+
className: "trm-field",
|
|
3804
|
+
"aria-label": label,
|
|
3805
|
+
value,
|
|
3806
|
+
onChange: (event) => onChange(event.target.value)
|
|
3807
|
+
}, options.map((option) => /* @__PURE__ */ React.createElement("option", {
|
|
3808
|
+
key: option,
|
|
3809
|
+
value: option
|
|
3810
|
+
}, name(option))));
|
|
3811
|
+
}
|
|
3812
|
+
function taskName(mode) {
|
|
3813
|
+
return mode === "allow" ? rt("taskAllow") : mode === "ask" ? rt("taskAsk") : rt("taskDeny");
|
|
3814
|
+
}
|
|
3815
|
+
function inviteName(mode) {
|
|
3816
|
+
return mode === "join" ? rt("inviteJoin") : mode === "ask" ? rt("inviteAsk") : rt("inviteDeny");
|
|
3817
|
+
}
|
|
3818
|
+
function TasksFriends() {
|
|
3819
|
+
const { reply } = useDoubles();
|
|
3820
|
+
return /* @__PURE__ */ React.createElement(Choice, {
|
|
3821
|
+
value: reply.tasks.friends,
|
|
3822
|
+
options: TASK_MODES,
|
|
3823
|
+
name: taskName,
|
|
3824
|
+
label: rt("tasksFriends"),
|
|
3825
|
+
onChange: (friends) => void setReply((policy) => ({ ...policy, tasks: { ...policy.tasks, friends } }))
|
|
3826
|
+
});
|
|
3827
|
+
}
|
|
3828
|
+
function TasksOthers() {
|
|
3829
|
+
const { reply } = useDoubles();
|
|
3830
|
+
return /* @__PURE__ */ React.createElement(Choice, {
|
|
3831
|
+
value: reply.tasks.strangers,
|
|
3832
|
+
options: TASK_MODES,
|
|
3833
|
+
name: taskName,
|
|
3834
|
+
label: rt("tasksOthers"),
|
|
3835
|
+
onChange: (strangers) => void setReply((policy) => ({ ...policy, tasks: { ...policy.tasks, strangers } }))
|
|
3836
|
+
});
|
|
3837
|
+
}
|
|
3838
|
+
function InvitesAll() {
|
|
3839
|
+
const { reply } = useDoubles();
|
|
3840
|
+
return /* @__PURE__ */ React.createElement(Choice, {
|
|
3841
|
+
value: reply.invites,
|
|
3842
|
+
options: INVITE_MODES,
|
|
3843
|
+
name: inviteName,
|
|
3844
|
+
label: rt("invitesAll"),
|
|
3845
|
+
onChange: (invites) => void setReply((policy) => ({ ...policy, invites }))
|
|
3846
|
+
});
|
|
3847
|
+
}
|
|
3848
|
+
function replySettings() {
|
|
3849
|
+
return {
|
|
3850
|
+
title: () => rt("replyTitle"),
|
|
3851
|
+
icon: icon("MessageCircle"),
|
|
3852
|
+
group: "general",
|
|
3853
|
+
rows: [
|
|
3854
|
+
{ key: "reply-mode", label: () => rt("replyDefault"), description: () => rt("replyLead"), render: DefaultMode },
|
|
3855
|
+
{ key: "reply-away", label: () => rt("replyAway"), description: () => rt("replyAwayHint"), render: AwayMinutes },
|
|
3856
|
+
{ key: "reply-strangers", label: () => rt("replyStrangers"), description: () => rt("replyStrangersHint"), render: StrangersMode },
|
|
3857
|
+
{ key: "reply-quiet", label: () => rt("replyQuiet"), description: () => rt("replyQuietHint"), render: QuietHours, stacked: true },
|
|
3858
|
+
{ key: "tasks-friends", label: () => rt("tasksFriends"), description: () => rt("policyAllHint"), render: TasksFriends },
|
|
3859
|
+
{ key: "tasks-others", label: () => rt("tasksOthers"), render: TasksOthers },
|
|
3860
|
+
{ key: "invites", label: () => rt("invitesAll"), render: InvitesAll },
|
|
3861
|
+
{ key: "reply-own", label: () => rt("replyOwn"), description: () => rt("replyOwnHint"), render: OwnList, stacked: true },
|
|
3862
|
+
{ key: "reply-grants", label: () => dt("grantsTitle"), description: () => dt("grantsHint"), render: GrantList, stacked: true }
|
|
3863
|
+
]
|
|
3864
|
+
};
|
|
3865
|
+
}
|
|
3866
|
+
function DraftCard({ draft }) {
|
|
3867
|
+
const [editing, setEditing] = React.useState();
|
|
3868
|
+
const [busy, setBusy] = React.useState(false);
|
|
3869
|
+
const run = async (send, text) => {
|
|
3870
|
+
setBusy(true);
|
|
3871
|
+
try {
|
|
3872
|
+
await callDoubles(send ? { kind: "sendDraft", draft: draft.id, ...text !== undefined ? { text } : {} } : { kind: "dropDraft", draft: draft.id });
|
|
3873
|
+
} catch (error) {
|
|
3874
|
+
pi.ui.notify(message(error), "error");
|
|
3875
|
+
} finally {
|
|
3876
|
+
setBusy(false);
|
|
3877
|
+
}
|
|
3878
|
+
};
|
|
3879
|
+
const Bot = icon("Bot");
|
|
3880
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3881
|
+
className: `trm-draft${busy ? " ta-pending" : ""}`
|
|
3882
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3883
|
+
className: "trm-draft-head"
|
|
3884
|
+
}, /* @__PURE__ */ React.createElement(Bot, {
|
|
3885
|
+
size: 14
|
|
3886
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
3887
|
+
className: "trm-ellipsis"
|
|
3888
|
+
}, rt("draftTitle", { name: draft.name }))), /* @__PURE__ */ React.createElement("div", {
|
|
3889
|
+
className: "trm-draft-asked trm-ellipsis"
|
|
3890
|
+
}, draft.asked), editing === undefined ? /* @__PURE__ */ React.createElement("div", {
|
|
3891
|
+
className: "trm-draft-text"
|
|
3892
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Markdown, {
|
|
3893
|
+
text: draft.text
|
|
3894
|
+
})) : /* @__PURE__ */ React.createElement("textarea", {
|
|
3895
|
+
className: "trm-draft-edit",
|
|
3896
|
+
value: editing,
|
|
3897
|
+
rows: 3,
|
|
3898
|
+
onChange: (event) => setEditing(event.target.value)
|
|
3899
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
3900
|
+
className: "trm-draft-actions"
|
|
3901
|
+
}, editing === undefined ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("button", {
|
|
3902
|
+
type: "button",
|
|
3903
|
+
className: "ta-button",
|
|
3904
|
+
disabled: busy,
|
|
3905
|
+
onClick: () => void run(false)
|
|
3906
|
+
}, rt("draftDrop")), /* @__PURE__ */ React.createElement("button", {
|
|
3907
|
+
type: "button",
|
|
3908
|
+
className: "ta-button",
|
|
3909
|
+
disabled: busy,
|
|
3910
|
+
onClick: () => setEditing(draft.text)
|
|
3911
|
+
}, rt("draftEdit")), /* @__PURE__ */ React.createElement("button", {
|
|
3912
|
+
type: "button",
|
|
3913
|
+
className: "ta-button ta-primary",
|
|
3914
|
+
disabled: busy,
|
|
3915
|
+
onClick: () => void run(true)
|
|
3916
|
+
}, rt("draftSend"))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("button", {
|
|
3917
|
+
type: "button",
|
|
3918
|
+
className: "ta-button",
|
|
3919
|
+
disabled: busy,
|
|
3920
|
+
onClick: () => setEditing(undefined)
|
|
3921
|
+
}, rt("draftCancel")), /* @__PURE__ */ React.createElement("button", {
|
|
3922
|
+
type: "button",
|
|
3923
|
+
className: "ta-button ta-primary",
|
|
3924
|
+
disabled: busy || !editing.trim(),
|
|
3925
|
+
onClick: () => void run(true, editing)
|
|
3926
|
+
}, rt("draftSave")))));
|
|
3927
|
+
}
|
|
3928
|
+
function Drafts({ room }) {
|
|
3929
|
+
const { drafts } = useDoubles();
|
|
3930
|
+
const mine = drafts.filter((draft) => draft.room === room.id);
|
|
3931
|
+
if (!mine.length) {
|
|
3932
|
+
return null;
|
|
3933
|
+
}
|
|
3934
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3935
|
+
className: "trm-drafts"
|
|
3936
|
+
}, mine.map((draft) => /* @__PURE__ */ React.createElement(DraftCard, {
|
|
3937
|
+
key: draft.id,
|
|
3938
|
+
draft
|
|
3939
|
+
})));
|
|
3940
|
+
}
|
|
3941
|
+
|
|
3942
|
+
// web-src/agents-view.tsx
|
|
3943
|
+
function agentOwner(room, agent) {
|
|
3944
|
+
const owner = room.members.find((member) => member.member === agent.member);
|
|
3945
|
+
return owner?.self ? dt("myAgent") : dt("agentOf", { name: owner?.name ?? "" });
|
|
3946
|
+
}
|
|
3947
|
+
function agentMentions(room, agents) {
|
|
3948
|
+
return agents.map((agent) => ({ name: agent.name, detail: agentOwner(room, agent) }));
|
|
3949
|
+
}
|
|
3950
|
+
function inviteAgent(room, agent) {
|
|
3951
|
+
const self = room.members.find((member) => member.self)?.member;
|
|
3952
|
+
const joining = { id: agent.id, name: agent.name, ...typeof agent.face === "number" ? { face: agent.face } : {} };
|
|
3953
|
+
const chat = book.chat(room.id);
|
|
3954
|
+
const before = new Set(chat?.lines.map((line) => line.id));
|
|
3955
|
+
book.setJoining(room.id, joining, true);
|
|
3956
|
+
callDoubles({ kind: "invite", room: room.id, agent: agent.id }).then(async (list) => {
|
|
3957
|
+
if (self && Array.isArray(list)) {
|
|
3958
|
+
book.putMine(room.id, self, list);
|
|
3959
|
+
}
|
|
3960
|
+
if (chat) {
|
|
3961
|
+
await saidHello(chat, (line) => !before.has(line.id) && line.agent?.id === agent.id && line.from === self);
|
|
3962
|
+
}
|
|
3963
|
+
}).catch((failure) => pi.ui.notify(dt("inviteFailed", { name: agent.name, error: message(failure) }), "error")).finally(() => book.setJoining(room.id, joining, false));
|
|
3964
|
+
}
|
|
3965
|
+
var HELLO_MS = 1e4;
|
|
3966
|
+
function saidHello(chat, hello) {
|
|
3967
|
+
return new Promise((resolve) => {
|
|
3968
|
+
const check = () => {
|
|
3969
|
+
if (chat.lines.some(hello)) {
|
|
3970
|
+
done();
|
|
3971
|
+
}
|
|
3972
|
+
};
|
|
3973
|
+
const stop = chat.subscribe(check);
|
|
3974
|
+
const timer = setTimeout(() => done(), HELLO_MS);
|
|
3975
|
+
const done = () => {
|
|
3976
|
+
stop();
|
|
3977
|
+
clearTimeout(timer);
|
|
3978
|
+
resolve();
|
|
3979
|
+
};
|
|
3980
|
+
check();
|
|
3981
|
+
});
|
|
3982
|
+
}
|
|
3983
|
+
function AgentPicker({ room, close }) {
|
|
3984
|
+
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
3985
|
+
const [agents, setAgents] = React.useState();
|
|
3986
|
+
const [error, setError] = React.useState();
|
|
3987
|
+
const inRoom = useAgents(room);
|
|
3988
|
+
const joining = useJoining(room);
|
|
3989
|
+
const self = room.members.find((member) => member.self)?.member;
|
|
3990
|
+
React.useEffect(() => {
|
|
3991
|
+
callDoubles({ kind: "agents" }).then((list) => setAgents(Array.isArray(list) ? list : []), (failure) => setError(message(failure)));
|
|
3992
|
+
}, []);
|
|
3993
|
+
const invite = (agent) => {
|
|
3994
|
+
inviteAgent(room, agent);
|
|
3995
|
+
close();
|
|
3996
|
+
};
|
|
3997
|
+
const Plus = icon("Plus");
|
|
3998
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
3999
|
+
title: dt("pickAgentTitle", { title: room.title }),
|
|
4000
|
+
onClose: close
|
|
4001
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
4002
|
+
className: "trm-dialog"
|
|
4003
|
+
}, /* @__PURE__ */ React.createElement("p", {
|
|
4004
|
+
className: "trm-note"
|
|
4005
|
+
}, dt("pickAgentLead")), !agents && !error && Loading && /* @__PURE__ */ React.createElement(Loading, null), agents?.length === 0 && /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
4006
|
+
title: dt("noAgents"),
|
|
4007
|
+
hint: dt("noAgentsHint"),
|
|
4008
|
+
compact: true
|
|
4009
|
+
}), agents && agents.length > 0 && /* @__PURE__ */ React.createElement("ul", {
|
|
4010
|
+
className: "trm-rows trm-agent-pick"
|
|
4011
|
+
}, agents.map((agent) => {
|
|
4012
|
+
const joined = inRoom.some((each) => each.id === agent.id && each.member === self);
|
|
4013
|
+
const coming = joining.some((each) => each.id === agent.id);
|
|
4014
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
4015
|
+
key: agent.id
|
|
4016
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
4017
|
+
type: "button",
|
|
4018
|
+
className: "trm-member",
|
|
4019
|
+
disabled: joined || coming,
|
|
4020
|
+
onClick: () => invite(agent)
|
|
4021
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
4022
|
+
id: agent.id,
|
|
4023
|
+
name: agent.name,
|
|
4024
|
+
face: agent.face,
|
|
4025
|
+
size: 34
|
|
4026
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
4027
|
+
className: "trm-member-text"
|
|
4028
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4029
|
+
className: "trm-member-name trm-ellipsis"
|
|
4030
|
+
}, agent.name), /* @__PURE__ */ React.createElement("span", {
|
|
4031
|
+
className: "trm-member-detail trm-ellipsis"
|
|
4032
|
+
}, joined ? dt("inRoom") : coming ? dt("joining") : agent.role)), coming ? /* @__PURE__ */ React.createElement("span", {
|
|
4033
|
+
className: "ta-spinner"
|
|
4034
|
+
}) : !joined && /* @__PURE__ */ React.createElement(Plus, {
|
|
4035
|
+
size: 16
|
|
4036
|
+
})));
|
|
4037
|
+
})), error && /* @__PURE__ */ React.createElement("p", {
|
|
4038
|
+
className: "trm-error"
|
|
4039
|
+
}, error)));
|
|
4040
|
+
}
|
|
4041
|
+
function openAgentPicker(room) {
|
|
4042
|
+
show(({ close }) => /* @__PURE__ */ React.createElement(AgentPicker, {
|
|
4043
|
+
room,
|
|
4044
|
+
close
|
|
4045
|
+
}));
|
|
4046
|
+
}
|
|
4047
|
+
function JoiningRow({ agent }) {
|
|
4048
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
4049
|
+
className: "trm-member",
|
|
4050
|
+
"aria-busy": "true"
|
|
4051
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
4052
|
+
id: agent.id,
|
|
4053
|
+
name: agent.name,
|
|
4054
|
+
face: agent.face,
|
|
4055
|
+
size: 34
|
|
4056
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
4057
|
+
className: "trm-member-text"
|
|
4058
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4059
|
+
className: "trm-member-name trm-ellipsis"
|
|
4060
|
+
}, agent.name), /* @__PURE__ */ React.createElement("span", {
|
|
4061
|
+
className: "trm-member-detail trm-ellipsis"
|
|
4062
|
+
}, dt("joining"))), /* @__PURE__ */ React.createElement("span", {
|
|
4063
|
+
className: "ta-spinner trm-member-action"
|
|
4064
|
+
}));
|
|
4065
|
+
}
|
|
4066
|
+
function AgentRow({ room, agent }) {
|
|
4067
|
+
const Remove = icon("X");
|
|
4068
|
+
const mine = room.members.find((member) => member.self)?.member === agent.member;
|
|
4069
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
4070
|
+
className: "trm-member"
|
|
4071
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
4072
|
+
id: agent.id,
|
|
4073
|
+
name: agent.name,
|
|
4074
|
+
face: agent.face,
|
|
4075
|
+
size: 34
|
|
4076
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
4077
|
+
className: "trm-member-text"
|
|
4078
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4079
|
+
className: "trm-member-name"
|
|
4080
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4081
|
+
className: "trm-ellipsis"
|
|
4082
|
+
}, agent.name), /* @__PURE__ */ React.createElement("span", {
|
|
4083
|
+
className: "trm-tag trm-tag-agent"
|
|
4084
|
+
}, agentOwner(room, agent))), agent.role && /* @__PURE__ */ React.createElement("span", {
|
|
4085
|
+
className: "trm-member-detail trm-ellipsis"
|
|
4086
|
+
}, agent.role)), mine && /* @__PURE__ */ React.createElement("button", {
|
|
4087
|
+
type: "button",
|
|
4088
|
+
className: "trm-icon trm-danger trm-member-action",
|
|
4089
|
+
title: dt("dismiss"),
|
|
4090
|
+
"aria-label": dt("dismiss"),
|
|
4091
|
+
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))
|
|
4092
|
+
}, /* @__PURE__ */ React.createElement(Remove, {
|
|
4093
|
+
size: 15
|
|
4094
|
+
})));
|
|
2856
4095
|
}
|
|
2857
4096
|
|
|
2858
4097
|
// web-src/tasks-view.tsx
|
|
@@ -2960,7 +4199,7 @@ class RoomTaskSource {
|
|
|
2960
4199
|
id: `for:${task.id}`,
|
|
2961
4200
|
title: dt("taskFor", { name: task.name, text: task.text }),
|
|
2962
4201
|
status: listed(task.status, true),
|
|
2963
|
-
detail: task.status === "permission" ? dt("taskNeedsYou") : open ? taskStatusWord(task.status) : oneLine(task.answer ?? task.detail ?? taskStatusWord(task.status)),
|
|
4202
|
+
detail: task.approval ? rt("approveWaiting") : task.status === "permission" ? dt("taskNeedsYou") : open ? taskStatusWord(task.status) : oneLine(task.answer ?? task.detail ?? taskStatusWord(task.status)),
|
|
2964
4203
|
startedAt: task.at,
|
|
2965
4204
|
...task.endedAt && !open ? { endedAt: task.endedAt } : {},
|
|
2966
4205
|
icon: ({ size }) => /* @__PURE__ */ React.createElement(Face, {
|
|
@@ -2970,7 +4209,9 @@ class RoomTaskSource {
|
|
|
2970
4209
|
}),
|
|
2971
4210
|
open: () => {
|
|
2972
4211
|
const ask = state.asks.find((each) => each.friend === task.friend);
|
|
2973
|
-
if (task.
|
|
4212
|
+
if (task.approval) {
|
|
4213
|
+
openApprove(task);
|
|
4214
|
+
} else if (task.status === "permission" && ask) {
|
|
2974
4215
|
openAsk(ask);
|
|
2975
4216
|
} else {
|
|
2976
4217
|
openRoom(task.room, true);
|
|
@@ -3089,6 +4330,10 @@ function leaveRoom(room) {
|
|
|
3089
4330
|
if (room.status !== "member") {
|
|
3090
4331
|
return (rooms()?.leave(room.id) ?? Promise.resolve()).then(() => book.load()).then(() => true);
|
|
3091
4332
|
}
|
|
4333
|
+
if (DirectUtil.is(room)) {
|
|
4334
|
+
const { name } = directPeer(room, book.get().friends);
|
|
4335
|
+
return confirmThen(rt("directDeleteTitle", { name }), room.owner ? rt("directDeleteOwn") : rt("directDeleteOther", { name }), rt("directDelete"), async () => rooms()?.leave(room.id));
|
|
4336
|
+
}
|
|
3092
4337
|
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
4338
|
}
|
|
3094
4339
|
function speaker(line) {
|
|
@@ -3111,6 +4356,23 @@ function RoomHead({ room }) {
|
|
|
3111
4356
|
}, [room.id]);
|
|
3112
4357
|
const page = usePageOf(room);
|
|
3113
4358
|
const online = room.members.filter((member) => member.online).length;
|
|
4359
|
+
const { friends } = useBook();
|
|
4360
|
+
if (DirectUtil.is(room)) {
|
|
4361
|
+
const peer = DirectUtil.peer(room);
|
|
4362
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4363
|
+
className: "trm-room-head"
|
|
4364
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4365
|
+
className: "trm-room-head-title"
|
|
4366
|
+
}, /* @__PURE__ */ React.createElement("strong", {
|
|
4367
|
+
className: "trm-ellipsis"
|
|
4368
|
+
}, directPeer(room, friends).name), /* @__PURE__ */ React.createElement("span", {
|
|
4369
|
+
className: `trm-room-head-sub${room.connected && peer?.online ? "" : " trm-quiet"}`
|
|
4370
|
+
}, !room.connected ? t("connecting") : peer ? peer.online ? t("online") : t("offline") : rt("directWaiting", { name: directPeer(room, friends).name }))), /* @__PURE__ */ React.createElement(MemberFaces, {
|
|
4371
|
+
room,
|
|
4372
|
+
shown,
|
|
4373
|
+
onClick: () => void pi.ui.showView(MEMBERS_VIEW)
|
|
4374
|
+
}));
|
|
4375
|
+
}
|
|
3114
4376
|
return /* @__PURE__ */ React.createElement("div", {
|
|
3115
4377
|
className: "trm-room-head"
|
|
3116
4378
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
@@ -3178,7 +4440,14 @@ function RoomView({ room, head, onBack }) {
|
|
|
3178
4440
|
const personOf = (line) => room.members.find((member) => member.member === line.from)?.name ?? line.name;
|
|
3179
4441
|
const nameOf = (line) => line.agent ? line.agent.name : !line.double ? personOf(line) : line.from === self?.member ? dt("myDouble") : dt("doubleOf", { name: personOf(line) });
|
|
3180
4442
|
const tagOf = (line) => line.agent ? agentOwner(room, { member: line.from }) : line.double ? dt("doubleTag") : "";
|
|
3181
|
-
const
|
|
4443
|
+
const direct = DirectUtil.is(room);
|
|
4444
|
+
const { friends } = useBook();
|
|
4445
|
+
const mentions = React.useMemo(() => [...agentMentions(room, agents), ...direct ? [] : mentionable(room).map((member) => ({ name: member.name, detail: rt("mentionPerson") }))], [room, agents, direct]);
|
|
4446
|
+
React.useEffect(() => {
|
|
4447
|
+
if (direct && room.owner && !DirectUtil.peer(room)) {
|
|
4448
|
+
reinvite(room);
|
|
4449
|
+
}
|
|
4450
|
+
}, [direct, room]);
|
|
3182
4451
|
React.useLayoutEffect(() => {
|
|
3183
4452
|
const element = list.current;
|
|
3184
4453
|
if (element && stuck.current) {
|
|
@@ -3202,8 +4471,8 @@ function RoomView({ room, head, onBack }) {
|
|
|
3202
4471
|
throw new Error(t("connecting"));
|
|
3203
4472
|
}
|
|
3204
4473
|
stuck.current = true;
|
|
3205
|
-
const to = addressed(text, room, agents);
|
|
3206
|
-
await chat.say(text, self, to.length ? { to } : {});
|
|
4474
|
+
const { to, person } = addressed(text, room, agents);
|
|
4475
|
+
await chat.say(text, self, to.length ? { to, ...person ? { person: true } : {} } : {});
|
|
3207
4476
|
};
|
|
3208
4477
|
return /* @__PURE__ */ React.createElement("div", {
|
|
3209
4478
|
className: "trm-room-page"
|
|
@@ -3230,7 +4499,14 @@ function RoomView({ room, head, onBack }) {
|
|
|
3230
4499
|
}
|
|
3231
4500
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
3232
4501
|
className: "trm-chat-col"
|
|
3233
|
-
}, lines.length === 0 && /* @__PURE__ */ React.createElement("div", {
|
|
4502
|
+
}, lines.length === 0 && direct && /* @__PURE__ */ React.createElement("div", {
|
|
4503
|
+
className: "trm-chat-empty"
|
|
4504
|
+
}, /* @__PURE__ */ React.createElement(DirectFace, {
|
|
4505
|
+
room,
|
|
4506
|
+
size: 56
|
|
4507
|
+
}), /* @__PURE__ */ React.createElement("strong", null, rt("directEmpty", { name: directPeer(room, friends).name })), /* @__PURE__ */ React.createElement("span", {
|
|
4508
|
+
className: "trm-chat-hint"
|
|
4509
|
+
}, rt("directHint", { name: directPeer(room, friends).name }))), lines.length === 0 && !direct && /* @__PURE__ */ React.createElement("div", {
|
|
3234
4510
|
className: "trm-chat-empty"
|
|
3235
4511
|
}, /* @__PURE__ */ React.createElement(RoomFace, {
|
|
3236
4512
|
room,
|
|
@@ -3290,15 +4566,176 @@ function RoomView({ room, head, onBack }) {
|
|
|
3290
4566
|
className: "ta-spinner"
|
|
3291
4567
|
}), dt("joiningRoom", { name: agent.name }))))), /* @__PURE__ */ React.createElement("div", {
|
|
3292
4568
|
className: "trm-chat-bottom"
|
|
3293
|
-
}, /* @__PURE__ */ React.createElement(
|
|
4569
|
+
}, /* @__PURE__ */ React.createElement(Drafts, {
|
|
4570
|
+
room
|
|
4571
|
+
}), /* @__PURE__ */ React.createElement(pi.ui.Composer, {
|
|
3294
4572
|
placeholder: t("chatPlaceholder"),
|
|
3295
4573
|
draft: room.id,
|
|
3296
4574
|
onSend: say,
|
|
3297
4575
|
mentions,
|
|
3298
|
-
mentionLabel:
|
|
4576
|
+
mentionLabel: rt("mentionPerson")
|
|
3299
4577
|
})));
|
|
3300
4578
|
}
|
|
3301
4579
|
|
|
4580
|
+
// web-src/person-view.tsx
|
|
4581
|
+
function OwnSelect({
|
|
4582
|
+
value,
|
|
4583
|
+
options,
|
|
4584
|
+
name,
|
|
4585
|
+
inherit,
|
|
4586
|
+
label,
|
|
4587
|
+
onChange
|
|
4588
|
+
}) {
|
|
4589
|
+
return /* @__PURE__ */ React.createElement("select", {
|
|
4590
|
+
className: "trm-field",
|
|
4591
|
+
"aria-label": label,
|
|
4592
|
+
value: value ?? "",
|
|
4593
|
+
onChange: (event) => onChange(event.target.value || undefined)
|
|
4594
|
+
}, /* @__PURE__ */ React.createElement("option", {
|
|
4595
|
+
value: ""
|
|
4596
|
+
}, rt("modeDefault")), options.map((option) => /* @__PURE__ */ React.createElement("option", {
|
|
4597
|
+
key: option,
|
|
4598
|
+
value: option
|
|
4599
|
+
}, name(option))));
|
|
4600
|
+
}
|
|
4601
|
+
function PolicyRow({ label, hint, children }) {
|
|
4602
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4603
|
+
className: "trm-reply-row"
|
|
4604
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4605
|
+
className: "trm-grant-text"
|
|
4606
|
+
}, /* @__PURE__ */ React.createElement("span", null, label), /* @__PURE__ */ React.createElement("span", {
|
|
4607
|
+
className: "trm-note"
|
|
4608
|
+
}, hint)), children);
|
|
4609
|
+
}
|
|
4610
|
+
function PersonPolicy({ person, friend, room }) {
|
|
4611
|
+
const { reply, grants } = useDoubles();
|
|
4612
|
+
const own = reply.people[person.id] ?? {};
|
|
4613
|
+
const replyAll = friend ? reply.mode : reply.strangers;
|
|
4614
|
+
const taskAll = friend ? reply.tasks.friends : reply.tasks.strangers;
|
|
4615
|
+
const work = mayLine(grantsOf(grants, person.id, room?.id));
|
|
4616
|
+
const Key = pi.ui.icons.KeyRound ?? icon("Bot");
|
|
4617
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
4618
|
+
className: "trm-person-policy"
|
|
4619
|
+
}, /* @__PURE__ */ React.createElement(PolicyRow, {
|
|
4620
|
+
label: rt("replyThem", { name: person.name }),
|
|
4621
|
+
hint: modeHint(own.reply ?? replyAll, reply)
|
|
4622
|
+
}, /* @__PURE__ */ React.createElement(ModeSelect, {
|
|
4623
|
+
value: own.reply,
|
|
4624
|
+
inherit: replyAll,
|
|
4625
|
+
label: rt("replyThem", { name: person.name }),
|
|
4626
|
+
onChange: (mode) => void setReply((policy) => ReplyPolicyUtil.setPerson(policy, person.id, "reply", mode))
|
|
4627
|
+
})), /* @__PURE__ */ React.createElement(PolicyRow, {
|
|
4628
|
+
label: rt("workFor"),
|
|
4629
|
+
hint: work || rt("workNone")
|
|
4630
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
4631
|
+
className: "trm-person-work"
|
|
4632
|
+
}, work && /* @__PURE__ */ React.createElement("button", {
|
|
4633
|
+
type: "button",
|
|
4634
|
+
className: "ta-button",
|
|
4635
|
+
onClick: () => void revokeAll(person.id, person.name)
|
|
4636
|
+
}, rt("workStop")), /* @__PURE__ */ React.createElement("button", {
|
|
4637
|
+
type: "button",
|
|
4638
|
+
className: "ta-button",
|
|
4639
|
+
onClick: () => openGrant(person, room)
|
|
4640
|
+
}, /* @__PURE__ */ React.createElement(Key, {
|
|
4641
|
+
size: 14
|
|
4642
|
+
}), rt("workGive")))), /* @__PURE__ */ React.createElement(PolicyRow, {
|
|
4643
|
+
label: rt("tasksFrom"),
|
|
4644
|
+
hint: taskName(own.tasks ?? taskAll)
|
|
4645
|
+
}, /* @__PURE__ */ React.createElement(OwnSelect, {
|
|
4646
|
+
value: own.tasks,
|
|
4647
|
+
options: TASK_MODES,
|
|
4648
|
+
name: taskName,
|
|
4649
|
+
inherit: taskAll,
|
|
4650
|
+
label: rt("tasksFrom"),
|
|
4651
|
+
onChange: (mode) => void setReply((policy) => ReplyPolicyUtil.setPerson(policy, person.id, "tasks", mode))
|
|
4652
|
+
})), friend && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(PolicyRow, {
|
|
4653
|
+
label: rt("invitesFrom"),
|
|
4654
|
+
hint: inviteName(own.invites ?? reply.invites)
|
|
4655
|
+
}, /* @__PURE__ */ React.createElement(OwnSelect, {
|
|
4656
|
+
value: own.invites,
|
|
4657
|
+
options: INVITE_MODES,
|
|
4658
|
+
name: inviteName,
|
|
4659
|
+
inherit: reply.invites,
|
|
4660
|
+
label: rt("invitesFrom"),
|
|
4661
|
+
onChange: (mode) => void setReply((policy) => ReplyPolicyUtil.setPerson(policy, person.id, "invites", mode))
|
|
4662
|
+
})), /* @__PURE__ */ React.createElement(PolicyRow, {
|
|
4663
|
+
label: rt("momentsTo"),
|
|
4664
|
+
hint: own.moments === false ? rt("momentsHidden") : rt("momentsShown")
|
|
4665
|
+
}, /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
4666
|
+
checked: own.moments !== false,
|
|
4667
|
+
label: rt("momentsTo"),
|
|
4668
|
+
onChange: (on) => void setReply((policy) => ReplyPolicyUtil.setPerson(policy, person.id, "moments", on ? undefined : false))
|
|
4669
|
+
}))));
|
|
4670
|
+
}
|
|
4671
|
+
function PersonDialog({ person, room, close }) {
|
|
4672
|
+
const { friends } = useBook();
|
|
4673
|
+
const friend = friends?.find((each) => each.id === person.id);
|
|
4674
|
+
const isFriend = friend?.status === "friend";
|
|
4675
|
+
const line = friend?.status === "adding" ? t("friendAdding") : friend?.online ? t("online") : undefined;
|
|
4676
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
4677
|
+
title: isFriend ? t("friends") : rt("personTitle"),
|
|
4678
|
+
onClose: close
|
|
4679
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
4680
|
+
className: "trm-dialog"
|
|
4681
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
4682
|
+
className: "trm-join"
|
|
4683
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
4684
|
+
id: person.id,
|
|
4685
|
+
name: person.name,
|
|
4686
|
+
size: 56,
|
|
4687
|
+
online: isFriend ? friend.online : undefined
|
|
4688
|
+
}), /* @__PURE__ */ React.createElement("strong", {
|
|
4689
|
+
className: "trm-join-name"
|
|
4690
|
+
}, friend?.name ?? person.name), line && /* @__PURE__ */ React.createElement("p", {
|
|
4691
|
+
className: "trm-lead"
|
|
4692
|
+
}, line)), isFriend && /* @__PURE__ */ React.createElement("button", {
|
|
4693
|
+
type: "button",
|
|
4694
|
+
className: "ta-button ta-primary trm-friend-message",
|
|
4695
|
+
onClick: () => {
|
|
4696
|
+
close();
|
|
4697
|
+
openDirect(friend);
|
|
4698
|
+
}
|
|
4699
|
+
}, rt("message")), /* @__PURE__ */ React.createElement(PersonPolicy, {
|
|
4700
|
+
person,
|
|
4701
|
+
friend: isFriend,
|
|
4702
|
+
room
|
|
4703
|
+
}), friend && /* @__PURE__ */ React.createElement("div", {
|
|
4704
|
+
className: "trm-actions trm-center"
|
|
4705
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
4706
|
+
type: "button",
|
|
4707
|
+
className: "ta-button ta-danger",
|
|
4708
|
+
onClick: () => void confirmThen(t("removeFriendTitle", { name: friend.name }), t("removeFriendHint"), t("removeFriend"), async () => {
|
|
4709
|
+
await rooms()?.removeFriend(friend.id);
|
|
4710
|
+
close();
|
|
4711
|
+
await book.load();
|
|
4712
|
+
})
|
|
4713
|
+
}, rt("removeFriendLong")))));
|
|
4714
|
+
}
|
|
4715
|
+
function openPerson(person, room) {
|
|
4716
|
+
show(({ close }) => /* @__PURE__ */ React.createElement(PersonDialog, {
|
|
4717
|
+
person,
|
|
4718
|
+
room,
|
|
4719
|
+
close
|
|
4720
|
+
}));
|
|
4721
|
+
}
|
|
4722
|
+
bindPersonOpener(openPerson);
|
|
4723
|
+
function personOf(member) {
|
|
4724
|
+
return member.self || member.guest ? undefined : { id: member.id, name: member.name };
|
|
4725
|
+
}
|
|
4726
|
+
function DirectPolicy({ room }) {
|
|
4727
|
+
const { friends } = useBook();
|
|
4728
|
+
const peer = DirectUtil.peer(room);
|
|
4729
|
+
if (!peer) {
|
|
4730
|
+
return null;
|
|
4731
|
+
}
|
|
4732
|
+
return /* @__PURE__ */ React.createElement(PersonPolicy, {
|
|
4733
|
+
person: { id: peer.id, name: peer.name },
|
|
4734
|
+
friend: !!friends?.some((each) => each.id === peer.id && each.status === "friend"),
|
|
4735
|
+
room: { id: room.id, title: room.title }
|
|
4736
|
+
});
|
|
4737
|
+
}
|
|
4738
|
+
|
|
3302
4739
|
// web-src/friends-view.tsx
|
|
3303
4740
|
function isFriendLink(text) {
|
|
3304
4741
|
return RelayHubUtil.is(text) && RelayFriendsUtil.isKind(RelayHubUtil.parse(text).kind);
|
|
@@ -3356,6 +4793,11 @@ function FriendRow({ friend }) {
|
|
|
3356
4793
|
});
|
|
3357
4794
|
return /* @__PURE__ */ React.createElement("li", {
|
|
3358
4795
|
className: "trm-friend"
|
|
4796
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
4797
|
+
type: "button",
|
|
4798
|
+
className: "trm-friend-open",
|
|
4799
|
+
disabled: friend.status !== "friend",
|
|
4800
|
+
onClick: () => void openDirect(friend)
|
|
3359
4801
|
}, /* @__PURE__ */ React.createElement(Face, {
|
|
3360
4802
|
id: friend.id,
|
|
3361
4803
|
name: friend.name,
|
|
@@ -3367,7 +4809,7 @@ function FriendRow({ friend }) {
|
|
|
3367
4809
|
className: "trm-room-name trm-ellipsis"
|
|
3368
4810
|
}, friend.name), friend.status === "adding" && /* @__PURE__ */ React.createElement("span", {
|
|
3369
4811
|
className: "trm-room-preview trm-ellipsis"
|
|
3370
|
-
}, t("friendAdding"))), /* @__PURE__ */ React.createElement("button", {
|
|
4812
|
+
}, t("friendAdding")))), /* @__PURE__ */ React.createElement("button", {
|
|
3371
4813
|
type: "button",
|
|
3372
4814
|
className: "trm-icon trm-danger",
|
|
3373
4815
|
title: t("removeFriend"),
|
|
@@ -3508,52 +4950,11 @@ function openFriendLink(text) {
|
|
|
3508
4950
|
}));
|
|
3509
4951
|
return true;
|
|
3510
4952
|
}
|
|
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
4953
|
function openFriend(id) {
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
}
|
|
4954
|
+
const friend = book.get().friends?.find((each) => each.id === id);
|
|
4955
|
+
if (friend) {
|
|
4956
|
+
openPerson({ id: friend.id, name: friend.name });
|
|
4957
|
+
}
|
|
3557
4958
|
}
|
|
3558
4959
|
function FriendRequestsDialog({ close }) {
|
|
3559
4960
|
const { friendRequests } = useBook();
|
|
@@ -4162,28 +5563,271 @@ function openGroupInvite(invite) {
|
|
|
4162
5563
|
}));
|
|
4163
5564
|
}
|
|
4164
5565
|
|
|
5566
|
+
// web-src/room-rules.ts
|
|
5567
|
+
var ROOM_RULES = ["agents", "doubles", "tasks"];
|
|
5568
|
+
var RoomRulesUtil;
|
|
5569
|
+
((RoomRulesUtil) => {
|
|
5570
|
+
function allows(room, rule) {
|
|
5571
|
+
return room?.rules?.[rule] !== false;
|
|
5572
|
+
}
|
|
5573
|
+
RoomRulesUtil.allows = allows;
|
|
5574
|
+
function approves(room) {
|
|
5575
|
+
return room?.rules?.approve === true;
|
|
5576
|
+
}
|
|
5577
|
+
RoomRulesUtil.approves = approves;
|
|
5578
|
+
function refused(rule, language) {
|
|
5579
|
+
return TaLanguageUtil.pick(language, {
|
|
5580
|
+
agents: {
|
|
5581
|
+
"zh-CN": "群主没有允许在这个群里用智能体",
|
|
5582
|
+
"zh-TW": "群主沒有允許在這個群裡用智慧體",
|
|
5583
|
+
"en-US": "the owner allows no agents in this group chat",
|
|
5584
|
+
"ja-JP": "このグループチャットではグループ主がエージェントを許可していません"
|
|
5585
|
+
},
|
|
5586
|
+
doubles: {
|
|
5587
|
+
"zh-CN": "群主没有允许分身在这个群里代答",
|
|
5588
|
+
"zh-TW": "群主沒有允許分身在這個群裡代答",
|
|
5589
|
+
"en-US": "the owner allows no double to answer in this group chat",
|
|
5590
|
+
"ja-JP": "このグループチャットではグループ主が分身の代理応答を許可していません"
|
|
5591
|
+
},
|
|
5592
|
+
tasks: {
|
|
5593
|
+
"zh-CN": "群主没有允许在这个群里给分身派任务",
|
|
5594
|
+
"zh-TW": "群主沒有允許在這個群裡給分身派任務",
|
|
5595
|
+
"en-US": "the owner allows no tasks for doubles in this group chat",
|
|
5596
|
+
"ja-JP": "このグループチャットではグループ主が分身へのタスクを許可していません"
|
|
5597
|
+
}
|
|
5598
|
+
}[rule]);
|
|
5599
|
+
}
|
|
5600
|
+
RoomRulesUtil.refused = refused;
|
|
5601
|
+
})(RoomRulesUtil ||= {});
|
|
5602
|
+
|
|
5603
|
+
// web-src/rules-i18n.ts
|
|
5604
|
+
var EN4 = {
|
|
5605
|
+
rulesManage: "Manage the group chat",
|
|
5606
|
+
rulesView: "Rules of the group chat",
|
|
5607
|
+
rulesSome: "{n} set",
|
|
5608
|
+
rulesNone: "None",
|
|
5609
|
+
adminTag: "Admin",
|
|
5610
|
+
admins: "Admins",
|
|
5611
|
+
adminsHint: "They let people in, invite and take members out, as you do, also while you are away. At most {n}.",
|
|
5612
|
+
adminsNone: "Members in the group chat with Ta can be made admins.",
|
|
5613
|
+
adminOf: "Admin",
|
|
5614
|
+
adminFull: "At most {n} admins.",
|
|
5615
|
+
rules: "Rules",
|
|
5616
|
+
rulesLead: "For everyone in the group chat; each one’s Ta keeps them. They only forbid: each person may still be stricter for themselves.",
|
|
5617
|
+
rulesOthers: "Set by the owner; everyone’s Ta keeps them.",
|
|
5618
|
+
approve: "Invited friends ask too",
|
|
5619
|
+
approveHint: "Friends you or an admin invite are let in only once one of you agrees",
|
|
5620
|
+
agents: "Agents may be invited",
|
|
5621
|
+
agentsHint: "Members may bring their agents in to help",
|
|
5622
|
+
doubles: "Doubles may answer for people",
|
|
5623
|
+
doublesHint: "When someone is @ed, their double may answer as they set it; off, they are only told",
|
|
5624
|
+
tasks: "Doubles may be handed tasks",
|
|
5625
|
+
tasksHint: "Members may hand each other’s doubles work to do"
|
|
5626
|
+
};
|
|
5627
|
+
var ZH4 = {
|
|
5628
|
+
rulesManage: "群管理",
|
|
5629
|
+
rulesView: "群规",
|
|
5630
|
+
rulesSome: "{n} 项",
|
|
5631
|
+
rulesNone: "无",
|
|
5632
|
+
adminTag: "管理员",
|
|
5633
|
+
admins: "管理员",
|
|
5634
|
+
adminsHint: "可以放人进群、邀请和移出成员,和你一样;你不在时也行。最多 {n} 位。",
|
|
5635
|
+
adminsNone: "群里装了 Ta 的成员可以设为管理员。",
|
|
5636
|
+
adminOf: "管理员",
|
|
5637
|
+
adminFull: "最多 {n} 位管理员。",
|
|
5638
|
+
rules: "群规",
|
|
5639
|
+
rulesLead: "对群里所有人有效,由每个人的 Ta 执行。群规只能禁止,每个人还可以对自己更严。",
|
|
5640
|
+
rulesOthers: "由群主设置,每个人的 Ta 都按这个执行。",
|
|
5641
|
+
approve: "受邀的好友也要同意",
|
|
5642
|
+
approveHint: "你或管理员邀请的好友,也要你们同意后才能进群",
|
|
5643
|
+
agents: "允许邀请智能体",
|
|
5644
|
+
agentsHint: "成员可以请自己的智能体进群帮忙",
|
|
5645
|
+
doubles: "允许分身代答",
|
|
5646
|
+
doublesHint: "有人被 @ 时,他的分身可以按他的设置代答;关掉后只提醒本人",
|
|
5647
|
+
tasks: "允许给分身派任务",
|
|
5648
|
+
tasksHint: "成员之间可以把事情交给对方的分身去做"
|
|
5649
|
+
};
|
|
5650
|
+
var ZH_TW4 = {
|
|
5651
|
+
rulesManage: "群管理",
|
|
5652
|
+
rulesView: "群規",
|
|
5653
|
+
rulesSome: "{n} 項",
|
|
5654
|
+
rulesNone: "無",
|
|
5655
|
+
adminTag: "管理員",
|
|
5656
|
+
admins: "管理員",
|
|
5657
|
+
adminsHint: "可以放人進群、邀請和移出成員,和你一樣;你不在時也行。最多 {n} 位。",
|
|
5658
|
+
adminsNone: "群裡裝了 Ta 的成員可以設為管理員。",
|
|
5659
|
+
adminOf: "管理員",
|
|
5660
|
+
adminFull: "最多 {n} 位管理員。",
|
|
5661
|
+
rules: "群規",
|
|
5662
|
+
rulesLead: "對群裡所有人有效,由每個人的 Ta 執行。群規只能禁止,每個人還可以對自己更嚴。",
|
|
5663
|
+
rulesOthers: "由群主設定,每個人的 Ta 都按這個執行。",
|
|
5664
|
+
approve: "受邀的好友也要同意",
|
|
5665
|
+
approveHint: "你或管理員邀請的好友,也要你們同意後才能進群",
|
|
5666
|
+
agents: "允許邀請智慧體",
|
|
5667
|
+
agentsHint: "成員可以請自己的智慧體進群幫忙",
|
|
5668
|
+
doubles: "允許分身代答",
|
|
5669
|
+
doublesHint: "有人被 @ 時,他的分身可以按他的設定代答;關掉後只提醒本人",
|
|
5670
|
+
tasks: "允許給分身派任務",
|
|
5671
|
+
tasksHint: "成員之間可以把事情交給對方的分身去做"
|
|
5672
|
+
};
|
|
5673
|
+
var JA4 = {
|
|
5674
|
+
rulesManage: "グループ管理",
|
|
5675
|
+
rulesView: "グループのルール",
|
|
5676
|
+
rulesSome: "{n} 件",
|
|
5677
|
+
rulesNone: "なし",
|
|
5678
|
+
adminTag: "管理者",
|
|
5679
|
+
admins: "管理者",
|
|
5680
|
+
adminsHint: "あなたと同じように参加の許可、招待、メンバーの削除ができます。あなたが不在でも可能です。最大 {n} 人。",
|
|
5681
|
+
adminsNone: "Ta を使っているメンバーを管理者にできます。",
|
|
5682
|
+
adminOf: "管理者",
|
|
5683
|
+
adminFull: "管理者は最大 {n} 人です。",
|
|
5684
|
+
rules: "ルール",
|
|
5685
|
+
rulesLead: "グループ全員に適用され、各自の Ta が守ります。ルールは禁止するだけで、各自はさらに厳しくできます。",
|
|
5686
|
+
rulesOthers: "グループ主が設定し、全員の Ta が守ります。",
|
|
5687
|
+
approve: "招待した友だちも承認が必要",
|
|
5688
|
+
approveHint: "あなたや管理者が招待した友だちも、承認されてから参加します",
|
|
5689
|
+
agents: "エージェントの招待を許可",
|
|
5690
|
+
agentsHint: "メンバーは自分のエージェントを招待して手伝わせることができます",
|
|
5691
|
+
doubles: "分身の代理応答を許可",
|
|
5692
|
+
doublesHint: "誰かが @ されたとき、その人の設定どおりに分身が応答できます。オフにすると本人に通知するだけです",
|
|
5693
|
+
tasks: "分身へのタスクを許可",
|
|
5694
|
+
tasksHint: "メンバー同士で相手の分身に作業を任せられます"
|
|
5695
|
+
};
|
|
5696
|
+
var RULES_WORDS = { "zh-CN": ZH4, "zh-TW": ZH_TW4, "en-US": EN4, "ja-JP": JA4 };
|
|
5697
|
+
function gt(key, values = {}) {
|
|
5698
|
+
return TaLanguageUtil.pick(pi.ui.language, RULES_WORDS)[key].replace(/\{(\w+)\}/g, (whole, name) => (name in values) ? String(values[name]) : whole);
|
|
5699
|
+
}
|
|
5700
|
+
|
|
5701
|
+
// web-src/group-rules-view.tsx
|
|
5702
|
+
var ADMINS_MAX = 8;
|
|
5703
|
+
var SWITCHES = [
|
|
5704
|
+
{ rule: "approve", label: () => gt("approve"), hint: () => gt("approveHint") },
|
|
5705
|
+
...ROOM_RULES.map((rule) => ({ rule, label: () => gt(rule), hint: () => gt(`${rule}Hint`) }))
|
|
5706
|
+
];
|
|
5707
|
+
function isOn(room, rule) {
|
|
5708
|
+
return rule === "approve" ? room.rules?.approve === true : room.rules?.[rule] !== false;
|
|
5709
|
+
}
|
|
5710
|
+
function countSet(room) {
|
|
5711
|
+
return SWITCHES.filter(({ rule }) => isOn(room, rule) !== (rule !== "approve")).length;
|
|
5712
|
+
}
|
|
5713
|
+
function GroupRulesRow({ room }) {
|
|
5714
|
+
const Chevron = icon("ChevronRight");
|
|
5715
|
+
const set = countSet(room);
|
|
5716
|
+
if (!room.owner && set === 0) {
|
|
5717
|
+
return null;
|
|
5718
|
+
}
|
|
5719
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
5720
|
+
type: "button",
|
|
5721
|
+
className: "trm-setting",
|
|
5722
|
+
onClick: () => book.set({ sub: { room: room.id, app: "rules" } })
|
|
5723
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5724
|
+
className: "trm-setting-label"
|
|
5725
|
+
}, room.owner ? gt("rulesManage") : gt("rulesView")), /* @__PURE__ */ React.createElement("span", {
|
|
5726
|
+
className: "trm-setting-value trm-ellipsis"
|
|
5727
|
+
}, set ? gt("rulesSome", { n: set }) : gt("rulesNone")), /* @__PURE__ */ React.createElement(Chevron, {
|
|
5728
|
+
size: 15
|
|
5729
|
+
}));
|
|
5730
|
+
}
|
|
5731
|
+
function configure(room, options) {
|
|
5732
|
+
const call = rooms()?.configureRoom(room.id, options);
|
|
5733
|
+
return (call ?? Promise.resolve()).catch((error) => {
|
|
5734
|
+
pi.ui.notify(message(error), "error");
|
|
5735
|
+
throw error;
|
|
5736
|
+
});
|
|
5737
|
+
}
|
|
5738
|
+
function AdminRow({ room, member, admins }) {
|
|
5739
|
+
const on = !!member.admin;
|
|
5740
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
5741
|
+
className: "trm-member"
|
|
5742
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
5743
|
+
id: member.id,
|
|
5744
|
+
name: member.name,
|
|
5745
|
+
size: 30,
|
|
5746
|
+
online: member.online
|
|
5747
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
5748
|
+
className: "trm-member-text"
|
|
5749
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5750
|
+
className: "trm-member-name trm-ellipsis"
|
|
5751
|
+
}, member.name)), /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
5752
|
+
checked: on,
|
|
5753
|
+
label: `${gt("adminOf")} · ${member.name}`,
|
|
5754
|
+
disabled: !on && admins.length >= ADMINS_MAX,
|
|
5755
|
+
onChange: (next) => configure(room, { admins: next ? [...admins, member.member] : admins.filter((id) => id !== member.member) })
|
|
5756
|
+
}));
|
|
5757
|
+
}
|
|
5758
|
+
function GroupRulesView({ room }) {
|
|
5759
|
+
const candidates = room.members.filter((member) => !member.owner && !member.guest && !member.self);
|
|
5760
|
+
const admins = room.members.filter((member) => member.admin).map((member) => member.member);
|
|
5761
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
5762
|
+
className: "trm-rules"
|
|
5763
|
+
}, room.owner && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
5764
|
+
className: "trm-panel-label"
|
|
5765
|
+
}, gt("admins")), /* @__PURE__ */ React.createElement("p", {
|
|
5766
|
+
className: "trm-note trm-panel-note"
|
|
5767
|
+
}, gt("adminsHint", { n: ADMINS_MAX })), candidates.length ? /* @__PURE__ */ React.createElement("ul", {
|
|
5768
|
+
className: "trm-panel-members"
|
|
5769
|
+
}, candidates.map((member) => /* @__PURE__ */ React.createElement(AdminRow, {
|
|
5770
|
+
key: member.member,
|
|
5771
|
+
room,
|
|
5772
|
+
member,
|
|
5773
|
+
admins
|
|
5774
|
+
}))) : /* @__PURE__ */ React.createElement("p", {
|
|
5775
|
+
className: "trm-note trm-panel-note"
|
|
5776
|
+
}, gt("adminsNone")), /* @__PURE__ */ React.createElement("div", {
|
|
5777
|
+
className: "trm-panel-sep"
|
|
5778
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
5779
|
+
className: "trm-panel-label"
|
|
5780
|
+
}, gt("rules")), /* @__PURE__ */ React.createElement("p", {
|
|
5781
|
+
className: "trm-note trm-panel-note"
|
|
5782
|
+
}, room.owner ? gt("rulesLead") : gt("rulesOthers")), SWITCHES.map(({ rule, label, hint }) => /* @__PURE__ */ React.createElement("div", {
|
|
5783
|
+
key: rule,
|
|
5784
|
+
className: "trm-double-switch"
|
|
5785
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
5786
|
+
className: "trm-grant-text"
|
|
5787
|
+
}, /* @__PURE__ */ React.createElement("span", null, label()), /* @__PURE__ */ React.createElement("span", {
|
|
5788
|
+
className: "trm-note"
|
|
5789
|
+
}, hint())), /* @__PURE__ */ React.createElement(pi.ui.Switch, {
|
|
5790
|
+
checked: isOn(room, rule),
|
|
5791
|
+
label: label(),
|
|
5792
|
+
disabled: !room.owner,
|
|
5793
|
+
onChange: (next) => configure(room, { rules: { ...room.rules, [rule]: next } })
|
|
5794
|
+
}))));
|
|
5795
|
+
}
|
|
5796
|
+
|
|
4165
5797
|
// web-src/members-view.tsx
|
|
4166
5798
|
function MemberRow({ room, member }) {
|
|
4167
5799
|
const Remove = icon("X");
|
|
4168
5800
|
const Key = pi.ui.icons.KeyRound ?? icon("Bot");
|
|
4169
|
-
const may = useMayLine(member);
|
|
5801
|
+
const may = useMayLine(member, room.id);
|
|
4170
5802
|
const { friends } = useBook();
|
|
4171
5803
|
const friend = friends?.find((each) => each.id === member.id);
|
|
4172
5804
|
const Add = icon("UserPlus");
|
|
4173
5805
|
const tags = [
|
|
4174
5806
|
member.self ? t("you") : "",
|
|
4175
5807
|
member.owner ? t("owner") : "",
|
|
5808
|
+
member.admin ? gt("adminTag") : "",
|
|
4176
5809
|
member.guest ? t("guestTag") : "",
|
|
4177
5810
|
friend?.status === "friend" ? t("friendTag") : ""
|
|
4178
5811
|
].filter(Boolean);
|
|
4179
5812
|
return /* @__PURE__ */ React.createElement("li", {
|
|
4180
5813
|
className: "trm-member"
|
|
5814
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
5815
|
+
type: "button",
|
|
5816
|
+
className: "trm-member-open",
|
|
5817
|
+
disabled: !personOf(member),
|
|
5818
|
+
"aria-label": member.name,
|
|
5819
|
+
onClick: () => {
|
|
5820
|
+
const person = personOf(member);
|
|
5821
|
+
if (person) {
|
|
5822
|
+
openPerson(person, { id: room.id, title: room.title });
|
|
5823
|
+
}
|
|
5824
|
+
}
|
|
4181
5825
|
}, /* @__PURE__ */ React.createElement(Face, {
|
|
4182
5826
|
id: member.id,
|
|
4183
5827
|
name: member.name,
|
|
4184
5828
|
size: 34,
|
|
4185
5829
|
online: member.online
|
|
4186
|
-
}), /* @__PURE__ */ React.createElement("span", {
|
|
5830
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
4187
5831
|
className: "trm-member-text"
|
|
4188
5832
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
4189
5833
|
className: "trm-member-name"
|
|
@@ -4207,12 +5851,12 @@ function MemberRow({ room, member }) {
|
|
|
4207
5851
|
})), !member.self && !member.guest && /* @__PURE__ */ React.createElement("button", {
|
|
4208
5852
|
type: "button",
|
|
4209
5853
|
className: `trm-icon trm-member-action${may ? " trm-on-icon" : ""}`,
|
|
4210
|
-
title:
|
|
4211
|
-
"aria-label":
|
|
4212
|
-
onClick: () =>
|
|
5854
|
+
title: rt("personPolicy"),
|
|
5855
|
+
"aria-label": `${rt("personPolicy")} · ${member.name}`,
|
|
5856
|
+
onClick: () => openPerson({ id: member.id, name: member.name }, { id: room.id, title: room.title })
|
|
4213
5857
|
}, /* @__PURE__ */ React.createElement(Key, {
|
|
4214
5858
|
size: 15
|
|
4215
|
-
})), room.owner && !member.self && /* @__PURE__ */ React.createElement("button", {
|
|
5859
|
+
})), (room.owner || room.admin && !member.owner && !member.admin) && !member.self && !DirectUtil.is(room) && /* @__PURE__ */ React.createElement("button", {
|
|
4216
5860
|
type: "button",
|
|
4217
5861
|
className: "trm-icon trm-danger trm-member-action",
|
|
4218
5862
|
title: t("remove"),
|
|
@@ -4277,7 +5921,7 @@ function SubPage({ title, onBack, children }) {
|
|
|
4277
5921
|
}, children));
|
|
4278
5922
|
}
|
|
4279
5923
|
function MembersView() {
|
|
4280
|
-
const { identity } = useBook();
|
|
5924
|
+
const { identity, friends } = useBook();
|
|
4281
5925
|
const shownPage = !!pi.ui.useView?.(ROOMS_VIEW)?.shown;
|
|
4282
5926
|
const opened = useOpened();
|
|
4283
5927
|
const room = shownPage ? opened : undefined;
|
|
@@ -4294,6 +5938,14 @@ function MembersView() {
|
|
|
4294
5938
|
}
|
|
4295
5939
|
const pushed = sub?.room === room.id ? sub.app : undefined;
|
|
4296
5940
|
const back = () => book.set({ sub: undefined });
|
|
5941
|
+
if (pushed === "rules") {
|
|
5942
|
+
return /* @__PURE__ */ React.createElement(SubPage, {
|
|
5943
|
+
title: room.owner ? gt("rulesManage") : gt("rulesView"),
|
|
5944
|
+
onBack: back
|
|
5945
|
+
}, /* @__PURE__ */ React.createElement(GroupRulesView, {
|
|
5946
|
+
room
|
|
5947
|
+
}));
|
|
5948
|
+
}
|
|
4297
5949
|
if (pushed === "doubles") {
|
|
4298
5950
|
return /* @__PURE__ */ React.createElement(SubPage, {
|
|
4299
5951
|
title: dt("log"),
|
|
@@ -4314,22 +5966,27 @@ function MembersView() {
|
|
|
4314
5966
|
const Contact = icon("Contact");
|
|
4315
5967
|
const online = room.members.filter((member) => member.online).length;
|
|
4316
5968
|
const self = room.members.find((member) => member.self)?.member;
|
|
5969
|
+
const direct = DirectUtil.is(room);
|
|
5970
|
+
const peerFriend = direct ? friends?.find((each) => each.id === DirectUtil.peer(room)?.id && each.status === "friend") : undefined;
|
|
4317
5971
|
return /* @__PURE__ */ React.createElement("div", {
|
|
4318
5972
|
className: "trm-panel"
|
|
4319
5973
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
4320
5974
|
className: "trm-panel-scroll"
|
|
4321
5975
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
4322
5976
|
className: "trm-panel-top"
|
|
4323
|
-
}, /* @__PURE__ */ React.createElement(
|
|
5977
|
+
}, direct ? /* @__PURE__ */ React.createElement(DirectFace, {
|
|
5978
|
+
room,
|
|
5979
|
+
size: 44
|
|
5980
|
+
}) : /* @__PURE__ */ React.createElement(RoomFace, {
|
|
4324
5981
|
room,
|
|
4325
5982
|
size: 44
|
|
4326
5983
|
}), /* @__PURE__ */ React.createElement("span", {
|
|
4327
5984
|
className: "trm-panel-title"
|
|
4328
5985
|
}, /* @__PURE__ */ React.createElement("strong", {
|
|
4329
5986
|
className: "trm-ellipsis"
|
|
4330
|
-
}, room.title), /* @__PURE__ */ React.createElement("span", {
|
|
5987
|
+
}, direct ? directPeer(room, friends).name : room.title), /* @__PURE__ */ React.createElement("span", {
|
|
4331
5988
|
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", {
|
|
5989
|
+
}, 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
5990
|
className: "trm-panel-label"
|
|
4334
5991
|
}, t("apps")), /* @__PURE__ */ React.createElement(AppTiles, {
|
|
4335
5992
|
room,
|
|
@@ -4338,7 +5995,7 @@ function MembersView() {
|
|
|
4338
5995
|
className: "trm-panel-label"
|
|
4339
5996
|
}, t("membersCount", { n: room.members.length, online })), /* @__PURE__ */ React.createElement("ul", {
|
|
4340
5997
|
className: "trm-panel-members"
|
|
4341
|
-
}, room.owner && !!pi.rooms && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
5998
|
+
}, (room.owner || room.admin) && !direct && !!pi.rooms && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
4342
5999
|
type: "button",
|
|
4343
6000
|
className: "trm-member trm-member-add",
|
|
4344
6001
|
onClick: () => openFriendPicker(room)
|
|
@@ -4352,7 +6009,7 @@ function MembersView() {
|
|
|
4352
6009
|
className: "trm-member-name"
|
|
4353
6010
|
}, t("inviteFriends")), /* @__PURE__ */ React.createElement("span", {
|
|
4354
6011
|
className: "trm-member-detail"
|
|
4355
|
-
}, t("inviteFriendsLine"))))), room.owner && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
6012
|
+
}, t("inviteFriendsLine"))))), (room.owner || room.admin) && !direct && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
4356
6013
|
type: "button",
|
|
4357
6014
|
className: "trm-member trm-member-add",
|
|
4358
6015
|
onClick: () => openInvite(room)
|
|
@@ -4374,7 +6031,9 @@ function MembersView() {
|
|
|
4374
6031
|
className: "trm-panel-label"
|
|
4375
6032
|
}, agents.length ? `${dt("agentsTitle")} · ${agents.length}` : dt("agentsTitle")), /* @__PURE__ */ React.createElement("ul", {
|
|
4376
6033
|
className: "trm-panel-members"
|
|
4377
|
-
},
|
|
6034
|
+
}, !RoomRulesUtil.allows(room, "agents") && /* @__PURE__ */ React.createElement("li", {
|
|
6035
|
+
className: "trm-note trm-panel-note"
|
|
6036
|
+
}, RoomRulesUtil.refused("agents", pi.ui.language)), RoomRulesUtil.allows(room, "agents") && /* @__PURE__ */ React.createElement("li", null, /* @__PURE__ */ React.createElement("button", {
|
|
4378
6037
|
type: "button",
|
|
4379
6038
|
className: "trm-member trm-member-add",
|
|
4380
6039
|
onClick: () => openAgentPicker(room)
|
|
@@ -4397,24 +6056,32 @@ function MembersView() {
|
|
|
4397
6056
|
agent
|
|
4398
6057
|
}))), /* @__PURE__ */ React.createElement("div", {
|
|
4399
6058
|
className: "trm-panel-sep"
|
|
4400
|
-
}), /* @__PURE__ */ React.createElement(
|
|
6059
|
+
}), !direct && /* @__PURE__ */ React.createElement(GroupRulesRow, {
|
|
6060
|
+
room
|
|
6061
|
+
}), direct ? /* @__PURE__ */ React.createElement(DirectPolicy, {
|
|
6062
|
+
room
|
|
6063
|
+
}) : /* @__PURE__ */ React.createElement(ReplyHere, {
|
|
4401
6064
|
room
|
|
4402
6065
|
}), /* @__PURE__ */ React.createElement(SettingRow, {
|
|
4403
6066
|
label: dt("log"),
|
|
4404
6067
|
onClick: () => book.set({ sub: { room: room.id, app: "doubles" } })
|
|
4405
|
-
}), /* @__PURE__ */ React.createElement("div", {
|
|
6068
|
+
}), !direct && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
4406
6069
|
className: "trm-panel-sep"
|
|
4407
6070
|
}), /* @__PURE__ */ React.createElement(SettingRow, {
|
|
4408
6071
|
label: t("me"),
|
|
4409
6072
|
value: identity?.name,
|
|
4410
6073
|
onClick: () => void rename()
|
|
4411
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
6074
|
+
}))), /* @__PURE__ */ React.createElement("div", {
|
|
4412
6075
|
className: "trm-panel-foot"
|
|
4413
6076
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
4414
6077
|
type: "button",
|
|
4415
6078
|
className: "trm-link trm-danger",
|
|
4416
6079
|
onClick: () => void leaveRoom(room).then((left2) => left2 && book.set({ opened: undefined }))
|
|
4417
|
-
}, room.owner ? t("close") : t("leave"))
|
|
6080
|
+
}, direct ? rt("directDelete") : room.owner ? t("close") : t("leave")), peerFriend && /* @__PURE__ */ React.createElement("button", {
|
|
6081
|
+
type: "button",
|
|
6082
|
+
className: "trm-link trm-danger",
|
|
6083
|
+
onClick: () => void confirmThen(t("removeFriendTitle", { name: peerFriend.name }), t("removeFriendHint"), t("removeFriend"), async () => rooms()?.removeFriend(peerFriend.id))
|
|
6084
|
+
}, rt("removeFriendLong"))));
|
|
4418
6085
|
}
|
|
4419
6086
|
|
|
4420
6087
|
// web-src/friend-shares.tsx
|
|
@@ -4509,10 +6176,14 @@ function plain(text) {
|
|
|
4509
6176
|
return text.replace(/```[\s\S]*?(```|$)/g, " ").replace(/[*_~`>#]+/g, "").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\s+/g, " ").trim();
|
|
4510
6177
|
}
|
|
4511
6178
|
function roomPreview(room, last) {
|
|
6179
|
+
const direct = DirectUtil.is(room) && room.status === "member";
|
|
4512
6180
|
if (!last) {
|
|
4513
|
-
return statusLine(room);
|
|
6181
|
+
return direct && !DirectUtil.peer(room) ? rt("directWaiting", { name: directPeer(room, book.get().friends).name }) : direct ? "" : statusLine(room);
|
|
4514
6182
|
}
|
|
4515
6183
|
const self = room.members.find((each) => each.self)?.member;
|
|
6184
|
+
if (direct && !last.agent && !last.double) {
|
|
6185
|
+
return plain(last.text);
|
|
6186
|
+
}
|
|
4516
6187
|
const person = room.members.find((each) => each.member === last.from)?.name ?? last.name;
|
|
4517
6188
|
const name = last.agent?.name ?? (!last.double ? person : last.from === self ? dt("myDouble") : dt("doubleOf", { name: person }));
|
|
4518
6189
|
return last.from === self && !last.agent && !last.double ? plain(last.text) : t("said", { name, text: plain(last.text) });
|
|
@@ -4562,7 +6233,11 @@ function RoomRow({ room, active, seen, openMenu }) {
|
|
|
4562
6233
|
"aria-current": active || undefined,
|
|
4563
6234
|
onClick: (event) => member ? openRoom(room.id) : openMenu(event, menu),
|
|
4564
6235
|
onContextMenu: (event) => openMenu(event, menu)
|
|
4565
|
-
}, /* @__PURE__ */ React.createElement(
|
|
6236
|
+
}, DirectUtil.is(room) ? /* @__PURE__ */ React.createElement(DirectFace, {
|
|
6237
|
+
room,
|
|
6238
|
+
size: 40,
|
|
6239
|
+
unread
|
|
6240
|
+
}) : /* @__PURE__ */ React.createElement(RoomFace, {
|
|
4566
6241
|
room,
|
|
4567
6242
|
unread
|
|
4568
6243
|
}), /* @__PURE__ */ React.createElement("span", {
|
|
@@ -4571,7 +6246,7 @@ function RoomRow({ room, active, seen, openMenu }) {
|
|
|
4571
6246
|
className: "trm-room-line"
|
|
4572
6247
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
4573
6248
|
className: "trm-room-name trm-ellipsis"
|
|
4574
|
-
}, room.title), /* @__PURE__ */ React.createElement("span", {
|
|
6249
|
+
}, DirectUtil.is(room) ? directPeer(room, book.get().friends).name : room.title), /* @__PURE__ */ React.createElement("span", {
|
|
4575
6250
|
className: "trm-room-time"
|
|
4576
6251
|
}, when(lastAt(room)))), /* @__PURE__ */ React.createElement("span", {
|
|
4577
6252
|
className: `trm-room-preview trm-ellipsis${member ? "" : " trm-quiet"}`
|
|
@@ -4579,7 +6254,8 @@ function RoomRow({ room, active, seen, openMenu }) {
|
|
|
4579
6254
|
}
|
|
4580
6255
|
function RoomList({ openMenu }) {
|
|
4581
6256
|
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
4582
|
-
const { identity, rooms: list, requests, groupInvites, opened, seen } = useBook();
|
|
6257
|
+
const { identity, rooms: list, requests, groupInvites: invites, opened, seen } = useBook();
|
|
6258
|
+
const groupInvites = invites.filter((invite) => !DirectUtil.is(invite));
|
|
4583
6259
|
const { asks } = useDoubles();
|
|
4584
6260
|
const sorted = useSorted(list ?? []);
|
|
4585
6261
|
return /* @__PURE__ */ React.createElement("div", {
|
|
@@ -4781,7 +6457,10 @@ var HOME_KEY = "home.rooms";
|
|
|
4781
6457
|
function homeFace(id) {
|
|
4782
6458
|
return function HomeFace({ size }) {
|
|
4783
6459
|
const room = React.useSyncExternalStore((listener) => book.subscribe(listener), () => book.get().rooms?.find((each) => each.id === id));
|
|
4784
|
-
return room ? /* @__PURE__ */ React.createElement(
|
|
6460
|
+
return room ? DirectUtil.is(room) ? /* @__PURE__ */ React.createElement(DirectFace, {
|
|
6461
|
+
room,
|
|
6462
|
+
size
|
|
6463
|
+
}) : /* @__PURE__ */ React.createElement(RoomFace, {
|
|
4785
6464
|
room,
|
|
4786
6465
|
size
|
|
4787
6466
|
}) : null;
|
|
@@ -4806,6 +6485,7 @@ class RoomsHome {
|
|
|
4806
6485
|
};
|
|
4807
6486
|
start() {
|
|
4808
6487
|
const stopBook = book.subscribe(() => this.refresh());
|
|
6488
|
+
const stopDirects = directs.subscribe(() => this.refresh());
|
|
4809
6489
|
const stopShares = this.partners ? FriendShares.subscribe(() => this.refresh()) : () => {
|
|
4810
6490
|
return;
|
|
4811
6491
|
};
|
|
@@ -4817,6 +6497,7 @@ class RoomsHome {
|
|
|
4817
6497
|
this.refresh();
|
|
4818
6498
|
return () => {
|
|
4819
6499
|
stopBook();
|
|
6500
|
+
stopDirects();
|
|
4820
6501
|
stopShares();
|
|
4821
6502
|
stopSharesLoad();
|
|
4822
6503
|
stopStorage();
|
|
@@ -4835,7 +6516,8 @@ class RoomsHome {
|
|
|
4835
6516
|
});
|
|
4836
6517
|
}
|
|
4837
6518
|
refresh() {
|
|
4838
|
-
const { rooms: rooms2 = [], seen, friends, friendRequests, requests
|
|
6519
|
+
const { rooms: rooms2 = [], seen, friends, friendRequests, requests } = book.get();
|
|
6520
|
+
const groupInvites = book.get().groupInvites.filter((invite) => !DirectUtil.is(invite));
|
|
4839
6521
|
const sent = this.partners ? FriendShares.get() : [];
|
|
4840
6522
|
const joined = this.shown || this.partners ? rooms2.filter((room) => room.status === "member") : [];
|
|
4841
6523
|
this.follow(joined);
|
|
@@ -4848,7 +6530,14 @@ class RoomsHome {
|
|
|
4848
6530
|
...groupInvites.map((invite) => invite.room),
|
|
4849
6531
|
...sent.map((share) => `${share.id}/${share.seen ? 1 : 0}`)
|
|
4850
6532
|
].join(",") : "",
|
|
4851
|
-
...rows.map(({ room, lines }) => [
|
|
6533
|
+
...rows.map(({ room, lines }) => [
|
|
6534
|
+
room.id,
|
|
6535
|
+
DirectUtil.is(room) ? directPeer(room, friends).name : room.title,
|
|
6536
|
+
lines.at(-1)?.id ?? "",
|
|
6537
|
+
unseen(room, lines, seen) ? 1 : 0,
|
|
6538
|
+
room.connected ? 1 : 0,
|
|
6539
|
+
room.members.length
|
|
6540
|
+
].join(":"))
|
|
4852
6541
|
].join("|");
|
|
4853
6542
|
if (signature === this.signature) {
|
|
4854
6543
|
return;
|
|
@@ -4872,11 +6561,12 @@ class RoomsHome {
|
|
|
4872
6561
|
face = homeFace(room.id);
|
|
4873
6562
|
this.faces.set(room.id, face);
|
|
4874
6563
|
}
|
|
6564
|
+
const direct = DirectUtil.is(room);
|
|
4875
6565
|
return {
|
|
4876
6566
|
id: room.id,
|
|
4877
|
-
title: room.title,
|
|
6567
|
+
title: direct ? directPeer(room, book.get().friends).name : room.title,
|
|
4878
6568
|
detail: roomPreview(room, lines.at(-1)),
|
|
4879
|
-
icon: icon("Users"),
|
|
6569
|
+
icon: icon(direct ? "MessageCircle" : "Users"),
|
|
4880
6570
|
face,
|
|
4881
6571
|
section: t("roomsTitle"),
|
|
4882
6572
|
...this.partners ? { place: "groups" } : {},
|
|
@@ -4917,7 +6607,7 @@ class RoomsHome {
|
|
|
4917
6607
|
}),
|
|
4918
6608
|
section: t("friends"),
|
|
4919
6609
|
place: "partners",
|
|
4920
|
-
open: () => openFriend(friend.id)
|
|
6610
|
+
open: () => friend.status === "friend" ? void openDirect(friend) : openFriend(friend.id)
|
|
4921
6611
|
};
|
|
4922
6612
|
}
|
|
4923
6613
|
asking(request) {
|
|
@@ -5184,7 +6874,7 @@ button.trm-member { cursor: pointer; }
|
|
|
5184
6874
|
.trm-setting > svg { flex: none; color: var(--ta-muted); }
|
|
5185
6875
|
.trm-setting-label { flex: 1; min-width: 0; }
|
|
5186
6876
|
.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); }
|
|
6877
|
+
.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
6878
|
.trm-panel-foot .trm-link { width: 100%; min-height: 36px; border-radius: 10px; font-weight: 500; }
|
|
5189
6879
|
/* Dialogs */
|
|
5190
6880
|
.trm-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 10px; }
|
|
@@ -5251,6 +6941,41 @@ button.trm-member { cursor: pointer; }
|
|
|
5251
6941
|
.trm-agent-pick .trm-member:disabled .trm-member-detail { color: var(--ta-green); }
|
|
5252
6942
|
.trm-member-may { color: var(--ta-secondary); }
|
|
5253
6943
|
.trm-member-action.trm-on-icon { opacity: 1; color: var(--ta-green); }
|
|
6944
|
+
.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)); }
|
|
6945
|
+
.trm-field-time { width: 96px; }
|
|
6946
|
+
.trm-reply-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; }
|
|
6947
|
+
.trm-reply-row .trm-field { flex: none; max-width: 52%; }
|
|
6948
|
+
.trm-dialog .trm-reply-row { padding: 8px 0; }
|
|
6949
|
+
.trm-friend-message { align-self: stretch; margin: 4px 0; }
|
|
6950
|
+
.trm-person-policy { display: flex; flex-direction: column; }
|
|
6951
|
+
.trm-person-work { display: flex; gap: 6px; flex: none; }
|
|
6952
|
+
.trm-person-work .ta-button { display: inline-flex; align-items: center; gap: 4px; }
|
|
6953
|
+
.trm-member-open { flex: none; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; }
|
|
6954
|
+
.trm-member-open:disabled { cursor: default; }
|
|
6955
|
+
.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; }
|
|
6956
|
+
.trm-friend-open:disabled { cursor: default; }
|
|
6957
|
+
.trm-quiet-hours { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
|
|
6958
|
+
.trm-reply-own:only-child, .trm-quiet-hours + * { align-self: stretch; }
|
|
6959
|
+
.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)); }
|
|
6960
|
+
.trm-reply-own { align-self: stretch; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
6961
|
+
.trm-reply-own-row { display: flex; align-items: center; gap: 8px; min-height: 36px; }
|
|
6962
|
+
.trm-reply-own-name { flex: none; max-width: 40%; }
|
|
6963
|
+
.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; }
|
|
6964
|
+
.trm-reply-own-open:disabled { cursor: default; }
|
|
6965
|
+
.trm-grants { align-self: stretch; width: 100%; max-width: 100%; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
|
|
6966
|
+
.trm-grants .trm-rows, .trm-grants .trm-row { min-width: 0; max-width: 100%; }
|
|
6967
|
+
.trm-grants .trm-row { padding: 6px 0; }
|
|
6968
|
+
.trm-grants .trm-row-line { display: block; }
|
|
6969
|
+
.trm-grants .trm-panel-note { margin: 4px 0 0; align-self: flex-start; }
|
|
6970
|
+
.trm-drafts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
|
|
6971
|
+
.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; }
|
|
6972
|
+
.trm-draft-head { display: flex; align-items: center; gap: 6px; color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
6973
|
+
.trm-draft-head > svg { flex: none; }
|
|
6974
|
+
.trm-draft-asked { color: var(--ta-muted); font-size: calc(12.5px * var(--ta-font-scale)); }
|
|
6975
|
+
.trm-draft-text { font-size: calc(14px * var(--ta-font-scale)); }
|
|
6976
|
+
.trm-draft-text p { margin: 0; }
|
|
6977
|
+
.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; }
|
|
6978
|
+
.trm-draft-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
5254
6979
|
.trm-double-switch, .trm-grant-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; }
|
|
5255
6980
|
.trm-grant-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
|
|
5256
6981
|
.trm-grant-who { display: flex; align-items: center; gap: 12px; }
|
|
@@ -5339,7 +7064,13 @@ function activate(pi2) {
|
|
|
5339
7064
|
order: 79
|
|
5340
7065
|
});
|
|
5341
7066
|
pi2.registerView("add-friend", { title: () => t("addFriend"), icon: icon("UserPlus"), render: AddFriendPage, head: AddFriendHead, navigation: false });
|
|
5342
|
-
pi2.registerView("members", {
|
|
7067
|
+
pi2.registerView("members", {
|
|
7068
|
+
title: () => DirectUtil.is(book.get().rooms?.find((room) => room.id === book.get().opened)) ? rt("chatInfo") : t("membersTitle"),
|
|
7069
|
+
icon: icon("Users"),
|
|
7070
|
+
render: MembersView,
|
|
7071
|
+
location: "panel",
|
|
7072
|
+
order: 90
|
|
7073
|
+
});
|
|
5343
7074
|
pi2.registerView(DOUBLES_VIEW.slice(DOUBLES_VIEW.lastIndexOf("/") + 1), {
|
|
5344
7075
|
title: () => dt("logTitle"),
|
|
5345
7076
|
icon: icon("Bot"),
|
|
@@ -5350,6 +7081,12 @@ function activate(pi2) {
|
|
|
5350
7081
|
if (!partners2) {
|
|
5351
7082
|
pi2.registerSettings(roomsSettings());
|
|
5352
7083
|
}
|
|
7084
|
+
if (pi2.rooms) {
|
|
7085
|
+
pi2.registerSettings(replySettings());
|
|
7086
|
+
}
|
|
7087
|
+
const stopDirects = pi2.rooms ? directs.start() : () => {
|
|
7088
|
+
return;
|
|
7089
|
+
};
|
|
5353
7090
|
const home = new RoomsHome(partners2);
|
|
5354
7091
|
const stopHome = pi2.rooms ? home.start() : () => {
|
|
5355
7092
|
return;
|
|
@@ -5398,6 +7135,7 @@ function activate(pi2) {
|
|
|
5398
7135
|
return () => {
|
|
5399
7136
|
stop?.();
|
|
5400
7137
|
stopAsks();
|
|
7138
|
+
stopDirects();
|
|
5401
7139
|
stopHome();
|
|
5402
7140
|
book.onChange = undefined;
|
|
5403
7141
|
removeStyle();
|