@amityco/react-native-social-uikit 4.1.1-fe2678f6.0 → 4.2.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/README.md +7 -0
- package/lib/commonjs/core/assets/icons/post.js +1 -1
- package/lib/commonjs/core/assets/icons/post.js.map +1 -1
- package/lib/commonjs/core/assets/icons/story.js +1 -1
- package/lib/commonjs/core/assets/icons/story.js.map +1 -1
- package/lib/commonjs/core/assets/icons/xml.js +16 -2
- package/lib/commonjs/core/assets/icons/xml.js.map +1 -1
- package/lib/commonjs/core/legacy/file.js +145 -62
- package/lib/commonjs/core/legacy/file.js.map +1 -1
- package/lib/commonjs/core/stores/slices/feedSlice.js +3 -0
- package/lib/commonjs/core/stores/slices/feedSlice.js.map +1 -1
- package/lib/commonjs/core/stores/slices/globalfeedSlice.js +5 -0
- package/lib/commonjs/core/stores/slices/globalfeedSlice.js.map +1 -1
- package/lib/commonjs/core/stores/slices/localVideoThumbnailSlice.js +46 -0
- package/lib/commonjs/core/stores/slices/localVideoThumbnailSlice.js.map +1 -0
- package/lib/commonjs/core/stores/slices/uiSlice.js +5 -1
- package/lib/commonjs/core/stores/slices/uiSlice.js.map +1 -1
- package/lib/commonjs/core/stores/store/index.js +3 -1
- package/lib/commonjs/core/stores/store/index.js.map +1 -1
- package/lib/commonjs/social/components/LoadingImage/index.js +73 -12
- package/lib/commonjs/social/components/LoadingImage/index.js.map +1 -1
- package/lib/commonjs/social/components/LoadingImage/styles.js +8 -3
- package/lib/commonjs/social/components/LoadingImage/styles.js.map +1 -1
- package/lib/commonjs/social/components/LoadingVideo/index.js +90 -16
- package/lib/commonjs/social/components/LoadingVideo/index.js.map +1 -1
- package/lib/commonjs/social/components/LoadingVideo/styles.js +14 -5
- package/lib/commonjs/social/components/LoadingVideo/styles.js.map +1 -1
- package/lib/commonjs/social/components/MediaViewer/MediaViewer.js +13 -13
- package/lib/commonjs/social/components/MediaViewer/MediaViewer.js.map +1 -1
- package/lib/commonjs/social/components/MediaViewer/styles.js +11 -1
- package/lib/commonjs/social/components/MediaViewer/styles.js.map +1 -1
- package/lib/commonjs/social/components/PostContent/index.js +8 -29
- package/lib/commonjs/social/components/PostContent/index.js.map +1 -1
- package/lib/commonjs/social/components/SelectedMediaComponent/SelectedMediaComponent.js +109 -17
- package/lib/commonjs/social/components/SelectedMediaComponent/SelectedMediaComponent.js.map +1 -1
- package/lib/commonjs/social/components/legacy/LoadingVideo/index.js +17 -6
- package/lib/commonjs/social/components/legacy/LoadingVideo/index.js.map +1 -1
- package/lib/commonjs/social/elements/PostMediaElement/PostMediaElement.js +121 -23
- package/lib/commonjs/social/elements/PostMediaElement/PostMediaElement.js.map +1 -1
- package/lib/commonjs/social/elements/PostMediaElement/styles.js +7 -0
- package/lib/commonjs/social/elements/PostMediaElement/styles.js.map +1 -1
- package/lib/commonjs/social/features/community/PendingRequest/components/PendingPostList/PendingPostList.js +11 -5
- package/lib/commonjs/social/features/community/PendingRequest/components/PendingPostList/PendingPostList.js.map +1 -1
- package/lib/commonjs/social/features/feed/components/NewsFeed/NewsFeed.js +14 -0
- package/lib/commonjs/social/features/feed/components/NewsFeed/NewsFeed.js.map +1 -1
- package/lib/commonjs/social/features/post/Composer/PostComposer.js +234 -86
- package/lib/commonjs/social/features/post/Composer/PostComposer.js.map +1 -1
- package/lib/commonjs/social/hooks/index.js +11 -0
- package/lib/commonjs/social/hooks/index.js.map +1 -1
- package/lib/commonjs/social/hooks/useCommunities.js +5 -3
- package/lib/commonjs/social/hooks/useCommunities.js.map +1 -1
- package/lib/commonjs/social/hooks/useCommunityPermission.js +43 -0
- package/lib/commonjs/social/hooks/useCommunityPermission.js.map +1 -0
- package/lib/commonjs/social/hooks/useCustomRankingGlobalFeed.js +10 -1
- package/lib/commonjs/social/hooks/useCustomRankingGlobalFeed.js.map +1 -1
- package/lib/commonjs/social/hooks/useFile.js +11 -0
- package/lib/commonjs/social/hooks/useFile.js.map +1 -1
- package/lib/commonjs/social/screens/CommunityProfile/components/Header/Header.js +18 -7
- package/lib/commonjs/social/screens/CommunityProfile/components/Header/Header.js.map +1 -1
- package/lib/commonjs/social/utils/mediaAttachments.js +150 -0
- package/lib/commonjs/social/utils/mediaAttachments.js.map +1 -0
- package/lib/commonjs/social/utils/postChildren.js +72 -0
- package/lib/commonjs/social/utils/postChildren.js.map +1 -0
- package/lib/module/core/assets/icons/post.js +1 -1
- package/lib/module/core/assets/icons/post.js.map +1 -1
- package/lib/module/core/assets/icons/story.js +1 -1
- package/lib/module/core/assets/icons/story.js.map +1 -1
- package/lib/module/core/assets/icons/xml.js +13 -0
- package/lib/module/core/assets/icons/xml.js.map +1 -1
- package/lib/module/core/legacy/file.js +145 -62
- package/lib/module/core/legacy/file.js.map +1 -1
- package/lib/module/core/stores/slices/feedSlice.js +3 -0
- package/lib/module/core/stores/slices/feedSlice.js.map +1 -1
- package/lib/module/core/stores/slices/globalfeedSlice.js +5 -0
- package/lib/module/core/stores/slices/globalfeedSlice.js.map +1 -1
- package/lib/module/core/stores/slices/localVideoThumbnailSlice.js +41 -0
- package/lib/module/core/stores/slices/localVideoThumbnailSlice.js.map +1 -0
- package/lib/module/core/stores/slices/uiSlice.js +5 -1
- package/lib/module/core/stores/slices/uiSlice.js.map +1 -1
- package/lib/module/core/stores/store/index.js +3 -1
- package/lib/module/core/stores/store/index.js.map +1 -1
- package/lib/module/social/components/LoadingImage/index.js +74 -14
- package/lib/module/social/components/LoadingImage/index.js.map +1 -1
- package/lib/module/social/components/LoadingImage/styles.js +8 -3
- package/lib/module/social/components/LoadingImage/styles.js.map +1 -1
- package/lib/module/social/components/LoadingVideo/index.js +91 -17
- package/lib/module/social/components/LoadingVideo/index.js.map +1 -1
- package/lib/module/social/components/LoadingVideo/styles.js +14 -5
- package/lib/module/social/components/LoadingVideo/styles.js.map +1 -1
- package/lib/module/social/components/MediaViewer/MediaViewer.js +13 -13
- package/lib/module/social/components/MediaViewer/MediaViewer.js.map +1 -1
- package/lib/module/social/components/MediaViewer/styles.js +11 -1
- package/lib/module/social/components/MediaViewer/styles.js.map +1 -1
- package/lib/module/social/components/PostContent/index.js +8 -29
- package/lib/module/social/components/PostContent/index.js.map +1 -1
- package/lib/module/social/components/SelectedMediaComponent/SelectedMediaComponent.js +110 -18
- package/lib/module/social/components/SelectedMediaComponent/SelectedMediaComponent.js.map +1 -1
- package/lib/module/social/components/legacy/LoadingVideo/index.js +17 -6
- package/lib/module/social/components/legacy/LoadingVideo/index.js.map +1 -1
- package/lib/module/social/elements/PostMediaElement/PostMediaElement.js +123 -25
- package/lib/module/social/elements/PostMediaElement/PostMediaElement.js.map +1 -1
- package/lib/module/social/elements/PostMediaElement/styles.js +7 -0
- package/lib/module/social/elements/PostMediaElement/styles.js.map +1 -1
- package/lib/module/social/features/community/PendingRequest/components/PendingPostList/PendingPostList.js +12 -6
- package/lib/module/social/features/community/PendingRequest/components/PendingPostList/PendingPostList.js.map +1 -1
- package/lib/module/social/features/feed/components/NewsFeed/NewsFeed.js +15 -1
- package/lib/module/social/features/feed/components/NewsFeed/NewsFeed.js.map +1 -1
- package/lib/module/social/features/post/Composer/PostComposer.js +236 -89
- package/lib/module/social/features/post/Composer/PostComposer.js.map +1 -1
- package/lib/module/social/hooks/index.js +1 -0
- package/lib/module/social/hooks/index.js.map +1 -1
- package/lib/module/social/hooks/useCommunities.js +5 -3
- package/lib/module/social/hooks/useCommunities.js.map +1 -1
- package/lib/module/social/hooks/useCommunityPermission.js +37 -0
- package/lib/module/social/hooks/useCommunityPermission.js.map +1 -0
- package/lib/module/social/hooks/useCustomRankingGlobalFeed.js +10 -1
- package/lib/module/social/hooks/useCustomRankingGlobalFeed.js.map +1 -1
- package/lib/module/social/hooks/useFile.js +11 -0
- package/lib/module/social/hooks/useFile.js.map +1 -1
- package/lib/module/social/screens/CommunityProfile/components/Header/Header.js +19 -8
- package/lib/module/social/screens/CommunityProfile/components/Header/Header.js.map +1 -1
- package/lib/module/social/utils/mediaAttachments.js +139 -0
- package/lib/module/social/utils/mediaAttachments.js.map +1 -0
- package/lib/module/social/utils/postChildren.js +66 -0
- package/lib/module/social/utils/postChildren.js.map +1 -0
- package/lib/typescript/core/assets/icons/xml.d.ts +1 -0
- package/lib/typescript/core/assets/icons/xml.d.ts.map +1 -1
- package/lib/typescript/core/legacy/file.d.ts +32 -0
- package/lib/typescript/core/legacy/file.d.ts.map +1 -1
- package/lib/typescript/core/stores/slices/feedSlice.d.ts.map +1 -1
- package/lib/typescript/core/stores/slices/globalfeedSlice.d.ts.map +1 -1
- package/lib/typescript/core/stores/slices/localVideoThumbnailSlice.d.ts +35 -0
- package/lib/typescript/core/stores/slices/localVideoThumbnailSlice.d.ts.map +1 -0
- package/lib/typescript/core/stores/slices/uiSlice.d.ts +5 -0
- package/lib/typescript/core/stores/slices/uiSlice.d.ts.map +1 -1
- package/lib/typescript/core/stores/store/index.d.ts.map +1 -1
- package/lib/typescript/core/types/mention.d.ts +34 -0
- package/lib/typescript/core/types/mention.d.ts.map +1 -1
- package/lib/typescript/social/components/LoadingImage/index.d.ts +8 -2
- package/lib/typescript/social/components/LoadingImage/index.d.ts.map +1 -1
- package/lib/typescript/social/components/LoadingImage/styles.d.ts.map +1 -1
- package/lib/typescript/social/components/LoadingVideo/index.d.ts +9 -2
- package/lib/typescript/social/components/LoadingVideo/index.d.ts.map +1 -1
- package/lib/typescript/social/components/LoadingVideo/styles.d.ts +1 -0
- package/lib/typescript/social/components/LoadingVideo/styles.d.ts.map +1 -1
- package/lib/typescript/social/components/MediaViewer/MediaViewer.d.ts.map +1 -1
- package/lib/typescript/social/components/MediaViewer/styles.d.ts +1 -0
- package/lib/typescript/social/components/MediaViewer/styles.d.ts.map +1 -1
- package/lib/typescript/social/components/PostContent/index.d.ts.map +1 -1
- package/lib/typescript/social/components/SelectedMediaComponent/SelectedMediaComponent.d.ts +2 -2
- package/lib/typescript/social/components/SelectedMediaComponent/SelectedMediaComponent.d.ts.map +1 -1
- package/lib/typescript/social/components/legacy/LoadingVideo/index.d.ts.map +1 -1
- package/lib/typescript/social/elements/PostMediaElement/PostMediaElement.d.ts.map +1 -1
- package/lib/typescript/social/elements/PostMediaElement/styles.d.ts +4 -0
- package/lib/typescript/social/elements/PostMediaElement/styles.d.ts.map +1 -1
- package/lib/typescript/social/features/community/PendingRequest/components/PendingPostList/PendingPostList.d.ts.map +1 -1
- package/lib/typescript/social/features/feed/components/NewsFeed/NewsFeed.d.ts.map +1 -1
- package/lib/typescript/social/features/post/Composer/PostComposer.d.ts.map +1 -1
- package/lib/typescript/social/hooks/index.d.ts +1 -0
- package/lib/typescript/social/hooks/index.d.ts.map +1 -1
- package/lib/typescript/social/hooks/useCommunities.d.ts +2 -1
- package/lib/typescript/social/hooks/useCommunities.d.ts.map +1 -1
- package/lib/typescript/social/hooks/useCommunityPermission.d.ts +14 -0
- package/lib/typescript/social/hooks/useCommunityPermission.d.ts.map +1 -0
- package/lib/typescript/social/hooks/useCustomRankingGlobalFeed.d.ts.map +1 -1
- package/lib/typescript/social/hooks/useFile.d.ts +11 -0
- package/lib/typescript/social/hooks/useFile.d.ts.map +1 -1
- package/lib/typescript/social/screens/CommunityProfile/components/Header/Header.d.ts.map +1 -1
- package/lib/typescript/social/utils/mediaAttachments.d.ts +91 -0
- package/lib/typescript/social/utils/mediaAttachments.d.ts.map +1 -0
- package/lib/typescript/social/utils/postChildren.d.ts +38 -0
- package/lib/typescript/social/utils/postChildren.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/core/assets/icons/post.tsx +1 -1
- package/src/core/assets/icons/story.tsx +1 -1
- package/src/core/assets/icons/xml.ts +15 -0
- package/src/core/legacy/file.tsx +169 -84
- package/src/core/stores/slices/feedSlice.ts +3 -0
- package/src/core/stores/slices/globalfeedSlice.ts +5 -0
- package/src/core/stores/slices/localVideoThumbnailSlice.ts +58 -0
- package/src/core/stores/slices/uiSlice.ts +8 -0
- package/src/core/stores/store/index.ts +2 -0
- package/src/core/types/mention.ts +34 -0
- package/src/social/components/LoadingImage/index.tsx +81 -12
- package/src/social/components/LoadingImage/styles.ts +8 -3
- package/src/social/components/LoadingVideo/index.tsx +111 -21
- package/src/social/components/LoadingVideo/styles.ts +13 -4
- package/src/social/components/MediaViewer/MediaViewer.tsx +11 -12
- package/src/social/components/MediaViewer/styles.ts +9 -1
- package/src/social/components/PostContent/index.tsx +3 -35
- package/src/social/components/SelectedMediaComponent/SelectedMediaComponent.tsx +103 -13
- package/src/social/components/legacy/LoadingVideo/index.tsx +26 -15
- package/src/social/elements/PostMediaElement/PostMediaElement.tsx +139 -29
- package/src/social/elements/PostMediaElement/styles.ts +7 -0
- package/src/social/features/community/PendingRequest/components/PendingPostList/PendingPostList.tsx +11 -6
- package/src/social/features/feed/components/NewsFeed/NewsFeed.tsx +16 -1
- package/src/social/features/post/Composer/PostComposer.tsx +304 -91
- package/src/social/hooks/index.ts +1 -0
- package/src/social/hooks/useCommunities.ts +4 -2
- package/src/social/hooks/useCommunityPermission.ts +40 -0
- package/src/social/hooks/useCustomRankingGlobalFeed.ts +8 -1
- package/src/social/hooks/useFile.ts +11 -0
- package/src/social/screens/CommunityProfile/components/Header/Header.tsx +19 -10
- package/src/social/utils/mediaAttachments.ts +158 -0
- package/src/social/utils/postChildren.ts +85 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MAX_MEDIA_ATTACHMENTS = void 0;
|
|
7
|
+
exports.appendWithinCap = appendWithinCap;
|
|
8
|
+
exports.applyFinishedUpload = applyFinishedUpload;
|
|
9
|
+
exports.dedupeMediaPicks = dedupeMediaPicks;
|
|
10
|
+
exports.toLocalVideoThumbnails = toLocalVideoThumbnails;
|
|
11
|
+
exports.toggleUploadingSource = toggleUploadingSource;
|
|
12
|
+
/**
|
|
13
|
+
* The composer caps a post at 10 attachments of a single media type.
|
|
14
|
+
*/
|
|
15
|
+
const MAX_MEDIA_ATTACHMENTS = exports.MAX_MEDIA_ATTACHMENTS = 10;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The identity fields a staged attachment must carry for the helpers below to
|
|
19
|
+
* recognise it across its own upload. See `IDisplayImage.localId`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Drop the candidates that are already staged, and any repeated inside the
|
|
24
|
+
* batch itself, preserving the order of the ones that survive.
|
|
25
|
+
*
|
|
26
|
+
* De-duplication runs against the LOCAL identity, never `fileName`: the moment
|
|
27
|
+
* an item finishes uploading the composer rewrites its `fileName` to the
|
|
28
|
+
* server's `attributes.name`, and edit-mode entries are hydrated with the
|
|
29
|
+
* fileId, so a set built from `fileName` compares server-side names against
|
|
30
|
+
* picker names and never matches. `localId` / `localFileName` are assigned once
|
|
31
|
+
* at pick time and survive the upload, so they still line up here.
|
|
32
|
+
*
|
|
33
|
+
* `localFileName` is a second key next to `localId` because the picker's
|
|
34
|
+
* `asset.id` is not populated by every configuration — the name is what catches
|
|
35
|
+
* a re-pick when no id came back. Camera captures deliberately carry no
|
|
36
|
+
* `localFileName`, so two shots never de-duplicate against each other.
|
|
37
|
+
*
|
|
38
|
+
* The drop is silent by design (no toast, no alert) and leaves the already
|
|
39
|
+
* staged copy exactly where it is, which is what keeps a re-pick of A followed
|
|
40
|
+
* by B and C rendering as A, B, C.
|
|
41
|
+
*/
|
|
42
|
+
function dedupeMediaPicks(staged, candidates) {
|
|
43
|
+
const seenIds = new Set(staged.map(item => item.localId).filter(Boolean));
|
|
44
|
+
const seenNames = new Set(staged.map(item => item.localFileName).filter(Boolean));
|
|
45
|
+
const additions = [];
|
|
46
|
+
for (const candidate of candidates) {
|
|
47
|
+
const {
|
|
48
|
+
localId,
|
|
49
|
+
localFileName
|
|
50
|
+
} = candidate;
|
|
51
|
+
if (seenIds.has(localId)) continue;
|
|
52
|
+
if (localFileName && seenNames.has(localFileName)) continue;
|
|
53
|
+
seenIds.add(localId);
|
|
54
|
+
if (localFileName) seenNames.add(localFileName);
|
|
55
|
+
additions.push(candidate);
|
|
56
|
+
}
|
|
57
|
+
return additions;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Append `additions` to `staged`, holding the 10-attachment cap.
|
|
62
|
+
*/
|
|
63
|
+
function appendWithinCap(staged, additions) {
|
|
64
|
+
const updated = [...staged, ...additions];
|
|
65
|
+
return updated.length > MAX_MEDIA_ATTACHMENTS ? updated.slice(0, MAX_MEDIA_ATTACHMENTS) : updated;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Route a finished upload back to the entry it actually belongs to, matched by
|
|
70
|
+
* the local path the child was mounted with.
|
|
71
|
+
*
|
|
72
|
+
* The child reports both a positional `index` and the `originalPath`. The index
|
|
73
|
+
* is the array position the frame was RENDERED at when the upload started —
|
|
74
|
+
* LoadingVideo goes further and memoises its uploader on `[source]` alone, so
|
|
75
|
+
* it freezes the index of the render where the source last changed. Writing
|
|
76
|
+
* `data[index]` therefore lands on whatever now sits at that position: a frame
|
|
77
|
+
* removed, an upload retried after the array grew, or a slow upload finishing
|
|
78
|
+
* after its neighbours moved all put one file's remote url onto another file's
|
|
79
|
+
* entry — which is what QA saw as an already-loaded image repainting with a
|
|
80
|
+
* different picture once the network came back. Matching on `originalPath` is
|
|
81
|
+
* exact: a not-yet-uploaded entry's `url` IS the local path its child was
|
|
82
|
+
* handed, and pick de-duplication guarantees those are unique across the array.
|
|
83
|
+
*
|
|
84
|
+
* The patch is MERGED rather than replacing the entry: `localId` /
|
|
85
|
+
* `localFileName` are what the next pick de-duplicates against, and
|
|
86
|
+
* what the carousel keys its frames by, and the picker's width/height still
|
|
87
|
+
* classify the frame ratio — a wholesale replacement dropped all of them.
|
|
88
|
+
*
|
|
89
|
+
* No match means the entry is gone (closed mid-upload) or already finished, so
|
|
90
|
+
* the array is returned untouched rather than resurrecting or double-writing.
|
|
91
|
+
*/
|
|
92
|
+
function applyFinishedUpload(staged, originalPath, patch) {
|
|
93
|
+
const targetIndex = staged.findIndex(item => item.url === originalPath);
|
|
94
|
+
if (targetIndex === -1) return staged;
|
|
95
|
+
const updated = [...staged];
|
|
96
|
+
updated[targetIndex] = {
|
|
97
|
+
...updated[targetIndex],
|
|
98
|
+
...patch
|
|
99
|
+
};
|
|
100
|
+
return updated;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Add or remove a media item's `source` from the set of in-flight uploads.
|
|
105
|
+
*
|
|
106
|
+
* The composer gates Post/Save on this set being empty. It replaced a single
|
|
107
|
+
* shared boolean that whichever upload finished FIRST flipped back to false on
|
|
108
|
+
* behalf of every other frame, unlocking Post while the rest were still
|
|
109
|
+
* uploading.
|
|
110
|
+
*
|
|
111
|
+
* Returns the same set instance when nothing changes, so a redundant report —
|
|
112
|
+
* a child clearing on unmount right after `handleLoadEnd` already cleared —
|
|
113
|
+
* does not trigger a re-render.
|
|
114
|
+
*/
|
|
115
|
+
function toggleUploadingSource(uploading, source, isUploading) {
|
|
116
|
+
if (isUploading === uploading.has(source)) return uploading;
|
|
117
|
+
const updated = new Set(uploading);
|
|
118
|
+
if (isUploading) {
|
|
119
|
+
updated.add(source);
|
|
120
|
+
} else {
|
|
121
|
+
updated.delete(source);
|
|
122
|
+
}
|
|
123
|
+
return updated;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The entries the feed's local-thumbnail bridge should hold for a just-created
|
|
128
|
+
* video post.
|
|
129
|
+
*
|
|
130
|
+
* A video's server thumbnail does not exist until transcoding finishes, so the
|
|
131
|
+
* feed falls back to the frame the composer decoded at pick time, matched on
|
|
132
|
+
* the uploaded video's fileId. Entries without both halves are dropped: a row
|
|
133
|
+
* with an empty url still satisfies the feed's lookup, which suppresses its own
|
|
134
|
+
* pending state and leaves the frame blank instead of showing the play button
|
|
135
|
+
* over a plain background.
|
|
136
|
+
*/
|
|
137
|
+
function toLocalVideoThumbnails(videos) {
|
|
138
|
+
return videos.reduce((acc, {
|
|
139
|
+
fileId,
|
|
140
|
+
thumbNail
|
|
141
|
+
}) => {
|
|
142
|
+
if (!fileId || !thumbNail) return acc;
|
|
143
|
+
acc.push({
|
|
144
|
+
fileId,
|
|
145
|
+
thumbnailUrl: thumbNail
|
|
146
|
+
});
|
|
147
|
+
return acc;
|
|
148
|
+
}, []);
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=mediaAttachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MAX_MEDIA_ATTACHMENTS","exports","dedupeMediaPicks","staged","candidates","seenIds","Set","map","item","localId","filter","Boolean","seenNames","localFileName","additions","candidate","has","add","push","appendWithinCap","updated","length","slice","applyFinishedUpload","originalPath","patch","targetIndex","findIndex","url","toggleUploadingSource","uploading","source","isUploading","delete","toLocalVideoThumbnails","videos","reduce","acc","fileId","thumbNail","thumbnailUrl"],"sourceRoot":"../../../../src","sources":["social/utils/mediaAttachments.ts"],"mappings":";;;;;;;;;;;AAEA;AACA;AACA;AACO,MAAMA,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,EAAE;;AAEvC;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAC9BC,MAAuB,EACvBC,UAAe,EACV;EACL,MAAMC,OAAO,GAAG,IAAIC,GAAG,CACrBH,MAAM,CAACI,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,OAAO,CAAC,CAACC,MAAM,CAACC,OAAO,CACnD,CAAC;EACD,MAAMC,SAAS,GAAG,IAAIN,GAAG,CACvBH,MAAM,CAACI,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACK,aAAa,CAAC,CAACH,MAAM,CAACC,OAAO,CACzD,CAAC;EAED,MAAMG,SAAc,GAAG,EAAE;EACz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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,qBAAqBA,CACnCC,SAAsB,EACtBC,MAAc,EACdC,WAAoB,EACP;EACb,IAAIA,WAAW,KAAKF,SAAS,CAACd,GAAG,CAACe,MAAM,CAAC,EAAE,OAAOD,SAAS;EAC3D,MAAMV,OAAO,GAAG,IAAId,GAAG,CAACwB,SAAS,CAAC;EAClC,IAAIE,WAAW,EAAE;IACfZ,OAAO,CAACH,GAAG,CAACc,MAAM,CAAC;EACrB,CAAC,MAAM;IACLX,OAAO,CAACa,MAAM,CAACF,MAAM,CAAC;EACxB;EACA,OAAOX,OAAO;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASc,sBAAsBA,CACpCC,MAAqD,EACT;EAC5C,OAAOA,MAAM,CAACC,MAAM,CAClB,CAACC,GAAG,EAAE;IAAEC,MAAM;IAAEC;EAAU,CAAC,KAAK;IAC9B,IAAI,CAACD,MAAM,IAAI,CAACC,SAAS,EAAE,OAAOF,GAAG;IAErCA,GAAG,CAACnB,IAAI,CAAC;MAAEoB,MAAM;MAAEE,YAAY,EAAED;IAAU,CAAC,CAAC;IAC7C,OAAOF,GAAG;EACZ,CAAC,EACD,EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.classifyPostChildren = classifyPostChildren;
|
|
7
|
+
/** A post child as the feed resolves it: the child post plus its own payload. */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Sort a post's resolved children into what each surface needs.
|
|
11
|
+
*
|
|
12
|
+
* Every hop into a child's payload is guarded, because the cost of being wrong
|
|
13
|
+
* is out of proportion to the saving: an ErrorBoundary sits around the whole
|
|
14
|
+
* UIKit without an onError, so one TypeError in here replaces the entire app
|
|
15
|
+
* with a generic error page and takes its own stack down with it.
|
|
16
|
+
*
|
|
17
|
+
* `ContentDataVideo` types `videoFileId` as always present but every size
|
|
18
|
+
* inside it as optional, so `original` is the hop that can legitimately be
|
|
19
|
+
* missing. The keys above it are guarded on the same principle rather than on
|
|
20
|
+
* evidence that they go missing.
|
|
21
|
+
*/
|
|
22
|
+
function classifyPostChildren(children, apiRegion) {
|
|
23
|
+
const images = [];
|
|
24
|
+
const videos = [];
|
|
25
|
+
const polls = [];
|
|
26
|
+
const livestreams = [];
|
|
27
|
+
const media = [];
|
|
28
|
+
children.forEach(item => {
|
|
29
|
+
var _item$data, _item$data2, _item$data4, _item$data6;
|
|
30
|
+
if ((item === null || item === void 0 ? void 0 : item.dataType) === 'image' && item !== null && item !== void 0 && (_item$data = item.data) !== null && _item$data !== void 0 && _item$data.fileId) {
|
|
31
|
+
const url = `https://api.${apiRegion}.amity.co/api/v3/files/${item.data.fileId}/download?size=medium`;
|
|
32
|
+
if (!images.includes(url)) {
|
|
33
|
+
images.push(url);
|
|
34
|
+
if (item.post) media.push(item.post);
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if ((item === null || item === void 0 ? void 0 : item.dataType) === 'video' && item !== null && item !== void 0 && (_item$data2 = item.data) !== null && _item$data2 !== void 0 && (_item$data2 = _item$data2.videoFileId) !== null && _item$data2 !== void 0 && _item$data2.original) {
|
|
39
|
+
const isExisted = videos.some(video => {
|
|
40
|
+
var _video$videoFileId, _item$data3;
|
|
41
|
+
return ((_video$videoFileId = video.videoFileId) === null || _video$videoFileId === void 0 ? void 0 : _video$videoFileId.original) === ((_item$data3 = item.data) === null || _item$data3 === void 0 || (_item$data3 = _item$data3.videoFileId) === null || _item$data3 === void 0 ? void 0 : _item$data3.original);
|
|
42
|
+
});
|
|
43
|
+
if (!isExisted) {
|
|
44
|
+
videos.push(item.data);
|
|
45
|
+
if (item.post) media.push(item.post);
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if ((item === null || item === void 0 ? void 0 : item.dataType) === 'poll' && item !== null && item !== void 0 && (_item$data4 = item.data) !== null && _item$data4 !== void 0 && _item$data4.pollId) {
|
|
50
|
+
if (!polls.some(poll => {
|
|
51
|
+
var _item$data5;
|
|
52
|
+
return poll.pollId === ((_item$data5 = item.data) === null || _item$data5 === void 0 ? void 0 : _item$data5.pollId);
|
|
53
|
+
})) {
|
|
54
|
+
polls.push(item.data);
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if ((item === null || item === void 0 ? void 0 : item.dataType) === 'room' && item !== null && item !== void 0 && (_item$data6 = item.data) !== null && _item$data6 !== void 0 && _item$data6.roomId) {
|
|
59
|
+
if (!livestreams.includes(item.data.roomId)) {
|
|
60
|
+
livestreams.push(item.data.roomId);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
images,
|
|
66
|
+
videos,
|
|
67
|
+
polls,
|
|
68
|
+
livestreams,
|
|
69
|
+
media
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=postChildren.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["classifyPostChildren","children","apiRegion","images","videos","polls","livestreams","media","forEach","item","_item$data","_item$data2","_item$data4","_item$data6","dataType","data","fileId","url","includes","push","post","videoFileId","original","isExisted","some","video","_video$videoFileId","_item$data3","pollId","poll","_item$data5","roomId"],"sourceRoot":"../../../../src","sources":["social/utils/postChildren.ts"],"mappings":";;;;;;AAEA;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAoBA,CAClCC,QAA6B,EAC7BC,SAAiB,EACO;EACxB,MAAMC,MAAgB,GAAG,EAAE;EAC3B,MAAMC,MAAoB,GAAG,EAAE;EAC/B,MAAMC,KAA2B,GAAG,EAAE;EACtC,MAAMC,WAAmC,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|
height = 24,
|
|
5
|
-
fill = '
|
|
5
|
+
fill = 'currentColor'
|
|
6
6
|
} = props || {};
|
|
7
7
|
return `<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
8
8
|
<path d="M16.0078 15.3789L17.1328 14.2539C17.3086 14.0781 17.625 14.2188 17.625 14.4648V19.5625C17.625 20.5117 16.8516 21.25 15.9375 21.25H3.5625C2.61328 21.25 1.875 20.5117 1.875 19.5625V7.1875C1.875 6.27344 2.61328 5.5 3.5625 5.5H13.1602C13.4062 5.5 13.5469 5.81641 13.3711 5.99219L12.2461 7.11719C12.1758 7.1875 12.1055 7.1875 12.0352 7.1875H3.5625V19.5625H15.9375V15.5898C15.9375 15.5195 15.9375 15.4492 16.0078 15.3789ZM21.4922 8.3125L12.2812 17.5234L9.08203 17.875C8.16797 17.9805 7.39453 17.207 7.5 16.293L7.85156 13.0938L17.0625 3.88281C17.8711 3.07422 19.1719 3.07422 19.9805 3.88281L21.4922 5.39453C22.3008 6.20312 22.3008 7.50391 21.4922 8.3125ZM18.0469 9.36719L16.0078 7.32812L9.46875 13.8672L9.1875 16.1875L11.5078 15.9062L18.0469 9.36719ZM20.2969 6.58984L18.7852 5.07812C18.6445 4.90234 18.3984 4.90234 18.2578 5.07812L17.2031 6.13281L19.2422 8.20703L20.332 7.11719C20.4727 6.94141 20.4727 6.73047 20.2969 6.58984Z" fill="${fill}"/>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["icon","props","width","height","fill"],"sourceRoot":"../../../../../src","sources":["core/assets/icons/post.tsx"],"mappings":"AAEA,MAAMA,IAAI,GAAIC,KAA+B,IAAK;EAChD,MAAM;IAAEC,KAAK,GAAG,EAAE;IAAEC,MAAM,GAAG,EAAE;IAAEC,IAAI,GAAG;
|
|
1
|
+
{"version":3,"names":["icon","props","width","height","fill"],"sourceRoot":"../../../../../src","sources":["core/assets/icons/post.tsx"],"mappings":"AAEA,MAAMA,IAAI,GAAIC,KAA+B,IAAK;EAChD,MAAM;IAAEC,KAAK,GAAG,EAAE;IAAEC,MAAM,GAAG,EAAE;IAAEC,IAAI,GAAG;EAAe,CAAC,GAAGH,KAAK,IAAI,CAAC,CAAC;EAEtE,OAAO,eAAeC,KAAK,aAAaC,MAAM,kBAAkBD,KAAK,IAAIC,MAAM;AACjF,06BAA06BC,IAAI;AAC96B;AACA,CAAC;AACD,CAAC;AAED,eAAeJ,IAAI","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["icon","props","width","height","fill"],"sourceRoot":"../../../../../src","sources":["core/assets/icons/story.tsx"],"mappings":"AAEA,MAAMA,IAAI,GAAIC,KAA+B,IAAK;EAChD,MAAM;IAAEC,KAAK,GAAG,EAAE;IAAEC,MAAM,GAAG,EAAE;IAAEC,IAAI,GAAG;
|
|
1
|
+
{"version":3,"names":["icon","props","width","height","fill"],"sourceRoot":"../../../../../src","sources":["core/assets/icons/story.tsx"],"mappings":"AAEA,MAAMA,IAAI,GAAIC,KAA+B,IAAK;EAChD,MAAM;IAAEC,KAAK,GAAG,EAAE;IAAEC,MAAM,GAAG,EAAE;IAAEC,IAAI,GAAG;EAAe,CAAC,GAAGH,KAAK,IAAI,CAAC,CAAC;EAEtE,OAAO;AACT,aAAaC,KAAK;AAClB,cAAcC,MAAM;AACpB,mBAAmBD,KAAK,IAAIC,MAAM;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcC,IAAI;AAClB;AACA;AACA;AACA,cAAcA,IAAI;AAClB;AACA,SAAS;AACT,CAAC;AAED,eAAeJ,IAAI","ignoreList":[]}
|
|
@@ -50,6 +50,19 @@ export const postIconOutlined = (color = '#292B32') => `<svg width="22" height="
|
|
|
50
50
|
export const closeIcon = (color = '#292B32') => `<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
51
51
|
<path d="M7.65234 6.25L11.4492 2.48828C11.6602 2.27734 11.6602 1.89062 11.4492 1.67969L10.5703 0.800781C10.3594 0.589844 9.97266 0.589844 9.76172 0.800781L6 4.59766L2.20312 0.800781C1.99219 0.589844 1.60547 0.589844 1.39453 0.800781L0.515625 1.67969C0.304688 1.89062 0.304688 2.27734 0.515625 2.48828L4.3125 6.25L0.515625 10.0469C0.304688 10.2578 0.304688 10.6445 0.515625 10.8555L1.39453 11.7344C1.60547 11.9453 1.99219 11.9453 2.20312 11.7344L6 7.9375L9.76172 11.7344C9.97266 11.9453 10.3594 11.9453 10.5703 11.7344L11.4492 10.8555C11.6602 10.6445 11.6602 10.2578 11.4492 10.0469L7.65234 6.25Z" fill="${color}"/>
|
|
52
52
|
</svg>`;
|
|
53
|
+
// Ported verbatim from web UIKit icons/Close, for the carousel composer's
|
|
54
|
+
// per-frame remove button.
|
|
55
|
+
//
|
|
56
|
+
// Not a swap for `closeIcon` above, which eleven other screens render — the
|
|
57
|
+
// difference that matters here is that this one carries its padding INSIDE its
|
|
58
|
+
// own 32-unit viewBox: the cross spans 8.4 to 23.6, so it fills about 47% of
|
|
59
|
+
// the box against `closeIcon`'s near-100%. Rendered at 20 inside a 28dp disc it
|
|
60
|
+
// draws a ~9dp cross with the scrim still visible around it, which is exactly
|
|
61
|
+
// what web looks like. Using `closeIcon` at the same 20 filled the disc edge to
|
|
62
|
+
// edge and left a bare white X floating on the photo.
|
|
63
|
+
export const mediaRemoveIcon = (color = '#FFFFFF') => `<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
64
|
+
<path d="M18.2031 16.2861L23.2656 21.3486C23.5469 21.6299 23.5469 22.1455 23.2656 22.4268L22.0938 23.5986C21.8125 23.8799 21.2969 23.8799 21.0156 23.5986L16 18.5361L10.9375 23.5986C10.6562 23.8799 10.1406 23.8799 9.85938 23.5986L8.6875 22.4268C8.40625 22.1455 8.40625 21.6299 8.6875 21.3486L13.75 16.2861L8.6875 11.2705C8.40625 10.9893 8.40625 10.4736 8.6875 10.1924L9.85938 9.02051C10.1406 8.73926 10.6562 8.73926 10.9375 9.02051L16 14.083L21.0156 9.02051C21.2969 8.73926 21.8125 8.73926 22.0938 9.02051L23.2656 10.1924C23.5469 10.4736 23.5469 10.9893 23.2656 11.2705L18.2031 16.2861Z" fill="${color}"/>
|
|
65
|
+
</svg>`;
|
|
53
66
|
// Ported from web UIKit icons/MutedFilled (speaker + waves) — shown when audio
|
|
54
67
|
// is ON (unmuted). Used by the carousel full-screen media viewer.
|
|
55
68
|
export const soundOnIcon = (color = '#FFFFFF') => `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["likeXml","personXml","commentXml","likedXml","color","arrowXml","arrowOutlined","playBtn","replyIcon","postIcon","postIconOutlined","closeIcon","soundOnIcon","soundOffIcon","videoControlIcon","brokenImageIcon","clearIcon","playControlIcon","pauseControlIcon","cameraIcon","galleryIcon","playVideoIcon","arrowDown","arrowBack","searchIcon","circleCloseIcon","communityIcon","threeDots","privateIcon","officialIcon","plusIcon","categoryIcon","publicIcon","editIcon","userIcon","primaryDot","storyRing","colorOne","colorTwo","expandIcon","pollIcon","radioOn","radioOff","blockOrUnblock","unfollow","report","reportOutLine","photo","video","fileSearch","likeCircle","seenIcon","storyCommentIcon","storyLikedIcon","storyLikeIcon","storyHyperLinkIcon","storyCircleCreatePlusIcon","leftLongArrow","rightLongArrow","flashOn","flashOff","switchCamera","storyGallery","storyThreedotsMenu","storyDraftDeletHyperLink","toastIcon","arrowForward","likeReaction","circleColor","loveReaction","cancelFollowRequest","privateUserProfile","syncIcon","editThumbnailIcon","livestreamIcon","exclamationIcon","playIcon","stopIcon","toastSuccess","star","infoIcon","errorIcon"],"sourceRoot":"../../../../../src","sources":["core/assets/icons/xml.ts"],"mappings":"AAAA,OAAO,MAAMA,OAAe,GAAG;AAC/B;AACA,OAAO;AACP,OAAO,MAAMC,SAAiB,GAAG;AACjC;AACA;AACA;AACA,CAAC;AACD,OAAO,MAAMC,UAAkB,GAAG;AAClC;AACA;AACA,CAAC;AACD,OAAO,MAAMC,QAAQ,GAAGA,CACtBC,KAAa,GAAG,SAAS,KACd;AACb,q4BAAq4BA,KAAK;AAC14B,OAAO;AACP,OAAO,MAAMC,QAAgB,GAAG;AAChC;AACA,OAAO;AACP,OAAO,MAAMC,aAAa,GAAGA,CAC3BF,KAAa,GAAG,SAAS,KACd;AACb,yWAAyWA,KAAK;AAC9W;AACA,CAAC;AACD,OAAO,MAAMG,OAAe,GAAG;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,OAAO,MAAMC,SAAiB,GAAG;AACjC;AACA;AACA,CAAC;AACD,OAAO,MAAMC,QAAQ,GAAGA,CACtBL,KAAa,GAAG,SAAS,KACd;AACb,muBAAmuBA,KAAK;AACxuB;AACA,CAAC;AACD,OAAO,MAAMM,gBAAgB,GAAGA,CAC9BN,KAAa,GAAG,SAAS,KACd;AACb,g7BAAg7BA,KAAK;AACr7B;AACA,CAAC;AACD,OAAO,MAAMO,SAAS,GAAGA,CACvBP,KAAa,GAAG,SAAS,KACd;AACb,6lBAA6lBA,KAAK;AAClmB,OAAO;AACP;AACA;AACA,OAAO,MAAMQ,WAAW,GAAGA,
|
|
1
|
+
{"version":3,"names":["likeXml","personXml","commentXml","likedXml","color","arrowXml","arrowOutlined","playBtn","replyIcon","postIcon","postIconOutlined","closeIcon","mediaRemoveIcon","soundOnIcon","soundOffIcon","videoControlIcon","brokenImageIcon","clearIcon","playControlIcon","pauseControlIcon","cameraIcon","galleryIcon","playVideoIcon","arrowDown","arrowBack","searchIcon","circleCloseIcon","communityIcon","threeDots","privateIcon","officialIcon","plusIcon","categoryIcon","publicIcon","editIcon","userIcon","primaryDot","storyRing","colorOne","colorTwo","expandIcon","pollIcon","radioOn","radioOff","blockOrUnblock","unfollow","report","reportOutLine","photo","video","fileSearch","likeCircle","seenIcon","storyCommentIcon","storyLikedIcon","storyLikeIcon","storyHyperLinkIcon","storyCircleCreatePlusIcon","leftLongArrow","rightLongArrow","flashOn","flashOff","switchCamera","storyGallery","storyThreedotsMenu","storyDraftDeletHyperLink","toastIcon","arrowForward","likeReaction","circleColor","loveReaction","cancelFollowRequest","privateUserProfile","syncIcon","editThumbnailIcon","livestreamIcon","exclamationIcon","playIcon","stopIcon","toastSuccess","star","infoIcon","errorIcon"],"sourceRoot":"../../../../../src","sources":["core/assets/icons/xml.ts"],"mappings":"AAAA,OAAO,MAAMA,OAAe,GAAG;AAC/B;AACA,OAAO;AACP,OAAO,MAAMC,SAAiB,GAAG;AACjC;AACA;AACA;AACA,CAAC;AACD,OAAO,MAAMC,UAAkB,GAAG;AAClC;AACA;AACA,CAAC;AACD,OAAO,MAAMC,QAAQ,GAAGA,CACtBC,KAAa,GAAG,SAAS,KACd;AACb,q4BAAq4BA,KAAK;AAC14B,OAAO;AACP,OAAO,MAAMC,QAAgB,GAAG;AAChC;AACA,OAAO;AACP,OAAO,MAAMC,aAAa,GAAGA,CAC3BF,KAAa,GAAG,SAAS,KACd;AACb,yWAAyWA,KAAK;AAC9W;AACA,CAAC;AACD,OAAO,MAAMG,OAAe,GAAG;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,OAAO,MAAMC,SAAiB,GAAG;AACjC;AACA;AACA,CAAC;AACD,OAAO,MAAMC,QAAQ,GAAGA,CACtBL,KAAa,GAAG,SAAS,KACd;AACb,muBAAmuBA,KAAK;AACxuB;AACA,CAAC;AACD,OAAO,MAAMM,gBAAgB,GAAGA,CAC9BN,KAAa,GAAG,SAAS,KACd;AACb,g7BAAg7BA,KAAK;AACr7B;AACA,CAAC;AACD,OAAO,MAAMO,SAAS,GAAGA,CACvBP,KAAa,GAAG,SAAS,KACd;AACb,6lBAA6lBA,KAAK;AAClmB,OAAO;AACP;AACA;AACA;A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,onBAAonBA,KAAK;AACznB,OAAO;AAEP,OAAO,MAAMyE,QAAQ,GAAGA,CAACzE,KAAa,GAAG,SAAS,KAChD,8XAA8XA,KAAK,UAAU;AAE/Y,OAAO,MAAM0E,QAAQ,GAAGA,CAAC1E,KAAa,GAAG,SAAS,KAChD;AACF,uDAAuDA,KAAK;AAC5D,OAAO;AACP,OAAO,MAAM2E,YAAY,GAAGA,CAC1B3E,KAAa,GAAG,MAAM,KACnB;AACL,suBAAsuBA,KAAK;AAC3uB,OAAO;AACP,OAAO,MAAM4E,IAAI,GAAGA,CAClB5E,KAAa,GAAG,MAAM,KACnB;AACL,wZAAwZA,KAAK;AAC7Z;AACA,CAAC;AACD,OAAO,MAAM6E,QAAQ,GAAGA,CACtB7E,KAAa,GAAG,SAAS,KACd;AACb,m3BAAm3BA,KAAK;AACx3B,OAAO;AACP,OAAO,MAAM8E,SAAS,GAAGA,CACvB9E,KAAa,GAAG,MAAM,KACX;AACb;AACA,+QAA+QA,KAAK;AACpR,OAAO","ignoreList":[]}
|
|
@@ -1,80 +1,163 @@
|
|
|
1
1
|
import { FileRepository, ContentFeedType } from '@amityco/ts-sdk-react-native';
|
|
2
|
+
import NetInfo from '@react-native-community/netinfo';
|
|
2
3
|
import { Platform } from 'react-native';
|
|
3
4
|
import { appendFileToFormData } from '../utils/fileUpload';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The rejection shape every uploader in this module throws.
|
|
8
|
+
*
|
|
9
|
+
* `LoadingImage` / `LoadingVideo` currently ignore the thrown value and show a
|
|
10
|
+
* generic toast, so the contract is deliberately loose — but keeping one shape
|
|
11
|
+
* means a caller that *does* want to branch (e.g. the `INVALID_IMAGE`
|
|
12
|
+
* moderation case) can read `code` instead of sniffing strings.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Thrown when the SDK resolves without a payload. A 2xx with no `data` is still
|
|
17
|
+
* a failed upload as far as the caller is concerned — the callers immediately
|
|
18
|
+
* read `file[0]?.fileId`, so resolving `undefined` would only move the failure
|
|
19
|
+
* somewhere less diagnosable.
|
|
20
|
+
*/
|
|
21
|
+
const NO_FILE_DATA_ERROR = {
|
|
22
|
+
message: 'Upload failed - no file data returned'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Thrown before an attempt is even made when the device has no connection.
|
|
27
|
+
*
|
|
28
|
+
* Rejecting up front is not belt-and-braces — on iOS it is the only thing that
|
|
29
|
+
* produces a failure at all. Android's networking stack rejects an offline
|
|
30
|
+
* request almost immediately, so the uploaders' `catch` ran and the frame
|
|
31
|
+
* showed its error state; NSURLSession instead sits on the request waiting for
|
|
32
|
+
* connectivity, so the promise never settled, the `catch` never ran, and the
|
|
33
|
+
* frame stayed on its spinner forever with no way to reach the failed state
|
|
34
|
+
* The spec asks for an error state per attachment that failed to upload,
|
|
35
|
+
* whatever the platform.
|
|
36
|
+
*/
|
|
37
|
+
const OFFLINE_ERROR = {
|
|
38
|
+
message: 'Upload failed - no internet connection',
|
|
39
|
+
code: 'OFFLINE'
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Reject immediately when there is no connection, rather than handing the
|
|
44
|
+
* request to a networking stack that may never answer.
|
|
45
|
+
*
|
|
46
|
+
* Only covers being offline as the attempt STARTS. A connection dropped
|
|
47
|
+
* mid-upload still leaves iOS waiting, because nothing here can abort a
|
|
48
|
+
* request already inside the SDK — the composer's reconnect retry is what
|
|
49
|
+
* eventually recovers that case.
|
|
50
|
+
*/
|
|
51
|
+
async function assertOnline() {
|
|
52
|
+
const state = await NetInfo.fetch();
|
|
53
|
+
if (!state.isConnected) throw OFFLINE_ERROR;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Normalise whatever the SDK / networking layer threw into an `UploadError`.
|
|
58
|
+
*
|
|
59
|
+
* A dropped connection surfaces here as a plain `Error` ("Network request
|
|
60
|
+
* failed") carrying no Amity error code — which is exactly the reported repro:
|
|
61
|
+
* the user toggles the network off mid-upload and the request rejects.
|
|
62
|
+
*/
|
|
63
|
+
function toUploadError(error) {
|
|
64
|
+
return {
|
|
65
|
+
message: 'Upload failed',
|
|
66
|
+
details: (error === null || error === void 0 ? void 0 : error.message) || "We couldn't complete your upload. Please try again.",
|
|
67
|
+
originalError: error
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Every uploader below is a plain `async` function with try/catch,
|
|
73
|
+
* NOT `new Promise(async (resolve, reject) => …)`.
|
|
74
|
+
*
|
|
75
|
+
* The old wrapper was actively harmful, not merely redundant. An `async`
|
|
76
|
+
* executor returns a promise that `new Promise` neither awaits nor observes, so
|
|
77
|
+
* anything the executor threw — and a mid-upload network drop makes
|
|
78
|
+
* `FileRepository.upload*` throw — settled only that orphaned promise. The
|
|
79
|
+
* outer promise stayed **pending forever**: `LoadingVideo.uploadFileToAmity`
|
|
80
|
+
* sat awaiting it, its `catch` never ran, `handleLoadEnd()` was never called,
|
|
81
|
+
* `loading` stayed `true`, and the frame kept spinning even after the
|
|
82
|
+
* connection came back, so the tappable retry overlay was unreachable.
|
|
83
|
+
*
|
|
84
|
+
* Throwing from an `async` function has no such hole: a `throw` anywhere in the
|
|
85
|
+
* body — including from code the function `await`ed — settles the promise it
|
|
86
|
+
* returned. `uploadImageFile` already had the try/catch, which is
|
|
87
|
+
* why the image path showed a failed state while the video path hung.
|
|
88
|
+
*/
|
|
4
89
|
export async function uploadFile(filePath, perCentCallback) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
90
|
+
const formData = new FormData();
|
|
91
|
+
const parts = filePath.split('/');
|
|
92
|
+
const fileName = parts[parts.length - 1];
|
|
93
|
+
const fileType = Platform.OS === 'ios' ? 'image/jpeg' : 'image/jpg';
|
|
94
|
+
let file;
|
|
95
|
+
await assertOnline();
|
|
96
|
+
try {
|
|
97
|
+
appendFileToFormData(formData, 'files', filePath, fileName, fileType);
|
|
98
|
+
({
|
|
12
99
|
data: file
|
|
13
100
|
} = await FileRepository.uploadFile(formData, percent => {
|
|
14
101
|
perCentCallback && perCentCallback(percent);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
102
|
+
}));
|
|
103
|
+
} catch (error) {
|
|
104
|
+
throw toUploadError(error);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Deliberately outside the try: an empty payload is not an exception to
|
|
108
|
+
// re-wrap, and throwing it in here would round-trip it through
|
|
109
|
+
// `toUploadError` and lose the specific message.
|
|
110
|
+
if (!file) throw NO_FILE_DATA_ERROR;
|
|
111
|
+
return file;
|
|
22
112
|
}
|
|
23
113
|
export async function uploadImageFile(filePath, perCentCallback) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
message: 'Inappropriate image',
|
|
48
|
-
details: 'Please choose a different image to upload.',
|
|
49
|
-
code: 'INVALID_IMAGE'
|
|
50
|
-
});
|
|
51
|
-
} else {
|
|
52
|
-
reject({
|
|
53
|
-
message: 'Upload failed',
|
|
54
|
-
details: (error === null || error === void 0 ? void 0 : error.message) || "We couldn't complete your upload. Please try again.",
|
|
55
|
-
originalError: error
|
|
56
|
-
});
|
|
57
|
-
}
|
|
114
|
+
const formData = new FormData();
|
|
115
|
+
const parts = filePath.split('/');
|
|
116
|
+
const fileName = parts[parts.length - 1];
|
|
117
|
+
const fileType = Platform.OS === 'ios' ? 'image/jpeg' : 'image/jpg';
|
|
118
|
+
let file;
|
|
119
|
+
await assertOnline();
|
|
120
|
+
try {
|
|
121
|
+
appendFileToFormData(formData, 'files', filePath, fileName, fileType);
|
|
122
|
+
({
|
|
123
|
+
data: file
|
|
124
|
+
} = await FileRepository.uploadImage(formData, percent => {
|
|
125
|
+
perCentCallback && perCentCallback(percent);
|
|
126
|
+
}));
|
|
127
|
+
} catch (error) {
|
|
128
|
+
var _error$message, _error$message2;
|
|
129
|
+
// Moderation rejects the image server-side; that is spelled out here
|
|
130
|
+
// rather than folded into the generic "please try again" copy.
|
|
131
|
+
if (error !== null && error !== void 0 && (_error$message = error.message) !== null && _error$message !== void 0 && _error$message.includes('INVALID_IMAGE') || error !== null && error !== void 0 && (_error$message2 = error.message) !== null && _error$message2 !== void 0 && _error$message2.includes('Inappropriate')) {
|
|
132
|
+
throw {
|
|
133
|
+
message: 'Inappropriate image',
|
|
134
|
+
details: 'Please choose a different image to upload.',
|
|
135
|
+
code: 'INVALID_IMAGE'
|
|
136
|
+
};
|
|
58
137
|
}
|
|
59
|
-
|
|
138
|
+
throw toUploadError(error);
|
|
139
|
+
}
|
|
140
|
+
if (!file) throw NO_FILE_DATA_ERROR;
|
|
141
|
+
return file;
|
|
60
142
|
}
|
|
61
143
|
export async function uploadVideoFile(filePath, perCentCallback) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
144
|
+
const formData = new FormData();
|
|
145
|
+
const parts = filePath.split('/');
|
|
146
|
+
const fileName = parts[parts.length - 1];
|
|
147
|
+
let file;
|
|
148
|
+
await assertOnline();
|
|
149
|
+
try {
|
|
150
|
+
appendFileToFormData(formData, 'files', filePath, fileName, 'video/mp4');
|
|
151
|
+
({
|
|
68
152
|
data: file
|
|
69
153
|
} = await FileRepository.uploadVideo(formData, ContentFeedType.POST, percent => {
|
|
70
154
|
perCentCallback && perCentCallback(percent);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
});
|
|
155
|
+
}));
|
|
156
|
+
} catch (error) {
|
|
157
|
+
throw toUploadError(error);
|
|
158
|
+
}
|
|
159
|
+
if (!file) throw NO_FILE_DATA_ERROR;
|
|
160
|
+
return file;
|
|
78
161
|
}
|
|
79
162
|
export async function deleteAmityFile(fileId) {
|
|
80
163
|
const reactionObject = new Promise(async (resolve, reject) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FileRepository","ContentFeedType","Platform","appendFileToFormData","
|
|
1
|
+
{"version":3,"names":["FileRepository","ContentFeedType","NetInfo","Platform","appendFileToFormData","NO_FILE_DATA_ERROR","message","OFFLINE_ERROR","code","assertOnline","state","fetch","isConnected","toUploadError","error","details","originalError","uploadFile","filePath","perCentCallback","formData","FormData","parts","split","fileName","length","fileType","OS","file","data","percent","uploadImageFile","uploadImage","_error$message","_error$message2","includes","uploadVideoFile","uploadVideo","POST","deleteAmityFile","fileId","reactionObject","Promise","resolve","reject","isFileDeleted","deleteFile"],"sourceRoot":"../../../../src","sources":["core/legacy/file.tsx"],"mappings":"AAAA,SAASA,cAAc,EAAEC,eAAe,QAAQ,8BAA8B;AAE9E,OAAOC,OAAO,MAAM,iCAAiC;AACrD,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,oBAAoB,QAAQ,qBAAqB;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAA+B,GAAG;EACtCC,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAA0B,GAAG;EACjCD,OAAO,EAAE,wCAAwC;EACjDE,IAAI,EAAE;AACR,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeC,YAAYA,CAAA,EAAkB;EAC3C,M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ice = createSlice({
|
|
|
22
22
|
postDetail
|
|
23
23
|
} = action.payload;
|
|
24
24
|
const index = state.postList.findIndex(item => item.postId === postId);
|
|
25
|
+
// Same miss as in globalfeedSlice: a postId this list never held wrote a
|
|
26
|
+
// "-1" property instead of updating anything, leaving the entries stale.
|
|
27
|
+
if (index < 0) return;
|
|
25
28
|
state.postList[index] = postDetail;
|
|
26
29
|
},
|
|
27
30
|
deleteByPostId: (state, action) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSlice","initialState","postList","feedSlice","name","reducers","updateFeed","state","action","getUniqueArrayById","arr","uniqueIds","Set","map","post","postId","filter","has","payload","addPostToFeed","updateByPostId","postDetail","index","findIndex","item","deleteByPostId","prevPostList","updatedPostList","clearFeed"],"sourceRoot":"../../../../../src","sources":["core/stores/slices/feedSlice.ts"],"mappings":"AAAA,SAAwBA,WAAW,QAAQ,kBAAkB;AAK7D,MAAMC,YAAuB,GAAG;EAC9BC,QAAQ,EAAE;AACZ,CAAC;AAED,MAAMC,SAAS,GAAGH,WAAW,CAAC;EAC5BI,IAAI,EAAE,MAAM;EACZH,YAAY;EACZI,QAAQ,EAAE;IACRC,UAAU,EAAEA,CAACC,KAAK,EAAEC,MAAwC,KAAK;MAC/D,MAAMC,kBAAkB,GAAIC,GAAsB,IAAK;QACrD,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAACL,KAAK,CAACL,QAAQ,CAACW,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,MAAM,CAAC,CAAC;QACpE,OAAOL,GAAG,CAACM,MAAM,CAAEF,IAAI,IAAK,CAACH,SAAS,CAACM,GAAG,CAACH,IAAI,CAACC,MAAM,CAAC,CAAC;MAC1D,CAAC;MACDR,KAAK,CAACL,QAAQ,GAAG,CACf,GAAGO,kBAAkB,CAACD,MAAM,CAACU,OAAO,CAAC,EACrC,GAAGX,KAAK,CAACL,QAAQ,CAClB;IACH,CAAC;IACDiB,aAAa,EAAEA,CAACZ,KAAK,EAAEC,MAAsC,KAAK;MAChED,KAAK,CAACL,QAAQ,GAAG,CAACM,MAAM,CAACU,OAAO,EAAE,GAAGX,KAAK,CAACL,QAAQ,CAAC;IACtD,CAAC;IACDkB,cAAc,EAAEA,CACdb,KAAK,EACLC,MAAsE,KACnE;MACH,MAAM;QAAEO,MAAM;QAAEM;MAAW,CAAC,GAAGb,MAAM,CAACU,OAAO;MAC7C,MAAMI,KAAK,GAAGf,KAAK,CAACL,QAAQ,CAACqB,SAAS,CAAEC,IAAI,IAAKA,IAAI,CAACT,MAAM,KAAKA,MAAM,CAAC;
|
|
1
|
+
{"version":3,"names":["createSlice","initialState","postList","feedSlice","name","reducers","updateFeed","state","action","getUniqueArrayById","arr","uniqueIds","Set","map","post","postId","filter","has","payload","addPostToFeed","updateByPostId","postDetail","index","findIndex","item","deleteByPostId","prevPostList","updatedPostList","clearFeed"],"sourceRoot":"../../../../../src","sources":["core/stores/slices/feedSlice.ts"],"mappings":"AAAA,SAAwBA,WAAW,QAAQ,kBAAkB;AAK7D,MAAMC,YAAuB,GAAG;EAC9BC,QAAQ,EAAE;AACZ,CAAC;AAED,MAAMC,SAAS,GAAGH,WAAW,CAAC;EAC5BI,IAAI,EAAE,MAAM;EACZH,YAAY;EACZI,QAAQ,EAAE;IACRC,UAAU,EAAEA,CAACC,KAAK,EAAEC,MAAwC,KAAK;MAC/D,MAAMC,kBAAkB,GAAIC,GAAsB,IAAK;QACrD,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAACL,KAAK,CAACL,QAAQ,CAACW,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,MAAM,CAAC,CAAC;QACpE,OAAOL,GAAG,CAACM,MAAM,CAAEF,IAAI,IAAK,CAACH,SAAS,CAACM,GAAG,CAACH,IAAI,CAACC,MAAM,CAAC,CAAC;MAC1D,CAAC;MACDR,KAAK,CAACL,QAAQ,GAAG,CACf,GAAGO,kBAAkB,CAACD,MAAM,CAACU,OAAO,CAAC,EACrC,GAAGX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