sanity-plugin-r2-video 0.1.3 → 0.1.4
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/dist/studio/index.js +19 -8
- package/package.json +1 -1
package/dist/studio/index.js
CHANGED
|
@@ -90,14 +90,21 @@ var findReferencingDocuments = (client, id) => {
|
|
|
90
90
|
};
|
|
91
91
|
var deleteVideoAsset = async (client, config, asset) => {
|
|
92
92
|
await client.delete(asset._id);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
const posterId = asset.poster?.asset?._ref;
|
|
94
|
+
const renditions = asset.renditions ?? [];
|
|
95
|
+
if (posterId) {
|
|
96
|
+
try {
|
|
97
|
+
await client.delete(posterId);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.info(
|
|
100
|
+
`Kept poster for '${asset.filename}' - still in use.`,
|
|
101
|
+
error
|
|
102
|
+
);
|
|
103
|
+
}
|
|
97
104
|
}
|
|
98
105
|
await deleteObjects(
|
|
99
106
|
config,
|
|
100
|
-
|
|
107
|
+
renditions.map((rendition) => rendition.key)
|
|
101
108
|
);
|
|
102
109
|
};
|
|
103
110
|
|
|
@@ -1722,7 +1729,10 @@ var QUERY_ASSETS = `*[_type == "r2Video.asset"] | order(uploadedAt desc){
|
|
|
1722
1729
|
poster,
|
|
1723
1730
|
duration,
|
|
1724
1731
|
hasAudio,
|
|
1725
|
-
|
|
1732
|
+
|
|
1733
|
+
// A document the pipeline never finished - Sanity's own create button made
|
|
1734
|
+
// these before the reference field disabled it - has no renditions at all
|
|
1735
|
+
"renditions": coalesce(renditions, []),
|
|
1726
1736
|
uploadedAt,
|
|
1727
1737
|
"posterUrl": poster.asset->url,
|
|
1728
1738
|
"folderName": folder->name
|
|
@@ -1731,10 +1741,11 @@ var slugify = (name) => {
|
|
|
1731
1741
|
return name.toLowerCase().replace(/['\u2019]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1732
1742
|
};
|
|
1733
1743
|
var toTitle = (asset, isFiltered) => {
|
|
1744
|
+
const filename = asset.filename || "Untitled video";
|
|
1734
1745
|
if (isFiltered || !asset.folderName) {
|
|
1735
|
-
return
|
|
1746
|
+
return filename;
|
|
1736
1747
|
}
|
|
1737
|
-
return `${slugify(asset.folderName)}/${
|
|
1748
|
+
return `${slugify(asset.folderName)}/${filename}`;
|
|
1738
1749
|
};
|
|
1739
1750
|
var matches = (asset, search) => {
|
|
1740
1751
|
if (!search) {
|