@celljs/ta-moments 4.18.0 → 4.19.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 +16 -0
- package/host/index.mjs +39 -2
- package/package.json +4 -4
- package/web/index.js +696 -109
package/extension/index.mjs
CHANGED
|
@@ -162,6 +162,8 @@ var MomentsBrief;
|
|
|
162
162
|
var TaAccessServer = Symbol("TaAccessServer");
|
|
163
163
|
var TA_SIGN_IN_PATH = "/sign-in";
|
|
164
164
|
var TA_DEVICE_SIGN_IN_PATH = `${TA_SIGN_IN_PATH}/device`;
|
|
165
|
+
// ../ta-protocol/esm/common/account-protocol.js
|
|
166
|
+
var TaAccountServer = Symbol("TaAccountServer");
|
|
165
167
|
// ../ta-protocol/esm/common/delegate-protocol.js
|
|
166
168
|
var TaDelegateUtil;
|
|
167
169
|
(function(TaDelegateUtil2) {
|
|
@@ -1744,6 +1746,7 @@ var Keys;
|
|
|
1744
1746
|
Keys.SHARES = "shares";
|
|
1745
1747
|
Keys.REV = "rev";
|
|
1746
1748
|
Keys.SEEN = "seen";
|
|
1749
|
+
Keys.TALK_SEEN = "talkSeen";
|
|
1747
1750
|
Keys.PICKED = "picked";
|
|
1748
1751
|
Keys.TOLD = "told";
|
|
1749
1752
|
Keys.OUTBOX = "outbox";
|
|
@@ -1958,6 +1961,19 @@ var PostUtil;
|
|
|
1958
1961
|
return posts.sort((a, b) => b.at - a.at);
|
|
1959
1962
|
}
|
|
1960
1963
|
PostUtil.feed = feed;
|
|
1964
|
+
function news(posts, me, since) {
|
|
1965
|
+
const found = [];
|
|
1966
|
+
for (const post of posts) {
|
|
1967
|
+
for (const entry of post.talk) {
|
|
1968
|
+
const others = entry.by.id !== me || !!entry.double;
|
|
1969
|
+
if (entry.at > since && !entry.pending && (post.mine ? others : others && entry.to?.id === me)) {
|
|
1970
|
+
found.push({ post, entry });
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
return found.sort((a, b) => b.entry.at - a.entry.at);
|
|
1975
|
+
}
|
|
1976
|
+
PostUtil.news = news;
|
|
1961
1977
|
})(PostUtil ||= {});
|
|
1962
1978
|
|
|
1963
1979
|
// web-src/server-texts.ts
|
package/host/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// web-src/moments-host.ts
|
|
2
|
-
import { mkdir as mkdir4, readdir as readdir3, readFile as readFile4, writeFile as writeFile3 } from "node:fs/promises";
|
|
3
|
-
import { basename as basename2, join as join5 } from "node:path";
|
|
2
|
+
import { mkdir as mkdir4, readdir as readdir3, readFile as readFile4, rm as rm4, writeFile as writeFile3 } from "node:fs/promises";
|
|
3
|
+
import { basename as basename2, dirname as dirname3, join as join5 } from "node:path";
|
|
4
4
|
|
|
5
5
|
// ../ta-protocol/esm/common/language.js
|
|
6
6
|
var TaLanguageUtil;
|
|
@@ -257,6 +257,8 @@ import { basename, dirname as dirname2, join as join3 } from "node:path";
|
|
|
257
257
|
var TaAccessServer = Symbol("TaAccessServer");
|
|
258
258
|
var TA_SIGN_IN_PATH = "/sign-in";
|
|
259
259
|
var TA_DEVICE_SIGN_IN_PATH = `${TA_SIGN_IN_PATH}/device`;
|
|
260
|
+
// ../ta-protocol/esm/common/account-protocol.js
|
|
261
|
+
var TaAccountServer = Symbol("TaAccountServer");
|
|
260
262
|
// ../ta-protocol/esm/common/delegate-protocol.js
|
|
261
263
|
var TaDelegateUtil;
|
|
262
264
|
(function(TaDelegateUtil2) {
|
|
@@ -1784,6 +1786,7 @@ var Keys;
|
|
|
1784
1786
|
Keys.SHARES = "shares";
|
|
1785
1787
|
Keys.REV = "rev";
|
|
1786
1788
|
Keys.SEEN = "seen";
|
|
1789
|
+
Keys.TALK_SEEN = "talkSeen";
|
|
1787
1790
|
Keys.PICKED = "picked";
|
|
1788
1791
|
Keys.TOLD = "told";
|
|
1789
1792
|
Keys.OUTBOX = "outbox";
|
|
@@ -1994,6 +1997,19 @@ var PostUtil;
|
|
|
1994
1997
|
return posts.sort((a, b) => b.at - a.at);
|
|
1995
1998
|
}
|
|
1996
1999
|
PostUtil.feed = feed;
|
|
2000
|
+
function news(posts, me, since) {
|
|
2001
|
+
const found = [];
|
|
2002
|
+
for (const post of posts) {
|
|
2003
|
+
for (const entry of post.talk) {
|
|
2004
|
+
const others = entry.by.id !== me || !!entry.double;
|
|
2005
|
+
if (entry.at > since && !entry.pending && (post.mine ? others : others && entry.to?.id === me)) {
|
|
2006
|
+
found.push({ post, entry });
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
return found.sort((a, b) => b.entry.at - a.entry.at);
|
|
2011
|
+
}
|
|
2012
|
+
PostUtil.news = news;
|
|
1997
2013
|
})(PostUtil ||= {});
|
|
1998
2014
|
|
|
1999
2015
|
// web-src/server-texts.ts
|
|
@@ -3237,6 +3253,8 @@ class MomentsHostPictures extends MomentsHostBase {
|
|
|
3237
3253
|
}
|
|
3238
3254
|
|
|
3239
3255
|
// web-src/moments-host.ts
|
|
3256
|
+
var COVER = /^data:image\/(jpeg|png|webp);base64,[A-Za-z0-9+/=]+$/;
|
|
3257
|
+
|
|
3240
3258
|
class MomentsHost extends MomentsHostPictures {
|
|
3241
3259
|
start() {
|
|
3242
3260
|
this.listen();
|
|
@@ -3305,6 +3323,25 @@ class MomentsHost extends MomentsHostPictures {
|
|
|
3305
3323
|
posts: posts.sort((a, b) => b.at - a.at)
|
|
3306
3324
|
};
|
|
3307
3325
|
}
|
|
3326
|
+
async cover() {
|
|
3327
|
+
const data = await readFile4(this.coverFile(), "utf8").catch(() => "");
|
|
3328
|
+
return COVER.test(data) ? data : "";
|
|
3329
|
+
}
|
|
3330
|
+
async setCover(data) {
|
|
3331
|
+
const file = this.coverFile();
|
|
3332
|
+
if (data === null) {
|
|
3333
|
+
await rm4(file, { force: true });
|
|
3334
|
+
return;
|
|
3335
|
+
}
|
|
3336
|
+
if (typeof data !== "string" || !COVER.test(data) || data.length > Limits.IMAGE_CHARS) {
|
|
3337
|
+
throw new Error("The cover is not a picture, or too large.");
|
|
3338
|
+
}
|
|
3339
|
+
await mkdir4(dirname3(file), { recursive: true });
|
|
3340
|
+
await writeFile3(file, data);
|
|
3341
|
+
}
|
|
3342
|
+
coverFile() {
|
|
3343
|
+
return join5(this.host.agentDir, "ta-moments", "cover.txt");
|
|
3344
|
+
}
|
|
3308
3345
|
async images(room, post) {
|
|
3309
3346
|
const info = (await this.host.rooms.listRooms()).find((item) => item.id === room);
|
|
3310
3347
|
const owner = info?.members.find((member) => member.owner);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-moments",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.19.0",
|
|
4
4
|
"description": "A pi package for Ta: Moments, what friends made with Ta that one can take and use. Ta drafts a post of what you made and you post it; your Ta friends see it, like it and take it, their Ta reading the code first",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@celljs/ta-protocol": "4.
|
|
31
|
-
"@celljs/ta-relay": "4.
|
|
32
|
-
"@celljs/ta-web": "4.
|
|
30
|
+
"@celljs/ta-protocol": "4.19.0",
|
|
31
|
+
"@celljs/ta-relay": "4.19.0",
|
|
32
|
+
"@celljs/ta-web": "4.19.0",
|
|
33
33
|
"@types/react": "^19.3.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
package/web/index.js
CHANGED
|
@@ -108,8 +108,6 @@ var zh = {
|
|
|
108
108
|
post: "发动态",
|
|
109
109
|
addFriend: "加好友",
|
|
110
110
|
friends: "好友",
|
|
111
|
-
friendsCount: "{n} 位",
|
|
112
|
-
friendsNone: "还没有",
|
|
113
111
|
emptyTitle: "还没有好友",
|
|
114
112
|
emptyHint: "加好友后,你们互相看到对方用 Ta 做出来的东西,也能拿去用。",
|
|
115
113
|
noPosts: "还没有动态",
|
|
@@ -183,15 +181,22 @@ var zh = {
|
|
|
183
181
|
deleteTalkTitle: "删除这条评论?",
|
|
184
182
|
deleteAnswerTitle: "删除 Ta 的这条回答?",
|
|
185
183
|
deleteAnswerBody: "也可以点它回复,补充或纠正。",
|
|
186
|
-
deleteTalk: "删除"
|
|
184
|
+
deleteTalk: "删除",
|
|
185
|
+
more: "更多",
|
|
186
|
+
newMessages: "{n} 条新消息",
|
|
187
|
+
messagesTitle: "消息",
|
|
188
|
+
changeCover: "换封面",
|
|
189
|
+
resetCover: "用默认封面",
|
|
190
|
+
myMoments: "我的动态",
|
|
191
|
+
fullText: "全文",
|
|
192
|
+
collapse: "收起",
|
|
193
|
+
albumEmpty: "还没有发过动态"
|
|
187
194
|
};
|
|
188
195
|
var zhTw = {
|
|
189
196
|
title: "動態",
|
|
190
197
|
post: "發動態",
|
|
191
198
|
addFriend: "加好友",
|
|
192
199
|
friends: "好友",
|
|
193
|
-
friendsCount: "{n} 位",
|
|
194
|
-
friendsNone: "還沒有",
|
|
195
200
|
emptyTitle: "還沒有好友",
|
|
196
201
|
emptyHint: "加好友後,你們互相看到對方用 Ta 做出來的東西,也能拿去用。",
|
|
197
202
|
noPosts: "還沒有動態",
|
|
@@ -265,15 +270,22 @@ var zhTw = {
|
|
|
265
270
|
deleteTalkTitle: "刪除這條評論?",
|
|
266
271
|
deleteAnswerTitle: "刪除 Ta 的這條回答?",
|
|
267
272
|
deleteAnswerBody: "也可以點它回覆,補充或糾正。",
|
|
268
|
-
deleteTalk: "刪除"
|
|
273
|
+
deleteTalk: "刪除",
|
|
274
|
+
more: "更多",
|
|
275
|
+
newMessages: "{n} 則新訊息",
|
|
276
|
+
messagesTitle: "訊息",
|
|
277
|
+
changeCover: "換封面",
|
|
278
|
+
resetCover: "用預設封面",
|
|
279
|
+
myMoments: "我的動態",
|
|
280
|
+
fullText: "全文",
|
|
281
|
+
collapse: "收起",
|
|
282
|
+
albumEmpty: "還沒有發過動態"
|
|
269
283
|
};
|
|
270
284
|
var en = {
|
|
271
285
|
title: "Moments",
|
|
272
286
|
post: "Post",
|
|
273
287
|
addFriend: "Add friend",
|
|
274
288
|
friends: "Friends",
|
|
275
|
-
friendsCount: "{n}",
|
|
276
|
-
friendsNone: "None yet",
|
|
277
289
|
emptyTitle: "No friends yet",
|
|
278
290
|
emptyHint: "Once you add friends, you see what each other makes with Ta, and can take it.",
|
|
279
291
|
noPosts: "No posts yet",
|
|
@@ -347,15 +359,22 @@ var en = {
|
|
|
347
359
|
deleteTalkTitle: "Delete this comment?",
|
|
348
360
|
deleteAnswerTitle: "Delete Ta's answer?",
|
|
349
361
|
deleteAnswerBody: "Or tap it to reply, adding to it or putting it right.",
|
|
350
|
-
deleteTalk: "Delete"
|
|
362
|
+
deleteTalk: "Delete",
|
|
363
|
+
more: "More",
|
|
364
|
+
newMessages: "{n} new messages",
|
|
365
|
+
messagesTitle: "Messages",
|
|
366
|
+
changeCover: "Change the cover",
|
|
367
|
+
resetCover: "Default cover",
|
|
368
|
+
myMoments: "My posts",
|
|
369
|
+
fullText: "More",
|
|
370
|
+
collapse: "Less",
|
|
371
|
+
albumEmpty: "No posts yet"
|
|
351
372
|
};
|
|
352
373
|
var ja = {
|
|
353
374
|
title: "モーメンツ",
|
|
354
375
|
post: "投稿",
|
|
355
376
|
addFriend: "友だちを追加",
|
|
356
377
|
friends: "友だち",
|
|
357
|
-
friendsCount: "{n}",
|
|
358
|
-
friendsNone: "まだありません",
|
|
359
378
|
emptyTitle: "まだ友だちがいません",
|
|
360
379
|
emptyHint: "友だちを追加すると、互いに Ta で作ったものが見えます。",
|
|
361
380
|
noPosts: "まだ投稿がありません",
|
|
@@ -429,7 +448,16 @@ var ja = {
|
|
|
429
448
|
deleteTalkTitle: "このコメントを削除しますか?",
|
|
430
449
|
deleteAnswerTitle: "Ta の回答を削除しますか?",
|
|
431
450
|
deleteAnswerBody: "またはタップして返信し、追加または修正できます。",
|
|
432
|
-
deleteTalk: "削除"
|
|
451
|
+
deleteTalk: "削除",
|
|
452
|
+
more: "その他",
|
|
453
|
+
newMessages: "新着メッセージ {n} 件",
|
|
454
|
+
messagesTitle: "メッセージ",
|
|
455
|
+
changeCover: "カバーを変更",
|
|
456
|
+
resetCover: "デフォルトのカバー",
|
|
457
|
+
myMoments: "自分の投稿",
|
|
458
|
+
fullText: "全文",
|
|
459
|
+
collapse: "閉じる",
|
|
460
|
+
albumEmpty: "まだ投稿がありません"
|
|
433
461
|
};
|
|
434
462
|
var WORDS = { "zh-CN": zh, "zh-TW": zhTw, "en-US": en, "ja-JP": ja };
|
|
435
463
|
var MomentsWords;
|
|
@@ -488,11 +516,18 @@ function useBusy() {
|
|
|
488
516
|
function icon(name, fallback = "Circle") {
|
|
489
517
|
return pi.ui.icons[name] ?? pi.ui.icons[fallback];
|
|
490
518
|
}
|
|
519
|
+
function names(people, me) {
|
|
520
|
+
const words = MomentsWords.of(pi.ui.language);
|
|
521
|
+
const separator = TaLanguageUtil.list(pi.ui.language, ["", ""]).slice(1, -1) || ", ";
|
|
522
|
+
return people.map((person) => person.id === me ? words.me : person.name).join(separator);
|
|
523
|
+
}
|
|
491
524
|
|
|
492
525
|
// ../ta-protocol/esm/common/access-protocol.js
|
|
493
526
|
var TaAccessServer = Symbol("TaAccessServer");
|
|
494
527
|
var TA_SIGN_IN_PATH = "/sign-in";
|
|
495
528
|
var TA_DEVICE_SIGN_IN_PATH = `${TA_SIGN_IN_PATH}/device`;
|
|
529
|
+
// ../ta-protocol/esm/common/account-protocol.js
|
|
530
|
+
var TaAccountServer = Symbol("TaAccountServer");
|
|
496
531
|
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
497
532
|
var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
|
|
498
533
|
var TA_HOST_EVENT = "ta:host";
|
|
@@ -2127,6 +2162,7 @@ var Keys;
|
|
|
2127
2162
|
Keys.SHARES = "shares";
|
|
2128
2163
|
Keys.REV = "rev";
|
|
2129
2164
|
Keys.SEEN = "seen";
|
|
2165
|
+
Keys.TALK_SEEN = "talkSeen";
|
|
2130
2166
|
Keys.PICKED = "picked";
|
|
2131
2167
|
Keys.TOLD = "told";
|
|
2132
2168
|
Keys.OUTBOX = "outbox";
|
|
@@ -2421,6 +2457,9 @@ class MomentsStore {
|
|
|
2421
2457
|
error;
|
|
2422
2458
|
seen = 0;
|
|
2423
2459
|
focus;
|
|
2460
|
+
album;
|
|
2461
|
+
cover;
|
|
2462
|
+
talkSeen;
|
|
2424
2463
|
listeners = new Set;
|
|
2425
2464
|
pictures = new Map;
|
|
2426
2465
|
loading;
|
|
@@ -2434,8 +2473,12 @@ class MomentsStore {
|
|
|
2434
2473
|
if (keys.includes(Keys.SEEN)) {
|
|
2435
2474
|
this.readSeen();
|
|
2436
2475
|
}
|
|
2476
|
+
if (keys.includes(Keys.TALK_SEEN)) {
|
|
2477
|
+
this.readTalkSeen();
|
|
2478
|
+
}
|
|
2437
2479
|
});
|
|
2438
2480
|
this.readSeen();
|
|
2481
|
+
this.readTalkSeen();
|
|
2439
2482
|
this.load();
|
|
2440
2483
|
return () => this.stop?.();
|
|
2441
2484
|
}
|
|
@@ -2477,8 +2520,49 @@ class MomentsStore {
|
|
|
2477
2520
|
}
|
|
2478
2521
|
show(room, post) {
|
|
2479
2522
|
this.focus = `${room}:${post}`;
|
|
2523
|
+
this.album = undefined;
|
|
2524
|
+
this.emit();
|
|
2525
|
+
}
|
|
2526
|
+
openAlbum(person) {
|
|
2527
|
+
this.album = person;
|
|
2528
|
+
this.emit();
|
|
2529
|
+
}
|
|
2530
|
+
async loadCover() {
|
|
2531
|
+
const cover = await pi.callHost("cover").catch(() => "");
|
|
2532
|
+
if (cover !== this.cover) {
|
|
2533
|
+
this.cover = cover;
|
|
2534
|
+
this.emit();
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
async setCover(data) {
|
|
2538
|
+
await pi.callHost("setCover", data);
|
|
2539
|
+
this.cover = data ?? "";
|
|
2480
2540
|
this.emit();
|
|
2481
2541
|
}
|
|
2542
|
+
async markTalkSeen(at) {
|
|
2543
|
+
if (at > (this.talkSeen ?? 0)) {
|
|
2544
|
+
this.talkSeen = at;
|
|
2545
|
+
this.emit();
|
|
2546
|
+
await pi.storage.set(Keys.TALK_SEEN, at).catch(() => {
|
|
2547
|
+
return;
|
|
2548
|
+
});
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
async readTalkSeen() {
|
|
2552
|
+
const kept = await pi.storage.get(Keys.TALK_SEEN).catch(() => {
|
|
2553
|
+
return;
|
|
2554
|
+
});
|
|
2555
|
+
if (typeof kept !== "number") {
|
|
2556
|
+
this.talkSeen = Date.now();
|
|
2557
|
+
this.emit();
|
|
2558
|
+
await pi.storage.set(Keys.TALK_SEEN, this.talkSeen).catch(() => {
|
|
2559
|
+
return;
|
|
2560
|
+
});
|
|
2561
|
+
} else if (kept !== this.talkSeen) {
|
|
2562
|
+
this.talkSeen = kept;
|
|
2563
|
+
this.emit();
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2482
2566
|
async markSeen() {
|
|
2483
2567
|
const latest = Math.max(0, ...(this.state?.posts ?? []).filter((post) => !post.mine).map((post) => post.at));
|
|
2484
2568
|
if (latest > this.seen) {
|
|
@@ -2511,6 +2595,15 @@ var store = new MomentsStore;
|
|
|
2511
2595
|
function useMoments() {
|
|
2512
2596
|
return React.useSyncExternalStore(store.subscribe, store.get);
|
|
2513
2597
|
}
|
|
2598
|
+
function useAlbum() {
|
|
2599
|
+
return React.useSyncExternalStore(store.subscribe, () => store.album);
|
|
2600
|
+
}
|
|
2601
|
+
function useCover() {
|
|
2602
|
+
return React.useSyncExternalStore(store.subscribe, () => store.cover);
|
|
2603
|
+
}
|
|
2604
|
+
function useTalkSeen() {
|
|
2605
|
+
return React.useSyncExternalStore(store.subscribe, () => store.talkSeen);
|
|
2606
|
+
}
|
|
2514
2607
|
function useSeen() {
|
|
2515
2608
|
return React.useSyncExternalStore(store.subscribe, () => store.seen);
|
|
2516
2609
|
}
|
|
@@ -2614,6 +2707,337 @@ function openFriends() {
|
|
|
2614
2707
|
pi.ui.showView(FRIENDS_VIEW).then((shown) => shown || pi.ui.notify(t("noFriendsPage"), "warning"));
|
|
2615
2708
|
}
|
|
2616
2709
|
|
|
2710
|
+
// web-src/cover.tsx
|
|
2711
|
+
function Cover({ person, mine, onFace }) {
|
|
2712
|
+
const cover = useCover();
|
|
2713
|
+
const [menu, openMenu] = pi.ui.useContextMenu();
|
|
2714
|
+
const [busy, run] = useBusy();
|
|
2715
|
+
const input = React.useRef(null);
|
|
2716
|
+
const image = mine ? cover : undefined;
|
|
2717
|
+
const choose = (event) => openMenu(event, [
|
|
2718
|
+
[
|
|
2719
|
+
{ key: "change", label: t("changeCover"), icon: icon("ImagePlus", "Image"), run: () => input.current?.click() },
|
|
2720
|
+
...cover ? [{ key: "reset", label: t("resetCover"), icon: icon("RotateCcw"), run: () => void store.setCover(null).catch(failed) }] : []
|
|
2721
|
+
]
|
|
2722
|
+
]);
|
|
2723
|
+
const picked = (file) => file && void run(async () => {
|
|
2724
|
+
try {
|
|
2725
|
+
await store.setCover((await ImageUtil.compress(file)).data);
|
|
2726
|
+
} catch (error) {
|
|
2727
|
+
failed(error);
|
|
2728
|
+
}
|
|
2729
|
+
});
|
|
2730
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2731
|
+
className: "tmo-cover"
|
|
2732
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
2733
|
+
type: "button",
|
|
2734
|
+
className: `tmo-cover-art${busy ? " tmo-busy" : ""}`,
|
|
2735
|
+
disabled: !mine,
|
|
2736
|
+
"aria-label": mine ? t("changeCover") : undefined,
|
|
2737
|
+
onClick: choose
|
|
2738
|
+
}, image ? /* @__PURE__ */ React.createElement("img", {
|
|
2739
|
+
src: image,
|
|
2740
|
+
alt: ""
|
|
2741
|
+
}) : /* @__PURE__ */ React.createElement("span", {
|
|
2742
|
+
className: "tmo-cover-default"
|
|
2743
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
2744
|
+
className: "tmo-cover-who"
|
|
2745
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
2746
|
+
className: "tmo-cover-name"
|
|
2747
|
+
}, person.name), /* @__PURE__ */ React.createElement("button", {
|
|
2748
|
+
type: "button",
|
|
2749
|
+
className: "tmo-cover-face",
|
|
2750
|
+
"aria-label": person.name,
|
|
2751
|
+
disabled: !onFace,
|
|
2752
|
+
onClick: onFace
|
|
2753
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
2754
|
+
id: person.id,
|
|
2755
|
+
look: person.look,
|
|
2756
|
+
mine,
|
|
2757
|
+
size: 64
|
|
2758
|
+
}))), mine && /* @__PURE__ */ React.createElement("input", {
|
|
2759
|
+
ref: input,
|
|
2760
|
+
type: "file",
|
|
2761
|
+
accept: "image/*",
|
|
2762
|
+
hidden: true,
|
|
2763
|
+
onChange: (event) => {
|
|
2764
|
+
picked(event.currentTarget.files?.[0]);
|
|
2765
|
+
event.currentTarget.value = "";
|
|
2766
|
+
}
|
|
2767
|
+
}), menu);
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
// web-src/post-util.ts
|
|
2771
|
+
var ID = /^[0-9a-f]{8}$/;
|
|
2772
|
+
function text(value, max) {
|
|
2773
|
+
return typeof value === "string" ? value.slice(0, max) : undefined;
|
|
2774
|
+
}
|
|
2775
|
+
function link(value) {
|
|
2776
|
+
return typeof value === "string" && value.length <= 4000 && /^https?:\/\//.test(value) ? value : undefined;
|
|
2777
|
+
}
|
|
2778
|
+
var PostUtil;
|
|
2779
|
+
((PostUtil) => {
|
|
2780
|
+
function newId() {
|
|
2781
|
+
return Array.from(crypto.getRandomValues(new Uint8Array(4)), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
2782
|
+
}
|
|
2783
|
+
PostUtil.newId = newId;
|
|
2784
|
+
function isId(id) {
|
|
2785
|
+
return ID.test(id);
|
|
2786
|
+
}
|
|
2787
|
+
PostUtil.isId = isId;
|
|
2788
|
+
function attach(value) {
|
|
2789
|
+
if (!value || typeof value !== "object") {
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
const raw = value;
|
|
2793
|
+
const title = text(raw.title, Limits.TITLE)?.trim();
|
|
2794
|
+
if (raw.kind === "link") {
|
|
2795
|
+
const url = link(raw.link);
|
|
2796
|
+
return url ? { kind: "link", title: title || url, link: url } : undefined;
|
|
2797
|
+
}
|
|
2798
|
+
const name = text(raw.name, 214)?.trim();
|
|
2799
|
+
if (raw.kind !== "package" || !name) {
|
|
2800
|
+
return;
|
|
2801
|
+
}
|
|
2802
|
+
const source = text(raw.source, 400)?.trim();
|
|
2803
|
+
const shared = link(raw.link);
|
|
2804
|
+
if (!source && !shared) {
|
|
2805
|
+
return;
|
|
2806
|
+
}
|
|
2807
|
+
return {
|
|
2808
|
+
kind: "package",
|
|
2809
|
+
name,
|
|
2810
|
+
title: title || name,
|
|
2811
|
+
...text(raw.summary, 200)?.trim() ? { summary: text(raw.summary, 200)?.trim() } : {},
|
|
2812
|
+
...source ? { source } : {},
|
|
2813
|
+
...shared ? { link: shared } : {}
|
|
2814
|
+
};
|
|
2815
|
+
}
|
|
2816
|
+
PostUtil.attach = attach;
|
|
2817
|
+
function check(value) {
|
|
2818
|
+
if (!value || typeof value !== "object") {
|
|
2819
|
+
return;
|
|
2820
|
+
}
|
|
2821
|
+
const raw = value;
|
|
2822
|
+
const body = text(raw.text, Limits.TEXT) ?? "";
|
|
2823
|
+
if (raw.v !== 1 || typeof raw.at !== "number") {
|
|
2824
|
+
return;
|
|
2825
|
+
}
|
|
2826
|
+
const images = (Array.isArray(raw.images) ? raw.images : []).slice(0, Limits.IMAGES).filter((image) => !!image && typeof image === "object" && [image.w, image.h].every((n) => Number.isInteger(n) && n > 0) && typeof image.thumb === "string" && image.thumb.startsWith("data:image/") && image.thumb.length <= Limits.THUMB_CHARS).map((image) => ({ w: image.w, h: image.h, thumb: image.thumb }));
|
|
2827
|
+
const attached = attach(raw.attach);
|
|
2828
|
+
if (!body.trim() && !images.length && !attached) {
|
|
2829
|
+
return;
|
|
2830
|
+
}
|
|
2831
|
+
return {
|
|
2832
|
+
v: 1,
|
|
2833
|
+
at: raw.at,
|
|
2834
|
+
...typeof raw.until === "number" ? { until: raw.until } : {},
|
|
2835
|
+
text: body,
|
|
2836
|
+
...images.length ? { images } : {},
|
|
2837
|
+
...attached ? { attach: attached } : {},
|
|
2838
|
+
...raw.ask === true ? { ask: true } : {}
|
|
2839
|
+
};
|
|
2840
|
+
}
|
|
2841
|
+
PostUtil.check = check;
|
|
2842
|
+
function parts(data) {
|
|
2843
|
+
const parts2 = [];
|
|
2844
|
+
for (let at = 0;at < data.length; at += Limits.PART_CHARS) {
|
|
2845
|
+
parts2.push(data.slice(at, at + Limits.PART_CHARS));
|
|
2846
|
+
}
|
|
2847
|
+
return parts2;
|
|
2848
|
+
}
|
|
2849
|
+
PostUtil.parts = parts;
|
|
2850
|
+
function isPicture(data, max = Limits.IMAGE_CHARS) {
|
|
2851
|
+
return typeof data === "string" && /^data:image\/(jpeg|png|webp|gif);base64,[A-Za-z0-9+/=]+$/.test(data) && data.length <= max;
|
|
2852
|
+
}
|
|
2853
|
+
PostUtil.isPicture = isPicture;
|
|
2854
|
+
function message2(data) {
|
|
2855
|
+
if (!data || typeof data !== "object") {
|
|
2856
|
+
return;
|
|
2857
|
+
}
|
|
2858
|
+
const raw = data;
|
|
2859
|
+
const post = typeof raw.post === "string" && isId(raw.post) ? raw.post : undefined;
|
|
2860
|
+
const index = Number.isInteger(raw.index) && raw.index >= 0 && raw.index < Limits.IMAGES ? raw.index : undefined;
|
|
2861
|
+
if (!post || index === undefined) {
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
if (raw.t === "ta-moments:want") {
|
|
2865
|
+
return { t: raw.t, post, index };
|
|
2866
|
+
}
|
|
2867
|
+
const max = Math.ceil(Limits.IMAGE_CHARS / Limits.PART_CHARS);
|
|
2868
|
+
if (raw.t === "ta-moments:img" && Number.isInteger(raw.parts) && raw.parts > 0 && raw.parts <= max && Number.isInteger(raw.part) && raw.part >= 0 && raw.part < raw.parts && typeof raw.d === "string" && raw.d.length <= Limits.PART_CHARS) {
|
|
2869
|
+
return { t: raw.t, post, index, part: raw.part, parts: raw.parts, d: raw.d };
|
|
2870
|
+
}
|
|
2871
|
+
return;
|
|
2872
|
+
}
|
|
2873
|
+
PostUtil.message = message2;
|
|
2874
|
+
function keysOf(id, keys) {
|
|
2875
|
+
const own = [`${StateKeys.IMG}${id}:`, `${StateKeys.LIKE}${id}:`, `${StateKeys.TOOK}${id}:`];
|
|
2876
|
+
return [`${StateKeys.POST}${id}`, ...[...keys].filter((key) => own.some((prefix) => key.startsWith(prefix)))];
|
|
2877
|
+
}
|
|
2878
|
+
PostUtil.keysOf = keysOf;
|
|
2879
|
+
function feed({ room, state, me, friends, now }) {
|
|
2880
|
+
const owner = room.members.find((member) => member.owner);
|
|
2881
|
+
if (!owner) {
|
|
2882
|
+
return [];
|
|
2883
|
+
}
|
|
2884
|
+
const online = owner.self || owner.online;
|
|
2885
|
+
const author = { id: owner.id, name: owner.name || room.ownerName, ...owner.look ? { look: owner.look } : {} };
|
|
2886
|
+
const byMember = new Map(room.members.map((member) => [member.member, member]));
|
|
2887
|
+
const self = room.members.find((member) => member.self);
|
|
2888
|
+
const marks = (prefix, id) => {
|
|
2889
|
+
const people = [];
|
|
2890
|
+
let mine = false;
|
|
2891
|
+
for (const [key, value] of Object.entries(state)) {
|
|
2892
|
+
if (!key.startsWith(`${prefix}${id}:`) || !value.value) {
|
|
2893
|
+
continue;
|
|
2894
|
+
}
|
|
2895
|
+
const member = key.slice(prefix.length + id.length + 1);
|
|
2896
|
+
const who = byMember.get(member);
|
|
2897
|
+
if (!who || value.by !== member) {
|
|
2898
|
+
continue;
|
|
2899
|
+
}
|
|
2900
|
+
if (who.member === self?.member) {
|
|
2901
|
+
mine = true;
|
|
2902
|
+
}
|
|
2903
|
+
if (who.id === me || who.id === owner.id || owner.id === me || friends.has(who.id)) {
|
|
2904
|
+
people.push({ id: who.id, name: who.name, ...who.look ? { look: who.look } : {} });
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
return { people, mine };
|
|
2908
|
+
};
|
|
2909
|
+
const posts = [];
|
|
2910
|
+
for (const [key, value] of Object.entries(state)) {
|
|
2911
|
+
const id = key.slice(StateKeys.POST.length);
|
|
2912
|
+
if (!key.startsWith(StateKeys.POST) || !isId(id) || value.by !== owner.member) {
|
|
2913
|
+
continue;
|
|
2914
|
+
}
|
|
2915
|
+
const post = check(value.value);
|
|
2916
|
+
if (!post || post.until !== undefined && post.until <= now) {
|
|
2917
|
+
continue;
|
|
2918
|
+
}
|
|
2919
|
+
const likes = marks(StateKeys.LIKE, id);
|
|
2920
|
+
const took = marks(StateKeys.TOOK, id);
|
|
2921
|
+
posts.push({
|
|
2922
|
+
room: room.id,
|
|
2923
|
+
id,
|
|
2924
|
+
author,
|
|
2925
|
+
mine: owner.id === me,
|
|
2926
|
+
online,
|
|
2927
|
+
at: post.at,
|
|
2928
|
+
...post.until !== undefined ? { until: post.until } : {},
|
|
2929
|
+
text: post.text,
|
|
2930
|
+
images: post.images ?? [],
|
|
2931
|
+
...post.attach ? { attach: post.attach } : {},
|
|
2932
|
+
likes: likes.people,
|
|
2933
|
+
liked: likes.mine,
|
|
2934
|
+
took: took.people,
|
|
2935
|
+
tookByMe: took.mine,
|
|
2936
|
+
...post.ask && owner.id !== me ? { ask: true } : {},
|
|
2937
|
+
talk: []
|
|
2938
|
+
});
|
|
2939
|
+
}
|
|
2940
|
+
return posts.sort((a, b) => b.at - a.at);
|
|
2941
|
+
}
|
|
2942
|
+
PostUtil.feed = feed;
|
|
2943
|
+
function news(posts, me, since) {
|
|
2944
|
+
const found = [];
|
|
2945
|
+
for (const post of posts) {
|
|
2946
|
+
for (const entry of post.talk) {
|
|
2947
|
+
const others = entry.by.id !== me || !!entry.double;
|
|
2948
|
+
if (entry.at > since && !entry.pending && (post.mine ? others : others && entry.to?.id === me)) {
|
|
2949
|
+
found.push({ post, entry });
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
return found.sort((a, b) => b.entry.at - a.entry.at);
|
|
2954
|
+
}
|
|
2955
|
+
PostUtil.news = news;
|
|
2956
|
+
})(PostUtil ||= {});
|
|
2957
|
+
|
|
2958
|
+
// web-src/news.tsx
|
|
2959
|
+
function PostPreview({ post }) {
|
|
2960
|
+
const [image, setImage] = React.useState();
|
|
2961
|
+
React.useEffect(() => {
|
|
2962
|
+
let live = true;
|
|
2963
|
+
if (post.images.length) {
|
|
2964
|
+
store.images(post.room, post.id).then((list) => live && setImage(list[0] || post.images[0]?.thumb));
|
|
2965
|
+
}
|
|
2966
|
+
return () => {
|
|
2967
|
+
live = false;
|
|
2968
|
+
};
|
|
2969
|
+
}, [post.room, post.id, post.images]);
|
|
2970
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
2971
|
+
className: "tmo-news-post"
|
|
2972
|
+
}, post.images.length ? image && /* @__PURE__ */ React.createElement("img", {
|
|
2973
|
+
src: image,
|
|
2974
|
+
alt: ""
|
|
2975
|
+
}) : /* @__PURE__ */ React.createElement("span", null, post.text || post.attach?.title));
|
|
2976
|
+
}
|
|
2977
|
+
function newsDialog(news, me, now) {
|
|
2978
|
+
return function NewsDialog({ close }) {
|
|
2979
|
+
const words2 = MomentsWords.of(pi.ui.language);
|
|
2980
|
+
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
2981
|
+
title: t("messagesTitle"),
|
|
2982
|
+
onClose: close
|
|
2983
|
+
}, /* @__PURE__ */ React.createElement("ul", {
|
|
2984
|
+
className: "tmo-rows tmo-news-list"
|
|
2985
|
+
}, news.map(({ post, entry }) => /* @__PURE__ */ React.createElement("li", {
|
|
2986
|
+
key: `${post.room}:${post.id}:${entry.id}`
|
|
2987
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
2988
|
+
type: "button",
|
|
2989
|
+
className: "tmo-row tmo-news-row",
|
|
2990
|
+
onClick: () => {
|
|
2991
|
+
close();
|
|
2992
|
+
store.show(post.room, post.id);
|
|
2993
|
+
}
|
|
2994
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
2995
|
+
id: entry.by.id,
|
|
2996
|
+
look: entry.by.look,
|
|
2997
|
+
mine: entry.by.id === me,
|
|
2998
|
+
size: 40
|
|
2999
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
3000
|
+
className: "tmo-row-text"
|
|
3001
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3002
|
+
className: "tmo-news-name"
|
|
3003
|
+
}, entry.double ? t("theirTa", { name: names([entry.by], me) }) : entry.by.name), /* @__PURE__ */ React.createElement("span", {
|
|
3004
|
+
className: "tmo-news-text"
|
|
3005
|
+
}, entry.text), /* @__PURE__ */ React.createElement("span", {
|
|
3006
|
+
className: "tmo-row-line"
|
|
3007
|
+
}, MomentsWords.ago(words2, entry.at, now, pi.ui.language))), /* @__PURE__ */ React.createElement(PostPreview, {
|
|
3008
|
+
post
|
|
3009
|
+
}))))));
|
|
3010
|
+
};
|
|
3011
|
+
}
|
|
3012
|
+
function News({ posts, me, now, people }) {
|
|
3013
|
+
const since = useTalkSeen();
|
|
3014
|
+
if (since === undefined) {
|
|
3015
|
+
return null;
|
|
3016
|
+
}
|
|
3017
|
+
const looks = new Map(people.map((person) => [person.id, person.look]));
|
|
3018
|
+
const news = PostUtil.news(posts, me, since).map(({ post, entry }) => ({
|
|
3019
|
+
post,
|
|
3020
|
+
entry: { ...entry, by: { ...entry.by, look: entry.by.look ?? looks.get(entry.by.id) } }
|
|
3021
|
+
}));
|
|
3022
|
+
if (!news.length) {
|
|
3023
|
+
return null;
|
|
3024
|
+
}
|
|
3025
|
+
const latest = news[0].entry.by;
|
|
3026
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
3027
|
+
type: "button",
|
|
3028
|
+
className: "tmo-news",
|
|
3029
|
+
onClick: () => {
|
|
3030
|
+
show(newsDialog(news, me, now));
|
|
3031
|
+
store.markTalkSeen(news[0].entry.at);
|
|
3032
|
+
}
|
|
3033
|
+
}, /* @__PURE__ */ React.createElement(Face, {
|
|
3034
|
+
id: latest.id,
|
|
3035
|
+
look: latest.look,
|
|
3036
|
+
mine: latest.id === me,
|
|
3037
|
+
size: 28
|
|
3038
|
+
}), /* @__PURE__ */ React.createElement("span", null, t("newMessages", { n: news.length })));
|
|
3039
|
+
}
|
|
3040
|
+
|
|
2617
3041
|
// web-src/page.tsx
|
|
2618
3042
|
function ComposeDialog({ close }) {
|
|
2619
3043
|
return /* @__PURE__ */ React.createElement(pi.ui.Dialog, {
|
|
@@ -2633,7 +3057,17 @@ function ComposeDialog({ close }) {
|
|
|
2633
3057
|
}));
|
|
2634
3058
|
}
|
|
2635
3059
|
function MomentsHead() {
|
|
3060
|
+
const state = useMoments();
|
|
3061
|
+
const album = useAlbum();
|
|
3062
|
+
if (album) {
|
|
3063
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3064
|
+
className: "tmo-head"
|
|
3065
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3066
|
+
className: "tmo-head-title"
|
|
3067
|
+
}, album.id === state?.me.id ? t("myMoments") : album.name));
|
|
3068
|
+
}
|
|
2636
3069
|
const Post = icon("Aperture", "Plus");
|
|
3070
|
+
const Friends = icon("Users");
|
|
2637
3071
|
return /* @__PURE__ */ React.createElement("div", {
|
|
2638
3072
|
className: "tmo-head"
|
|
2639
3073
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
@@ -2641,6 +3075,16 @@ function MomentsHead() {
|
|
|
2641
3075
|
}, t("title")), /* @__PURE__ */ React.createElement("div", {
|
|
2642
3076
|
className: "tmo-head-end"
|
|
2643
3077
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
3078
|
+
type: "button",
|
|
3079
|
+
className: "tmo-icon-button",
|
|
3080
|
+
"aria-label": t("friends"),
|
|
3081
|
+
title: t("friends"),
|
|
3082
|
+
onClick: openFriends
|
|
3083
|
+
}, Friends && /* @__PURE__ */ React.createElement(Friends, {
|
|
3084
|
+
size: 18
|
|
3085
|
+
}), state?.asking ? /* @__PURE__ */ React.createElement("i", {
|
|
3086
|
+
className: "tmo-icon-dot"
|
|
3087
|
+
}) : null), /* @__PURE__ */ React.createElement("button", {
|
|
2644
3088
|
type: "button",
|
|
2645
3089
|
className: "tmo-icon-button",
|
|
2646
3090
|
"aria-label": t("post"),
|
|
@@ -2790,11 +3234,6 @@ function AttachCard({ post, attach }) {
|
|
|
2790
3234
|
className: `ta-spinner ta-busy-mark${post.tookByMe ? "" : " ta-on-brand"}`
|
|
2791
3235
|
}), /* @__PURE__ */ React.createElement("span", null, label)));
|
|
2792
3236
|
}
|
|
2793
|
-
function names(people, me) {
|
|
2794
|
-
const words2 = MomentsWords.of(pi.ui.language);
|
|
2795
|
-
const separator = TaLanguageUtil.list(pi.ui.language, ["", ""]).slice(1, -1) || ", ";
|
|
2796
|
-
return people.map((person) => person.id === me ? words2.me : person.name).join(separator);
|
|
2797
|
-
}
|
|
2798
3237
|
function TalkLine({ post, entry, me, onReply }) {
|
|
2799
3238
|
const own = entry.by.id === me && !entry.double;
|
|
2800
3239
|
const answer = entry.double && post.mine;
|
|
@@ -2843,8 +3282,8 @@ function TalkBox({ post, writing, close }) {
|
|
|
2843
3282
|
key: `${writing.ask ? "ask" : "say"}:${writing.to?.id ?? ""}`,
|
|
2844
3283
|
placeholder,
|
|
2845
3284
|
draft: `${post.id}:${writing.ask ? "ask" : "say"}:${writing.to?.id ?? ""}`,
|
|
2846
|
-
onSend: async (
|
|
2847
|
-
await pi.callHost("say", post.room, post.id,
|
|
3285
|
+
onSend: async (text2) => {
|
|
3286
|
+
await pi.callHost("say", post.room, post.id, text2, { ...writing.to ? { to: writing.to.id } : {}, ...writing.ask ? { ask: true } : {} });
|
|
2848
3287
|
close();
|
|
2849
3288
|
await store.load();
|
|
2850
3289
|
}
|
|
@@ -2854,46 +3293,140 @@ function TalkBox({ post, writing, close }) {
|
|
|
2854
3293
|
onClick: close
|
|
2855
3294
|
}, t("cancel")));
|
|
2856
3295
|
}
|
|
2857
|
-
function
|
|
3296
|
+
function PostText({ text: text2 }) {
|
|
3297
|
+
const ref = React.useRef(null);
|
|
3298
|
+
const [long, setLong] = React.useState(false);
|
|
3299
|
+
const [open, setOpen] = React.useState(false);
|
|
3300
|
+
React.useLayoutEffect(() => {
|
|
3301
|
+
const element = ref.current;
|
|
3302
|
+
if (element && !open) {
|
|
3303
|
+
setLong(element.scrollHeight > element.clientHeight + 1);
|
|
3304
|
+
}
|
|
3305
|
+
}, [text2, open]);
|
|
3306
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
3307
|
+
ref,
|
|
3308
|
+
className: `tmo-text${open ? "" : " tmo-clamp"}`
|
|
3309
|
+
}, text2), long && /* @__PURE__ */ React.createElement("button", {
|
|
3310
|
+
type: "button",
|
|
3311
|
+
className: "tmo-fold",
|
|
3312
|
+
onClick: () => setOpen(!open)
|
|
3313
|
+
}, open ? t("collapse") : t("fullText")));
|
|
3314
|
+
}
|
|
3315
|
+
function Actions({ post, liking, onLike, onComment, onAsk }) {
|
|
3316
|
+
const [open, setOpen] = React.useState(false);
|
|
3317
|
+
const ref = React.useRef(null);
|
|
3318
|
+
pi.ui.useBackLayer?.(open, () => setOpen(false));
|
|
3319
|
+
React.useEffect(() => {
|
|
3320
|
+
if (!open) {
|
|
3321
|
+
return;
|
|
3322
|
+
}
|
|
3323
|
+
const away = (event) => {
|
|
3324
|
+
if (!ref.current?.contains(event.target)) {
|
|
3325
|
+
setOpen(false);
|
|
3326
|
+
}
|
|
3327
|
+
};
|
|
3328
|
+
document.addEventListener("pointerdown", away, true);
|
|
3329
|
+
return () => document.removeEventListener("pointerdown", away, true);
|
|
3330
|
+
}, [open]);
|
|
3331
|
+
const Heart = icon("Heart");
|
|
3332
|
+
const Comment = icon("MessageCircle");
|
|
3333
|
+
const Spark = icon("Sparkles");
|
|
3334
|
+
const pick = (action2) => () => {
|
|
3335
|
+
setOpen(false);
|
|
3336
|
+
action2();
|
|
3337
|
+
};
|
|
3338
|
+
const tab = open ? 0 : -1;
|
|
3339
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3340
|
+
className: "tmo-actions",
|
|
3341
|
+
ref
|
|
3342
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3343
|
+
className: `tmo-actions-pop${open ? " tmo-open" : ""}`,
|
|
3344
|
+
role: "menu",
|
|
3345
|
+
"aria-hidden": !open
|
|
3346
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3347
|
+
type: "button",
|
|
3348
|
+
role: "menuitem",
|
|
3349
|
+
tabIndex: tab,
|
|
3350
|
+
disabled: liking,
|
|
3351
|
+
className: post.liked ? "tmo-liked" : "",
|
|
3352
|
+
onClick: pick(onLike)
|
|
3353
|
+
}, Heart && /* @__PURE__ */ React.createElement(Heart, {
|
|
3354
|
+
size: 15
|
|
3355
|
+
}), /* @__PURE__ */ React.createElement("span", null, post.liked ? t("unlike") : t("like"))), /* @__PURE__ */ React.createElement("i", {
|
|
3356
|
+
className: "tmo-actions-split"
|
|
3357
|
+
}), /* @__PURE__ */ React.createElement("button", {
|
|
3358
|
+
type: "button",
|
|
3359
|
+
role: "menuitem",
|
|
3360
|
+
tabIndex: tab,
|
|
3361
|
+
onClick: pick(onComment)
|
|
3362
|
+
}, Comment && /* @__PURE__ */ React.createElement(Comment, {
|
|
3363
|
+
size: 15
|
|
3364
|
+
}), /* @__PURE__ */ React.createElement("span", null, t("comment"))), post.ask && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("i", {
|
|
3365
|
+
className: "tmo-actions-split"
|
|
3366
|
+
}), /* @__PURE__ */ React.createElement("button", {
|
|
3367
|
+
type: "button",
|
|
3368
|
+
role: "menuitem",
|
|
3369
|
+
tabIndex: tab,
|
|
3370
|
+
title: t("askTaHint", { name: post.author.name }),
|
|
3371
|
+
onClick: pick(onAsk)
|
|
3372
|
+
}, Spark && /* @__PURE__ */ React.createElement(Spark, {
|
|
3373
|
+
size: 15
|
|
3374
|
+
}), /* @__PURE__ */ React.createElement("span", null, t("askTa"))))), /* @__PURE__ */ React.createElement("button", {
|
|
3375
|
+
type: "button",
|
|
3376
|
+
className: `tmo-more${open ? " tmo-on" : ""}`,
|
|
3377
|
+
"aria-label": t("more"),
|
|
3378
|
+
"aria-expanded": open,
|
|
3379
|
+
onClick: () => setOpen(!open)
|
|
3380
|
+
}, /* @__PURE__ */ React.createElement("i", null), /* @__PURE__ */ React.createElement("i", null)));
|
|
3381
|
+
}
|
|
3382
|
+
function PostView({ post, me, now, album }) {
|
|
2858
3383
|
const [writing, setWriting] = React.useState();
|
|
2859
3384
|
const [liking, like] = useBusy();
|
|
2860
3385
|
const [removing, remove] = useBusy();
|
|
2861
3386
|
const Heart = icon("Heart");
|
|
2862
|
-
const Trash = icon("Trash2");
|
|
2863
3387
|
const Took = icon("PackageOpen");
|
|
2864
3388
|
const words2 = MomentsWords.of(pi.ui.language);
|
|
2865
3389
|
const left = post.until !== undefined ? Math.ceil((post.until - now) / 86400000) : undefined;
|
|
2866
3390
|
const Spark = icon("Sparkles");
|
|
2867
|
-
const
|
|
3391
|
+
const openAlbum = album ? undefined : () => store.openAlbum(post.author);
|
|
2868
3392
|
return /* @__PURE__ */ React.createElement("article", {
|
|
2869
3393
|
className: "tmo-post",
|
|
2870
3394
|
"data-post": `${post.room}:${post.id}`
|
|
3395
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3396
|
+
type: "button",
|
|
3397
|
+
className: "tmo-face-button",
|
|
3398
|
+
"aria-label": post.author.name,
|
|
3399
|
+
disabled: !openAlbum,
|
|
3400
|
+
onClick: openAlbum
|
|
2871
3401
|
}, /* @__PURE__ */ React.createElement(Face, {
|
|
2872
3402
|
id: post.author.id,
|
|
2873
3403
|
look: post.author.look,
|
|
2874
3404
|
mine: post.mine,
|
|
2875
3405
|
size: 42
|
|
2876
|
-
}), /* @__PURE__ */ React.createElement("div", {
|
|
3406
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
2877
3407
|
className: "tmo-post-body"
|
|
2878
|
-
}, /* @__PURE__ */ React.createElement("
|
|
2879
|
-
|
|
3408
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
3409
|
+
type: "button",
|
|
3410
|
+
className: "tmo-name",
|
|
3411
|
+
disabled: !openAlbum,
|
|
3412
|
+
onClick: openAlbum
|
|
2880
3413
|
}, post.author.name), post.why && /* @__PURE__ */ React.createElement("div", {
|
|
2881
3414
|
className: "tmo-why",
|
|
2882
3415
|
title: t("whyHint")
|
|
2883
3416
|
}, Spark && /* @__PURE__ */ React.createElement(Spark, {
|
|
2884
3417
|
size: 13
|
|
2885
|
-
}), /* @__PURE__ */ React.createElement("span", null, post.why)), post.text && /* @__PURE__ */ React.createElement(
|
|
2886
|
-
|
|
2887
|
-
}
|
|
3418
|
+
}), /* @__PURE__ */ React.createElement("span", null, post.why)), post.text && /* @__PURE__ */ React.createElement(PostText, {
|
|
3419
|
+
text: post.text
|
|
3420
|
+
}), /* @__PURE__ */ React.createElement(PostImages, {
|
|
2888
3421
|
post
|
|
2889
3422
|
}), post.attach && /* @__PURE__ */ React.createElement(AttachCard, {
|
|
2890
3423
|
post,
|
|
2891
3424
|
attach: post.attach
|
|
2892
3425
|
}), /* @__PURE__ */ React.createElement("div", {
|
|
2893
3426
|
className: "tmo-meta"
|
|
2894
|
-
}, /* @__PURE__ */ React.createElement("span", null, MomentsWords.ago(words2, post.at, now, pi.ui.language)), post.mine && left !== undefined && /* @__PURE__ */ React.createElement("span", null, left <= 1 ? t("expiresSoon") : t("expires", { days: left })), post.mine && /* @__PURE__ */ React.createElement("button", {
|
|
3427
|
+
}, /* @__PURE__ */ React.createElement("span", null, MomentsWords.ago(words2, post.at, now, pi.ui.language)), post.mine && left !== undefined && left <= 3 && /* @__PURE__ */ React.createElement("span", null, left <= 1 ? t("expiresSoon") : t("expires", { days: left })), post.mine && /* @__PURE__ */ React.createElement("button", {
|
|
2895
3428
|
type: "button",
|
|
2896
|
-
className: "tmo-link",
|
|
3429
|
+
className: "tmo-link tmo-delete",
|
|
2897
3430
|
disabled: removing,
|
|
2898
3431
|
onClick: () => void remove(async () => {
|
|
2899
3432
|
if (await pi.ui.confirm(t("deleteTitle"), t("deleteBody"), { confirmLabel: t("deletePost"), danger: true })) {
|
|
@@ -2901,39 +3434,18 @@ function PostView({ post, me, now }) {
|
|
|
2901
3434
|
await store.load();
|
|
2902
3435
|
}
|
|
2903
3436
|
})
|
|
2904
|
-
},
|
|
2905
|
-
size: 13
|
|
2906
|
-
}), /* @__PURE__ */ React.createElement("span", null, t("deletePost"))), /* @__PURE__ */ React.createElement("span", {
|
|
3437
|
+
}, t("deletePost")), /* @__PURE__ */ React.createElement("span", {
|
|
2907
3438
|
className: "tmo-grow"
|
|
2908
|
-
}),
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
onClick: () => setWriting(writing?.ask ? undefined : { ask: true })
|
|
2913
|
-
}, Spark && /* @__PURE__ */ React.createElement(Spark, {
|
|
2914
|
-
size: 13
|
|
2915
|
-
}), /* @__PURE__ */ React.createElement("span", null, t("askTa"))), /* @__PURE__ */ React.createElement("button", {
|
|
2916
|
-
type: "button",
|
|
2917
|
-
className: `tmo-like${writing && !writing.ask ? " tmo-on-talk" : ""}`,
|
|
2918
|
-
"aria-label": t("comment"),
|
|
2919
|
-
title: t("comment"),
|
|
2920
|
-
onClick: () => setWriting(writing && !writing.ask && !writing.to ? undefined : {})
|
|
2921
|
-
}, Comment && /* @__PURE__ */ React.createElement(Comment, {
|
|
2922
|
-
size: 16
|
|
2923
|
-
})), /* @__PURE__ */ React.createElement("button", {
|
|
2924
|
-
type: "button",
|
|
2925
|
-
className: `tmo-like${post.liked ? " tmo-on" : ""}`,
|
|
2926
|
-
"aria-pressed": post.liked,
|
|
2927
|
-
"aria-label": post.liked ? t("unlike") : t("like"),
|
|
2928
|
-
title: post.liked ? t("unlike") : t("like"),
|
|
2929
|
-
disabled: liking,
|
|
2930
|
-
onClick: () => void like(async () => {
|
|
3439
|
+
}), /* @__PURE__ */ React.createElement(Actions, {
|
|
3440
|
+
post,
|
|
3441
|
+
liking,
|
|
3442
|
+
onLike: () => void like(async () => {
|
|
2931
3443
|
await pi.callHost("like", post.room, post.id, !post.liked).catch(failed);
|
|
2932
3444
|
await store.load();
|
|
2933
|
-
})
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
}))
|
|
3445
|
+
}),
|
|
3446
|
+
onComment: () => setWriting({}),
|
|
3447
|
+
onAsk: () => setWriting({ ask: true })
|
|
3448
|
+
})), (post.likes.length > 0 || post.took.length > 0 || post.talk.length > 0) && /* @__PURE__ */ React.createElement("div", {
|
|
2937
3449
|
className: "tmo-marks"
|
|
2938
3450
|
}, post.likes.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
2939
3451
|
className: "tmo-marks-line"
|
|
@@ -2957,48 +3469,62 @@ function PostView({ post, me, now }) {
|
|
|
2957
3469
|
close: () => setWriting(undefined)
|
|
2958
3470
|
})));
|
|
2959
3471
|
}
|
|
2960
|
-
function
|
|
3472
|
+
function Album({ person }) {
|
|
2961
3473
|
const state = useMoments();
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
}),
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
3474
|
+
if (!state) {
|
|
3475
|
+
return null;
|
|
3476
|
+
}
|
|
3477
|
+
const now = Date.now();
|
|
3478
|
+
const posts = state.posts.filter((post) => post.author.id === person.id);
|
|
3479
|
+
return /* @__PURE__ */ React.createElement("section", {
|
|
3480
|
+
className: "tmo-page",
|
|
3481
|
+
"aria-label": person.name
|
|
3482
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3483
|
+
className: "tmo-feed"
|
|
3484
|
+
}, /* @__PURE__ */ React.createElement(Cover, {
|
|
3485
|
+
person,
|
|
3486
|
+
mine: person.id === state.me.id
|
|
3487
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
3488
|
+
className: "tmo-after-cover"
|
|
3489
|
+
}), posts.length ? posts.map((post) => /* @__PURE__ */ React.createElement(PostView, {
|
|
3490
|
+
key: `${post.room}:${post.id}`,
|
|
3491
|
+
post,
|
|
3492
|
+
me: state.me.id,
|
|
3493
|
+
now,
|
|
3494
|
+
album: true
|
|
3495
|
+
})) : /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
3496
|
+
title: t("albumEmpty")
|
|
2984
3497
|
})));
|
|
2985
3498
|
}
|
|
2986
3499
|
function MomentsPage() {
|
|
2987
3500
|
const Loading = pi.ui.Loading ?? pi.ui.Skeleton;
|
|
2988
3501
|
const state = useMoments();
|
|
3502
|
+
const album = useAlbum();
|
|
2989
3503
|
const now = Date.now();
|
|
2990
3504
|
const shown = pi.ui.useView?.(VIEW)?.shown ?? true;
|
|
2991
3505
|
React.useEffect(() => {
|
|
2992
3506
|
store.load();
|
|
3507
|
+
store.loadCover();
|
|
2993
3508
|
}, []);
|
|
2994
3509
|
React.useEffect(() => {
|
|
2995
3510
|
if (state && shown) {
|
|
2996
3511
|
store.markSeen();
|
|
2997
3512
|
}
|
|
2998
3513
|
}, [state, shown]);
|
|
3514
|
+
React.useEffect(() => {
|
|
3515
|
+
if (!shown) {
|
|
3516
|
+
store.openAlbum(undefined);
|
|
3517
|
+
}
|
|
3518
|
+
}, [shown]);
|
|
3519
|
+
const [kept, setKept] = React.useState();
|
|
3520
|
+
React.useEffect(() => {
|
|
3521
|
+
if (album) {
|
|
3522
|
+
setKept(album);
|
|
3523
|
+
}
|
|
3524
|
+
}, [album]);
|
|
2999
3525
|
const focus = React.useSyncExternalStore(store.subscribe, () => store.focus);
|
|
3000
3526
|
React.useEffect(() => {
|
|
3001
|
-
if (!state || !focus || !shown) {
|
|
3527
|
+
if (!state || !focus || !shown || album) {
|
|
3002
3528
|
return;
|
|
3003
3529
|
}
|
|
3004
3530
|
const element = document.querySelector(`.tmo-post[data-post="${CSS.escape(focus)}"]`);
|
|
@@ -3010,7 +3536,7 @@ function MomentsPage() {
|
|
|
3010
3536
|
} else {
|
|
3011
3537
|
pi.ui.notify(t("postGone"));
|
|
3012
3538
|
}
|
|
3013
|
-
}, [state, focus, shown]);
|
|
3539
|
+
}, [state, focus, shown, album]);
|
|
3014
3540
|
if (!pi.rooms) {
|
|
3015
3541
|
return /* @__PURE__ */ React.createElement(pi.ui.Empty, {
|
|
3016
3542
|
title: t("oldApp")
|
|
@@ -3023,12 +3549,23 @@ function MomentsPage() {
|
|
|
3023
3549
|
}) : /* @__PURE__ */ React.createElement(Loading, null);
|
|
3024
3550
|
}
|
|
3025
3551
|
const Add = icon("UserPlus");
|
|
3026
|
-
|
|
3552
|
+
const feed = /* @__PURE__ */ React.createElement("section", {
|
|
3027
3553
|
className: "tmo-page",
|
|
3028
3554
|
"aria-label": t("title")
|
|
3029
3555
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
3030
3556
|
className: "tmo-feed"
|
|
3031
|
-
}, /* @__PURE__ */ React.createElement(
|
|
3557
|
+
}, /* @__PURE__ */ React.createElement(Cover, {
|
|
3558
|
+
person: state.me,
|
|
3559
|
+
mine: true,
|
|
3560
|
+
onFace: () => store.openAlbum(state.me)
|
|
3561
|
+
}), /* @__PURE__ */ React.createElement(News, {
|
|
3562
|
+
posts: state.posts,
|
|
3563
|
+
me: state.me.id,
|
|
3564
|
+
now,
|
|
3565
|
+
people: [state.me, ...state.friends]
|
|
3566
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
3567
|
+
className: "tmo-after-cover"
|
|
3568
|
+
}), state.posts.length ? state.posts.map((post) => /* @__PURE__ */ React.createElement(PostView, {
|
|
3032
3569
|
key: `${post.room}:${post.id}`,
|
|
3033
3570
|
post,
|
|
3034
3571
|
me: state.me.id,
|
|
@@ -3046,6 +3583,22 @@ function MomentsPage() {
|
|
|
3046
3583
|
}, Add && /* @__PURE__ */ React.createElement(Add, {
|
|
3047
3584
|
size: 14
|
|
3048
3585
|
}), " ", t("addFriend")))));
|
|
3586
|
+
const Stack = pi.ui.Stack;
|
|
3587
|
+
const top = album ?? kept;
|
|
3588
|
+
if (!Stack) {
|
|
3589
|
+
return album ? /* @__PURE__ */ React.createElement(Album, {
|
|
3590
|
+
person: album
|
|
3591
|
+
}) : feed;
|
|
3592
|
+
}
|
|
3593
|
+
return /* @__PURE__ */ React.createElement(Stack, {
|
|
3594
|
+
base: feed,
|
|
3595
|
+
top: top ? /* @__PURE__ */ React.createElement(Album, {
|
|
3596
|
+
key: top.id,
|
|
3597
|
+
person: top
|
|
3598
|
+
}) : null,
|
|
3599
|
+
open: !!album,
|
|
3600
|
+
onClose: () => store.openAlbum(undefined)
|
|
3601
|
+
});
|
|
3049
3602
|
}
|
|
3050
3603
|
function MomentsMark() {
|
|
3051
3604
|
const state = useMoments();
|
|
@@ -3083,24 +3636,56 @@ var STYLE = `
|
|
|
3083
3636
|
.tmo-head-title { font-weight: 600; font-size: calc(14.5px * var(--ta-font-scale)); }
|
|
3084
3637
|
.tmo-head-end { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
|
|
3085
3638
|
/* The page: one column, as WeChat's Moments */
|
|
3086
|
-
.tmo-page { flex: 1; min-height: 0; height: 100%; overflow-y: auto; overscroll-behavior: none; background: var(--ta-main); color: var(--ta-text); }
|
|
3639
|
+
.tmo-page { flex: 1; min-height: 0; height: 100%; overflow-x: hidden; overflow-y: auto; overscroll-behavior: none; background: var(--ta-main); color: var(--ta-text); }
|
|
3087
3640
|
.tmo-feed { display: flex; flex-direction: column; min-height: 100%; max-width: var(--ta-page-width); margin: 0 auto; padding: 6px 14px calc(28px + env(safe-area-inset-bottom)); box-sizing: border-box; }
|
|
3088
3641
|
.tmo-card { margin: 4px 0 8px; padding: 2px 8px; border-radius: 14px; background: var(--ta-raised); }
|
|
3089
|
-
|
|
3090
|
-
.tmo-
|
|
3091
|
-
.tmo-
|
|
3092
|
-
.tmo-
|
|
3642
|
+
/* The cover, as WeChat's: the picture across the column, the name on it and the face over its foot */
|
|
3643
|
+
.tmo-cover { position: relative; margin: -6px -14px 0; }
|
|
3644
|
+
.tmo-cover-art { display: block; width: 100%; height: clamp(220px, 34vh, 300px); padding: 0; border: 0; overflow: hidden; background: var(--ta-raised); cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3645
|
+
.tmo-cover-art:disabled { cursor: default; }
|
|
3646
|
+
.tmo-cover-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
|
|
3647
|
+
.tmo-cover-art.tmo-busy { opacity: .6; }
|
|
3648
|
+
.tmo-cover-default { display: block; width: 100%; height: 100%; background:
|
|
3649
|
+
radial-gradient(120% 90% at 85% 0%, color-mix(in oklch, var(--ta-green) 42%, transparent), transparent 62%),
|
|
3650
|
+
radial-gradient(90% 80% at 0% 100%, color-mix(in oklch, var(--ta-yellow) 26%, transparent), transparent 60%),
|
|
3651
|
+
linear-gradient(180deg, color-mix(in oklch, var(--ta-green) 16%, var(--ta-raised)), var(--ta-raised)); }
|
|
3652
|
+
.tmo-cover-who { position: absolute; right: 16px; bottom: -22px; display: flex; align-items: flex-end; gap: 14px; max-width: calc(100% - 32px); pointer-events: none; }
|
|
3653
|
+
.tmo-cover-name { min-width: 0; margin-bottom: 30px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-weight: 600; font-size: calc(17px * var(--ta-font-scale)); text-shadow: 0 1px 3px rgba(0, 0, 0, .45); }
|
|
3654
|
+
.tmo-cover-face { flex: none; display: block; padding: 0; border: 0; border-radius: 50%; background: var(--ta-main); box-shadow: 0 0 0 3px var(--ta-main); line-height: 0; pointer-events: auto; cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3655
|
+
.tmo-cover-face:disabled { cursor: default; }
|
|
3656
|
+
.tmo-cover-face .ta-face { --ta-face-ring: var(--ta-main); }
|
|
3657
|
+
.tmo-after-cover { height: 22px; flex: none; }
|
|
3658
|
+
/* New messages under the cover */
|
|
3659
|
+
.tmo-news { display: flex; align-items: center; gap: 10px; align-self: center; margin: 38px 0 -8px; padding: 6px 16px 6px 6px; border: 0; border-radius: 9px; background: color-mix(in srgb, var(--ta-text) 72%, transparent); color: var(--ta-main); font: inherit; font-size: calc(13.5px * var(--ta-font-scale)); cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3660
|
+
.tmo-news .ta-face { --ta-face-ring: transparent; }
|
|
3661
|
+
.tmo-news:active { opacity: .85; }
|
|
3662
|
+
.tmo-news-list { min-width: min(400px, 82vw); }
|
|
3663
|
+
.tmo-news-row { width: 100%; border: 0; border-radius: 10px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; align-items: flex-start; }
|
|
3664
|
+
.tmo-news-row:hover { background: var(--ta-hover); }
|
|
3665
|
+
.tmo-news-row .ta-face { --ta-face-ring: var(--ta-card); }
|
|
3666
|
+
.tmo-news-name { font-weight: 500; color: var(--ta-link); }
|
|
3667
|
+
.tmo-news-text { line-height: 1.45; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
|
3668
|
+
.tmo-news-post { flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 6px; overflow: hidden; background: var(--ta-raised); }
|
|
3669
|
+
.tmo-news-post img { width: 100%; height: 100%; object-fit: cover; }
|
|
3670
|
+
.tmo-news-post span { padding: 4px; color: var(--ta-secondary); font-size: calc(11px * var(--ta-font-scale)); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
|
3671
|
+
.tmo-icon-button { position: relative; }
|
|
3672
|
+
.tmo-icon-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--ta-yellow); }
|
|
3093
3673
|
.tmo-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ta-yellow); }
|
|
3094
3674
|
/* A post: the face, then the name, words, pictures, what to take, when and the heart */
|
|
3095
3675
|
.tmo-post { display: flex; gap: 12px; padding: 16px 2px 14px; border-bottom: 1px solid var(--ta-border-muted); }
|
|
3676
|
+
.tmo-face-button { flex: none; align-self: flex-start; display: block; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3677
|
+
.tmo-face-button:disabled { cursor: default; }
|
|
3096
3678
|
.tmo-post .ta-face { --ta-face-ring: var(--ta-main); }
|
|
3097
3679
|
.tmo-post-body { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 0; }
|
|
3098
|
-
.tmo-name { font-weight: 600; color: var(--ta-link); font-size: calc(14.5px * var(--ta-font-scale)); line-height: 1.3; }
|
|
3680
|
+
.tmo-name { align-self: flex-start; max-width: 100%; padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--ta-link); font-size: calc(14.5px * var(--ta-font-scale)); line-height: 1.3; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3681
|
+
.tmo-name:disabled { cursor: default; color: var(--ta-link); }
|
|
3099
3682
|
.tmo-why { display: flex; align-items: flex-start; gap: 5px; align-self: flex-start; max-width: 100%; padding: 3px 8px; border-radius: 7px; background: color-mix(in srgb, var(--ta-yellow) 14%, transparent); color: var(--ta-secondary); font-size: calc(12.5px * var(--ta-font-scale)); line-height: 1.45; }
|
|
3100
3683
|
.tmo-why svg { flex: none; position: relative; top: 2px; color: var(--ta-yellow); }
|
|
3101
3684
|
.tmo-post.tmo-focus { animation: tmo-focus 1.6s ease-out; }
|
|
3102
3685
|
@keyframes tmo-focus { from { background: var(--ta-hover); } to { background: transparent; } }
|
|
3103
3686
|
.tmo-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: calc(14.5px * var(--ta-font-scale)); }
|
|
3687
|
+
.tmo-clamp { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
|
|
3688
|
+
.tmo-fold { align-self: flex-start; margin-top: -4px; padding: 0; border: 0; background: none; color: var(--ta-link); font: inherit; font-size: calc(14px * var(--ta-font-scale)); cursor: pointer; }
|
|
3104
3689
|
.tmo-images { display: flex; }
|
|
3105
3690
|
.tmo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; max-width: 300px; }
|
|
3106
3691
|
.tmo-image { position: relative; display: block; padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: var(--ta-raised); cursor: zoom-in; }
|
|
@@ -3117,15 +3702,21 @@ var STYLE = `
|
|
|
3117
3702
|
.tmo-attach-line { color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
3118
3703
|
.tmo-attach .ta-button { flex: none; }
|
|
3119
3704
|
.tmo-meta { display: flex; align-items: center; gap: 10px; min-height: 28px; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
3120
|
-
.tmo-meta .tmo-link { color: var(--ta-
|
|
3121
|
-
.tmo-meta .tmo-
|
|
3122
|
-
.tmo-
|
|
3123
|
-
|
|
3124
|
-
.tmo-
|
|
3125
|
-
.tmo-
|
|
3126
|
-
.tmo-
|
|
3127
|
-
.tmo-
|
|
3128
|
-
.tmo-
|
|
3705
|
+
.tmo-meta .tmo-link { color: var(--ta-link); }
|
|
3706
|
+
.tmo-meta .tmo-delete { padding: 2px 0; }
|
|
3707
|
+
.tmo-meta .tmo-delete:hover { background: none; color: var(--ta-red); }
|
|
3708
|
+
/* The two dots, and Like · Comment sliding out to their left, as WeChat's */
|
|
3709
|
+
.tmo-actions { position: relative; display: flex; align-items: center; }
|
|
3710
|
+
.tmo-more { display: flex; align-items: center; justify-content: center; gap: 4px; width: 32px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: var(--ta-raised); cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3711
|
+
.tmo-more i { width: 4px; height: 4px; border-radius: 50%; background: var(--ta-link); }
|
|
3712
|
+
.tmo-more:hover, .tmo-more.tmo-on { background: var(--ta-hover); }
|
|
3713
|
+
.tmo-actions-pop { position: absolute; right: calc(100% + 8px); top: 50%; display: flex; align-items: center; height: 38px; padding: 0 4px; border-radius: 6px; background: #4c4c4c; color: #fff; white-space: nowrap; transform: translateY(-50%) scaleX(0); transform-origin: right center; opacity: 0; pointer-events: none; transition: transform 160ms cubic-bezier(.2, .8, .2, 1), opacity 120ms; z-index: 2; }
|
|
3714
|
+
.tmo-actions-pop.tmo-open { transform: translateY(-50%) scaleX(1); opacity: 1; pointer-events: auto; }
|
|
3715
|
+
.tmo-actions-pop button { display: inline-flex; align-items: center; gap: 6px; height: 100%; padding: 0 14px; border: 0; background: none; color: inherit; font: inherit; font-size: calc(13.5px * var(--ta-font-scale)); cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3716
|
+
.tmo-actions-pop button:active { opacity: .7; }
|
|
3717
|
+
.tmo-actions-pop button.tmo-liked svg { fill: currentColor; color: #ff5b5b; }
|
|
3718
|
+
.tmo-actions-split { width: 1px; height: 18px; background: rgba(255, 255, 255, .16); }
|
|
3719
|
+
.tmo-marks { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 7px 10px; border-radius: 8px; background: var(--ta-raised); font-size: calc(12.5px * var(--ta-font-scale)); color: var(--ta-link); }
|
|
3129
3720
|
.tmo-marks-line { display: flex; align-items: baseline; gap: 6px; overflow-wrap: anywhere; }
|
|
3130
3721
|
.tmo-marks-line svg { flex: none; position: relative; top: 1px; color: var(--ta-muted); }
|
|
3131
3722
|
/* Words on a post, in the box of the likes */
|
|
@@ -3140,10 +3731,6 @@ var STYLE = `
|
|
|
3140
3731
|
.tmo-talk-text { white-space: pre-wrap; }
|
|
3141
3732
|
.tmo-talk-wait { margin-left: 6px; color: var(--ta-muted); font-size: calc(11.5px * var(--ta-font-scale)); }
|
|
3142
3733
|
.tmo-pending .tmo-talk-text { color: var(--ta-secondary); }
|
|
3143
|
-
.tmo-ask { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 9px; border: 0; border-radius: 8px; background: none; color: var(--ta-secondary); font: inherit; font-size: calc(12.5px * var(--ta-font-scale)); cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
3144
|
-
.tmo-ask svg { color: var(--ta-yellow); }
|
|
3145
|
-
.tmo-ask:hover, .tmo-ask.tmo-on { background: var(--ta-hover); color: var(--ta-text); }
|
|
3146
|
-
.tmo-like.tmo-on-talk { color: var(--ta-text); background: var(--ta-hover); }
|
|
3147
3734
|
.tmo-talk-box { display: flex; flex-direction: column; gap: 2px; }
|
|
3148
3735
|
.tmo-talk-cancel { align-self: flex-end; color: var(--ta-muted); font-size: calc(12px * var(--ta-font-scale)); }
|
|
3149
3736
|
.tmo-editor-check { gap: 7px; cursor: pointer; font-size: calc(13px * var(--ta-font-scale)); }
|
|
@@ -3205,7 +3792,7 @@ var STYLE = `
|
|
|
3205
3792
|
.tmo-mark { position: relative; display: inline-flex; }
|
|
3206
3793
|
.tmo-mark .ta-face { --ta-face-ring: var(--ta-list-cell, var(--ta-main)); }
|
|
3207
3794
|
.tmo-mark-dot { position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--ta-yellow); box-shadow: 0 0 0 2px var(--ta-list-cell, var(--ta-main)); }
|
|
3208
|
-
@media (prefers-reduced-motion: reduce) { .tmo-image-wait { animation: none; } .tmo-
|
|
3795
|
+
@media (prefers-reduced-motion: reduce) { .tmo-image-wait { animation: none; } .tmo-actions-pop { transition: none; } }
|
|
3209
3796
|
`;
|
|
3210
3797
|
function injectStyle() {
|
|
3211
3798
|
const element = document.createElement("style");
|
|
@@ -3229,8 +3816,8 @@ function activate(pi2) {
|
|
|
3229
3816
|
order: 78
|
|
3230
3817
|
});
|
|
3231
3818
|
pi2.registerMessageRenderer(DRAFT_TYPE, DraftMessage);
|
|
3232
|
-
pi2.registerOpener((
|
|
3233
|
-
const target =
|
|
3819
|
+
pi2.registerOpener((link2) => {
|
|
3820
|
+
const target = link2.type === "url" ? MomentsBrief.parse(link2.url) : undefined;
|
|
3234
3821
|
if (!target) {
|
|
3235
3822
|
return false;
|
|
3236
3823
|
}
|