@atmo-dev/kit 0.18.0 → 0.18.1
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.
|
@@ -74,19 +74,25 @@
|
|
|
74
74
|
$effect(() => {
|
|
75
75
|
const uri = firstLink;
|
|
76
76
|
const preview = linkPreview;
|
|
77
|
-
if (!preview || hasMedia
|
|
78
|
-
if (post.link
|
|
77
|
+
if (!preview || hasMedia) {
|
|
78
|
+
if (post.link) post.link = undefined;
|
|
79
|
+
loadingLink = false;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// The card outlives its link: deleting the URL, at once or a character at a time,
|
|
83
|
+
// leaves it attached. Only its own button, or another link, takes it away.
|
|
84
|
+
const shown = untrack(() => post.link?.uri);
|
|
85
|
+
if (!uri || uri === dismissed || uri === shown || shown?.startsWith(uri)) {
|
|
79
86
|
loadingLink = false;
|
|
80
87
|
return;
|
|
81
88
|
}
|
|
82
|
-
if (untrack(() => post.link?.uri) === uri) return;
|
|
83
89
|
const controller = new AbortController();
|
|
84
90
|
const timer = setTimeout(async () => {
|
|
85
91
|
loadingLink = true;
|
|
86
92
|
const card = await preview(uri, controller.signal).catch(() => undefined);
|
|
87
93
|
if (controller.signal.aborted) return;
|
|
88
94
|
loadingLink = false;
|
|
89
|
-
post.link = card;
|
|
95
|
+
if (card) post.link = card;
|
|
90
96
|
}, 500);
|
|
91
97
|
return () => {
|
|
92
98
|
clearTimeout(timer);
|
|
@@ -164,8 +164,8 @@
|
|
|
164
164
|
const lengthOf = (post: Post) => graphemeLength(post.text.trim());
|
|
165
165
|
const hasMedia = (post: Post) => post.images.length > 0 || !!post.video || !!post.gif;
|
|
166
166
|
const isEmpty = (post: Post, index: number) =>
|
|
167
|
-
!lengthOf(post) && !hasMedia(post) && !(index === 0 && quote);
|
|
168
|
-
let dirty = $derived(posts.some((post, index) => !isEmpty(post, index)
|
|
167
|
+
!lengthOf(post) && !hasMedia(post) && !post.link && !(index === 0 && quote);
|
|
168
|
+
let dirty = $derived(posts.some((post, index) => !isEmpty(post, index)));
|
|
169
169
|
let missingAlt = $derived(
|
|
170
170
|
requireAlt && posts.some((p) => p.images.some((image) => !image.alt.trim()))
|
|
171
171
|
);
|