@openpeepshq/rn-components 0.7.0 → 0.7.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.
- package/LICENSE.md +21 -0
- package/README.md +63 -0
- package/metro/css-interop-observable.js +41 -0
- package/metro/resolve-asset-source.js +19 -0
- package/metro.js +67 -0
- package/package.json +1 -1
- package/react-native.config.js +5 -0
- package/src/assets/audio/click-notification.wav +0 -0
- package/src/assets/images/audio-container.png +0 -0
- package/src/assets/images/black-ambition-2025-hero.png +0 -0
- package/src/assets/images/default-group-avatar.png +0 -0
- package/src/assets/images/event-placeholder.png +0 -0
- package/src/assets/images/group-header-placeholder.png +0 -0
- package/src/assets/images/jam-placeholder.png +0 -0
- package/src/assets/images/logo.webp +0 -0
- package/src/assets/images/profile-background-placeholder.png +0 -0
- package/src/assets/images/success.webp +0 -0
- package/src/assets/images/welcome-bg.webp +0 -0
- package/src/components/CapabilityMatrix.tsx +218 -0
- package/src/components/configuration/ConfigMenuButton.tsx +48 -0
- package/src/components/configuration/index.ts +1 -0
- package/src/components/conversations/ConversationMessageBubble.tsx +51 -0
- package/src/components/conversations/ConversationParticipantsModal.tsx +46 -0
- package/src/components/conversations/ConversationPreviewCard.tsx +158 -0
- package/src/components/conversations/ConversationProfileHeader.tsx +28 -0
- package/src/components/conversations/ConversationSettingsSheet.tsx +81 -0
- package/src/components/conversations/CreateNewConversationContext.tsx +71 -0
- package/src/components/conversations/DirectMessagesHeaderActions.tsx +24 -0
- package/src/components/conversations/MessageInThread.tsx +131 -0
- package/src/components/conversations/index.ts +8 -0
- package/src/components/custom/common/Loader.tsx +67 -0
- package/src/components/custom/common/agenda-tabs.tsx +47 -0
- package/src/components/custom/common/audio-player.tsx +219 -0
- package/src/components/custom/common/cached-image.tsx +34 -0
- package/src/components/custom/common/cached-video-player.tsx +497 -0
- package/src/components/custom/common/empty-state-container.tsx +58 -0
- package/src/components/custom/common/image-grid.tsx +95 -0
- package/src/components/custom/common/index.ts +12 -0
- package/src/components/custom/common/infinite-scroll-container.tsx +99 -0
- package/src/components/custom/common/media-upload-progress.tsx +109 -0
- package/src/components/custom/common/participant-avatar.tsx +34 -0
- package/src/components/custom/common/popover.tsx +268 -0
- package/src/components/custom/common/select.tsx +215 -0
- package/src/components/custom/date/formatter.ts +24 -0
- package/src/components/custom/date/index.ts +3 -0
- package/src/components/custom/date/timespan.tsx +49 -0
- package/src/components/custom/date/updating-date.tsx +31 -0
- package/src/components/custom/index.ts +4 -0
- package/src/components/custom/modals/common/base-sheet.tsx +104 -0
- package/src/components/custom/modals/common/index.ts +3 -0
- package/src/components/custom/modals/common/sheet-backdrop.tsx +14 -0
- package/src/components/custom/modals/common/sheet-footer.tsx +59 -0
- package/src/components/custom/modals/index.ts +3 -0
- package/src/components/custom/modals/media/alt-text-sheet.tsx +90 -0
- package/src/components/custom/modals/media/audio-picker-sheet.tsx +180 -0
- package/src/components/custom/modals/media/document-picker-sheet.tsx +384 -0
- package/src/components/custom/modals/media/image-picker-sheet.tsx +200 -0
- package/src/components/custom/modals/media/index.ts +7 -0
- package/src/components/custom/modals/media/record-audio-sheet.tsx +227 -0
- package/src/components/custom/modals/media/send-media-sheet.tsx +278 -0
- package/src/components/custom/modals/media/video-picker-sheet.tsx +109 -0
- package/src/components/custom/modals/settings/edit-notifications-sheet.tsx +184 -0
- package/src/components/custom/modals/settings/index.ts +1 -0
- package/src/components/custom/navigation/side-menu.tsx +223 -0
- package/src/components/form/HeaderAvatarInput.tsx +108 -0
- package/src/components/form/ImageInput.tsx +86 -0
- package/src/components/form/RadioSelect.tsx +58 -0
- package/src/components/form/TimeZoneSelect.tsx +97 -0
- package/src/components/form/index.ts +4 -0
- package/src/components/groups/AddGroupMemberModal.tsx +58 -0
- package/src/components/groups/AddGroupMembersButton.tsx +39 -0
- package/src/components/groups/ChangeGroupRolesModal.tsx +121 -0
- package/src/components/groups/ConfirmGroupExitModal.tsx +66 -0
- package/src/components/groups/ConfirmMemberRemovalModal.tsx +73 -0
- package/src/components/groups/DeleteGroupModal.tsx +68 -0
- package/src/components/groups/GroupAvatar.tsx +73 -0
- package/src/components/groups/GroupCapabilityMatrix.tsx +40 -0
- package/src/components/groups/GroupCard.tsx +84 -0
- package/src/components/groups/GroupFeed.tsx +25 -0
- package/src/components/groups/GroupForm.tsx +148 -0
- package/src/components/groups/GroupHeader.tsx +74 -0
- package/src/components/groups/GroupMembersList.tsx +194 -0
- package/src/components/groups/GroupNameFromId.tsx +17 -0
- package/src/components/groups/GroupNotificationSettingsModal.tsx +139 -0
- package/src/components/groups/GroupOptionsMenu.tsx +183 -0
- package/src/components/groups/GroupShareMenu.tsx +130 -0
- package/src/components/groups/JoinGroupButton.tsx +42 -0
- package/src/components/groups/index.ts +18 -0
- package/src/components/icons/iconWithClassName.ts +12 -0
- package/src/components/icons/index.ts +289 -0
- package/src/components/icons/types.ts +4 -0
- package/src/components/index.ts +12 -0
- package/src/components/jams/CreateNewJam.tsx +20 -0
- package/src/components/jams/CreateNewJamContext.tsx +36 -0
- package/src/components/jams/DeleteJamModal.tsx +69 -0
- package/src/components/jams/JamActionsFooter.tsx +85 -0
- package/src/components/jams/JamAnimatedEmoji.tsx +112 -0
- package/src/components/jams/JamCallParticipant.tsx +348 -0
- package/src/components/jams/JamCapacityGate.tsx +88 -0
- package/src/components/jams/JamCard.tsx +72 -0
- package/src/components/jams/JamChatDrawer.tsx +114 -0
- package/src/components/jams/JamChatMessage.tsx +86 -0
- package/src/components/jams/JamConference.tsx +69 -0
- package/src/components/jams/JamDesktopFooter.tsx +182 -0
- package/src/components/jams/JamDetailsDrawer.tsx +187 -0
- package/src/components/jams/JamDeviceSelectors.tsx +243 -0
- package/src/components/jams/JamDrawer.tsx +37 -0
- package/src/components/jams/JamFooter.tsx +241 -0
- package/src/components/jams/JamGuestForm.tsx +120 -0
- package/src/components/jams/JamLobby.tsx +203 -0
- package/src/components/jams/JamObserverShell.tsx +43 -0
- package/src/components/jams/JamParticipantConference.tsx +146 -0
- package/src/components/jams/JamPeopleDrawer.tsx +183 -0
- package/src/components/jams/JamReactionMenu.tsx +120 -0
- package/src/components/jams/JamRequestJoin.tsx +46 -0
- package/src/components/jams/JamRoom.tsx +194 -0
- package/src/components/jams/JamRoomIndicators.tsx +73 -0
- package/src/components/jams/JamRoomPanel.tsx +35 -0
- package/src/components/jams/JamToolbarButton.tsx +89 -0
- package/src/components/jams/JamVideoCall.tsx +50 -0
- package/src/components/jams/JamVideoLayout.tsx +401 -0
- package/src/components/jams/LeaveCloseButton.tsx +60 -0
- package/src/components/jams/LiveJamsSection.tsx +53 -0
- package/src/components/jams/index.ts +28 -0
- package/src/components/jams/useParticipantConnection.ts +43 -0
- package/src/components/layout/AuthLayout.tsx +156 -0
- package/src/components/layout/ContentHeader.tsx +62 -0
- package/src/components/layout/HeaderActionButton.tsx +23 -0
- package/src/components/layout/HeaderMobile.tsx +106 -0
- package/src/components/layout/PlusButton.tsx +34 -0
- package/src/components/layout/RootLayout.tsx +30 -0
- package/src/components/layout/index.ts +13 -0
- package/src/components/layout/pageChrome.test.tsx +147 -0
- package/src/components/layout/pageChrome.tsx +112 -0
- package/src/components/markdown/OpenpeepsMarkdown.tsx +129 -0
- package/src/components/markdown/extensions/codeBlock.tsx +63 -0
- package/src/components/markdown/extensions/codeInline.tsx +82 -0
- package/src/components/markdown/extensions/hashtag.tsx +77 -0
- package/src/components/markdown/extensions/html.test.tsx +172 -0
- package/src/components/markdown/extensions/html.tsx +116 -0
- package/src/components/markdown/extensions/mention.tsx +92 -0
- package/src/components/markdown/index.ts +2 -0
- package/src/components/markdown/theme.ts +59 -0
- package/src/components/markdown/utils.ts +34 -0
- package/src/components/navigation/Base.tsx +21 -0
- package/src/components/navigation/auth-navigator.tsx +47 -0
- package/src/components/navigation/helpers.ts +101 -0
- package/src/components/navigation/index.tsx +157 -0
- package/src/components/navigation/main-navigator.tsx +176 -0
- package/src/components/navigation/nativeRouter.tsx +255 -0
- package/src/components/navigation/parent-back.ts +139 -0
- package/src/components/navigation/side-menu-drawer.tsx +69 -0
- package/src/components/navigation/side-menu-wrapper.tsx +82 -0
- package/src/components/navigation/tab-navigator.tsx +254 -0
- package/src/components/navigation/types/auth.ts +23 -0
- package/src/components/navigation/types/index.ts +4 -0
- package/src/components/navigation/types/main.ts +156 -0
- package/src/components/navigation/types/root.ts +13 -0
- package/src/components/navigation/types/tabs.ts +51 -0
- package/src/components/notifications/NotificationErrorBoundary.tsx +40 -0
- package/src/components/notifications/NotificationHeaderActions.tsx +55 -0
- package/src/components/notifications/NotificationItem.tsx +80 -0
- package/src/components/notifications/NotificationWrapper.tsx +57 -0
- package/src/components/notifications/NotificationsList.tsx +103 -0
- package/src/components/notifications/index.ts +6 -0
- package/src/components/notifications/types/Announcement.tsx +51 -0
- package/src/components/notifications/types/DirectMessage.tsx +55 -0
- package/src/components/notifications/types/Follow.tsx +54 -0
- package/src/components/notifications/types/GroupMemberExit.tsx +52 -0
- package/src/components/notifications/types/JamModerator.tsx +38 -0
- package/src/components/notifications/types/JamSpeaker.tsx +38 -0
- package/src/components/notifications/types/JamStarted.tsx +39 -0
- package/src/components/notifications/types/Mention.tsx +56 -0
- package/src/components/notifications/types/NewGroupInvitation.tsx +53 -0
- package/src/components/notifications/types/NewGroupMember.tsx +57 -0
- package/src/components/notifications/types/NewGroupPost.tsx +41 -0
- package/src/components/notifications/types/NewProfile.tsx +53 -0
- package/src/components/notifications/types/PollEnded.tsx +55 -0
- package/src/components/notifications/types/PollVote.tsx +50 -0
- package/src/components/notifications/types/Reaction.tsx +49 -0
- package/src/components/notifications/types/Reply.tsx +52 -0
- package/src/components/notifications/types/Repost.tsx +49 -0
- package/src/components/notifications/types/Rsvp.tsx +48 -0
- package/src/components/notifications/types/RsvpCanceled.tsx +72 -0
- package/src/components/notifications/types/index.ts +19 -0
- package/src/components/post/CompactReplyParent.tsx +273 -0
- package/src/components/post/EventViewSwitch.tsx +42 -0
- package/src/components/post/Feed.tsx +110 -0
- package/src/components/post/FeedFormatSwitch.tsx +47 -0
- package/src/components/post/FeedPost.tsx +115 -0
- package/src/components/post/FeedPostContent.tsx +52 -0
- package/src/components/post/FullPostLayout.tsx +54 -0
- package/src/components/post/Markdown.tsx +8 -0
- package/src/components/post/NewEventButton.tsx +61 -0
- package/src/components/post/NewNoteButton.tsx +48 -0
- package/src/components/post/NewResourceButton.tsx +57 -0
- package/src/components/post/PinnedPost.tsx +42 -0
- package/src/components/post/PostDetail.tsx +55 -0
- package/src/components/post/ReplyBox.tsx +36 -0
- package/src/components/post/VideoPlayOverlay.tsx +23 -0
- package/src/components/post/feed/events/EventsCalendar.tsx +213 -0
- package/src/components/post/feed/events/EventsFeed.tsx +91 -0
- package/src/components/post/feed/events/EventsView.tsx +30 -0
- package/src/components/post/feed/events/index.ts +3 -0
- package/src/components/post/feed/threaded/ThreadPost.tsx +76 -0
- package/src/components/post/feed/threaded/ThreadedFeed.tsx +47 -0
- package/src/components/post/feed/threaded/index.ts +2 -0
- package/src/components/post/helpers.ts +54 -0
- package/src/components/post/index.ts +21 -0
- package/src/components/post/pieces/Attachments.tsx +153 -0
- package/src/components/post/pieces/AudioAttachment.tsx +57 -0
- package/src/components/post/pieces/DocumentAttachment.tsx +41 -0
- package/src/components/post/pieces/EventLocation.tsx +46 -0
- package/src/components/post/pieces/EventMenu.tsx +126 -0
- package/src/components/post/pieces/EventOccurrenceList.tsx +131 -0
- package/src/components/post/pieces/EventRsvpButton.tsx +177 -0
- package/src/components/post/pieces/EventRsvpList.tsx +277 -0
- package/src/components/post/pieces/EventRsvpScopeDialog.tsx +238 -0
- package/src/components/post/pieces/FeedPostStats.tsx +75 -0
- package/src/components/post/pieces/FeedThreadPreview.tsx +88 -0
- package/src/components/post/pieces/GalleryModal.tsx +115 -0
- package/src/components/post/pieces/ParticipantsCard.tsx +20 -0
- package/src/components/post/pieces/PollContent.tsx +219 -0
- package/src/components/post/pieces/PostActions.tsx +81 -0
- package/src/components/post/pieces/PostInfoHeader.tsx +52 -0
- package/src/components/post/pieces/PostMenu.tsx +477 -0
- package/src/components/post/pieces/PostReactionHeader.tsx +120 -0
- package/src/components/post/pieces/ShareMenu.tsx +127 -0
- package/src/components/post/pieces/UnreadPostIndicator.tsx +34 -0
- package/src/components/post/pieces/VideoPlayer.tsx +30 -0
- package/src/components/post/pieces/VisibilityDisplay.tsx +43 -0
- package/src/components/post/pieces/gallery/GalleryAudio.tsx +20 -0
- package/src/components/post/pieces/gallery/GalleryDocument.tsx +35 -0
- package/src/components/post/pieces/gallery/GalleryImage.tsx +15 -0
- package/src/components/post/pieces/gallery/GalleryVideo.tsx +39 -0
- package/src/components/post/pieces/gallery/index.ts +4 -0
- package/src/components/post/pieces/index.ts +24 -0
- package/src/components/post/pieces/modals/CancelEventModal.tsx +60 -0
- package/src/components/post/pieces/modals/DeleteEventModal.tsx +60 -0
- package/src/components/post/pieces/modals/DeletePostModal.tsx +54 -0
- package/src/components/post/pieces/modals/PostOptionsSheet.tsx +59 -0
- package/src/components/post/pieces/modals/ReactionsModal.tsx +45 -0
- package/src/components/post/pieces/modals/RepostModal.tsx +56 -0
- package/src/components/post/pieces/modals/index.ts +6 -0
- package/src/components/post/post-form/ArticleForm.tsx +101 -0
- package/src/components/post/post-form/ArticlePreviewSheet.tsx +24 -0
- package/src/components/post/post-form/AttachmentCard.tsx +119 -0
- package/src/components/post/post-form/ComposeAttachments.tsx +126 -0
- package/src/components/post/post-form/ComposePreviewLinks.tsx +21 -0
- package/src/components/post/post-form/DateSheet.tsx +154 -0
- package/src/components/post/post-form/DescriptionEditModal.tsx +58 -0
- package/src/components/post/post-form/EditPostModalContext.tsx +49 -0
- package/src/components/post/post-form/EventForm.tsx +416 -0
- package/src/components/post/post-form/EventTypeSwitcher.tsx +164 -0
- package/src/components/post/post-form/Footer.tsx +61 -0
- package/src/components/post/post-form/NewPostModalContext.tsx +77 -0
- package/src/components/post/post-form/OpenpeepsMarkdownInput.tsx +218 -0
- package/src/components/post/post-form/PollComposerFields.tsx +141 -0
- package/src/components/post/post-form/PostAudienceSelector.tsx +82 -0
- package/src/components/post/post-form/PostForm.tsx +187 -0
- package/src/components/post/post-form/PostTypeSwitcher.tsx +125 -0
- package/src/components/post/post-form/ReplyModal.tsx +40 -0
- package/src/components/post/post-form/ReplyModalContext.tsx +24 -0
- package/src/components/post/post-form/ResourceForm.tsx +241 -0
- package/src/components/post/post-form/VisibilitySelector.tsx +60 -0
- package/src/components/post/post-form/VisibilitySheet.tsx +239 -0
- package/src/components/post/post-form/constants.ts +47 -0
- package/src/components/post/post-form/index.ts +23 -0
- package/src/components/post/types/Article.tsx +55 -0
- package/src/components/post/types/Event.tsx +79 -0
- package/src/components/post/types/Note.tsx +29 -0
- package/src/components/post/types/Poll.tsx +34 -0
- package/src/components/post/types/article/CardArticle.tsx +44 -0
- package/src/components/post/types/article/FullArticle.tsx +56 -0
- package/src/components/post/types/article/index.ts +2 -0
- package/src/components/post/types/event/CardEvent.tsx +138 -0
- package/src/components/post/types/event/FullEvent.tsx +760 -0
- package/src/components/post/types/event/ProfileEventRelationship.tsx +56 -0
- package/src/components/post/types/event/index.ts +3 -0
- package/src/components/post/types/index.ts +9 -0
- package/src/components/post/types/note/FullNote.tsx +15 -0
- package/src/components/post/types/note/index.ts +1 -0
- package/src/components/post/types/poll/FullPoll.tsx +26 -0
- package/src/components/post/types/poll/index.ts +1 -0
- package/src/components/post/types/resource/FullResource.tsx +177 -0
- package/src/components/preview-link/AccessDenied.tsx +44 -0
- package/src/components/preview-link/LocalPreviewLink.tsx +40 -0
- package/src/components/preview-link/PreviewLink.tsx +27 -0
- package/src/components/preview-link/RemotePreviewLink.tsx +76 -0
- package/src/components/preview-link/helpers.ts +38 -0
- package/src/components/preview-link/index.ts +7 -0
- package/src/components/preview-link/local/GroupPreview.tsx +57 -0
- package/src/components/preview-link/local/JamPreview.tsx +40 -0
- package/src/components/preview-link/local/PostPreview.tsx +40 -0
- package/src/components/profile/Avatar.tsx +90 -0
- package/src/components/profile/AvatarWithName.tsx +18 -0
- package/src/components/profile/EditProfileForm.tsx +380 -0
- package/src/components/profile/FollowUnfollowButton.tsx +83 -0
- package/src/components/profile/ProfileActivitySummary.tsx +129 -0
- package/src/components/profile/ProfileBadge.tsx +52 -0
- package/src/components/profile/ProfileCard.tsx +122 -0
- package/src/components/profile/ProfileFromId.tsx +23 -0
- package/src/components/profile/ProfileHeader.tsx +107 -0
- package/src/components/profile/ProfileLink.tsx +35 -0
- package/src/components/profile/ProfilePageAction.tsx +193 -0
- package/src/components/profile/ProfilePieces.tsx +191 -0
- package/src/components/profile/ProfilePostsAndReplies.tsx +108 -0
- package/src/components/profile/ProfileSelector.tsx +210 -0
- package/src/components/profile/ProfileSheet.tsx +48 -0
- package/src/components/profile/ProfileStats.tsx +47 -0
- package/src/components/profile/ProfileWithActionCard.tsx +35 -0
- package/src/components/profile/ProfilesInput.tsx +81 -0
- package/src/components/profile/ReportProfileOrPostModal.tsx +228 -0
- package/src/components/profile/index.ts +19 -0
- package/src/components/resources/ResourceCard.tsx +289 -0
- package/src/components/resources/ResourceLibrary.tsx +371 -0
- package/src/components/resources/index.ts +4 -0
- package/src/components/ui/alert.tsx +87 -0
- package/src/components/ui/avatar.tsx +91 -0
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/bottom-sheet.tsx +253 -0
- package/src/components/ui/button.tsx +101 -0
- package/src/components/ui/calendar.tsx +117 -0
- package/src/components/ui/card.tsx +87 -0
- package/src/components/ui/checkbox.tsx +35 -0
- package/src/components/ui/combobox.tsx +229 -0
- package/src/components/ui/dropdown-menu.tsx +350 -0
- package/src/components/ui/form.tsx +716 -0
- package/src/components/ui/index.ts +49 -0
- package/src/components/ui/input.tsx +25 -0
- package/src/components/ui/label.tsx +33 -0
- package/src/components/ui/loading-spinner.tsx +24 -0
- package/src/components/ui/popup-menu-button.tsx +99 -0
- package/src/components/ui/popup-menu-section.tsx +21 -0
- package/src/components/ui/popup-menu-separator.tsx +10 -0
- package/src/components/ui/popup-menu.tsx +75 -0
- package/src/components/ui/progress.tsx +83 -0
- package/src/components/ui/radio-group.tsx +42 -0
- package/src/components/ui/select.tsx +200 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/skeleton.tsx +39 -0
- package/src/components/ui/svg-image.tsx +89 -0
- package/src/components/ui/switch.tsx +95 -0
- package/src/components/ui/tabs.tsx +93 -0
- package/src/components/ui/text.tsx +28 -0
- package/src/components/ui/textarea.tsx +39 -0
- package/src/components/ui/themed-safe-area-view.tsx +25 -0
- package/src/components/ui/themed-text.tsx +28 -0
- package/src/components/ui/themed-view.tsx +24 -0
- package/src/components/ui/tooltip.tsx +41 -0
- package/src/contexts/drawer-context.tsx +38 -0
- package/src/contexts/openpeeps-provider.tsx +135 -0
- package/src/global.css +53 -0
- package/src/hooks/helper.ts +26 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/use-cached-media-uri.ts +59 -0
- package/src/hooks/use-controlled-sheet.ts +16 -0
- package/src/hooks/use-notification-badge-reset.ts +93 -0
- package/src/hooks/use-post-view-ref.ts +65 -0
- package/src/i18n/index.ts +49 -0
- package/src/index.ts +42 -0
- package/src/lib/attachmentHelpers.ts +15 -0
- package/src/lib/auth.ts +17 -0
- package/src/lib/bottom-sheet-ref.ts +30 -0
- package/src/lib/constants.ts +14 -0
- package/src/lib/credentialsStore.ts +20 -0
- package/src/lib/downloadFile.ts +12 -0
- package/src/lib/livekit/useStableLiveKitRoom.ts +172 -0
- package/src/lib/media-permissions.ts +90 -0
- package/src/lib/media-url.ts +51 -0
- package/src/lib/mediaUriHelpers.ts +94 -0
- package/src/lib/notification-helpers.ts +17 -0
- package/src/lib/notifications-screen-state.ts +21 -0
- package/src/lib/polyfills/customEvent.ts +40 -0
- package/src/lib/post.ts +175 -0
- package/src/lib/push-notification-navigation.ts +11 -0
- package/src/lib/push-notifications-background.ts +13 -0
- package/src/lib/push-notifications.ts +247 -0
- package/src/lib/uploadMedia.ts +191 -0
- package/src/lib/utils.ts +247 -0
- package/src/nativewind-env.d.ts +1 -0
- package/src/pages/About.tsx +27 -0
- package/src/pages/CodeOfConduct.tsx +24 -0
- package/src/pages/Explore.tsx +297 -0
- package/src/pages/Members.tsx +118 -0
- package/src/pages/NotFound.tsx +36 -0
- package/src/pages/Notifications.tsx +39 -0
- package/src/pages/PostDetail.tsx +61 -0
- package/src/pages/Profile.tsx +77 -0
- package/src/pages/Tags.tsx +114 -0
- package/src/pages/VideoPlayer.tsx +16 -0
- package/src/pages/Welcome.tsx +214 -0
- package/src/pages/articles/Edit.tsx +72 -0
- package/src/pages/articles/Index.tsx +31 -0
- package/src/pages/articles/New.tsx +55 -0
- package/src/pages/auth/Login.tsx +148 -0
- package/src/pages/auth/Register.tsx +271 -0
- package/src/pages/auth/RegisterInvitation.tsx +8 -0
- package/src/pages/auth/RequestResetPassword.tsx +102 -0
- package/src/pages/auth/ResetPassword.tsx +48 -0
- package/src/pages/auth/Success.tsx +104 -0
- package/src/pages/auth/ValidateEmail.tsx +80 -0
- package/src/pages/auth/Welcome.tsx +64 -0
- package/src/pages/conversations/Index.tsx +168 -0
- package/src/pages/conversations/Info.tsx +99 -0
- package/src/pages/conversations/New.tsx +135 -0
- package/src/pages/conversations/NewDraft.tsx +102 -0
- package/src/pages/conversations/Show.tsx +261 -0
- package/src/pages/events/Edit.tsx +74 -0
- package/src/pages/events/Index.tsx +99 -0
- package/src/pages/events/My.tsx +60 -0
- package/src/pages/events/New.tsx +51 -0
- package/src/pages/feeds/Bookmarks.tsx +47 -0
- package/src/pages/feeds/Local.tsx +45 -0
- package/src/pages/feeds/My.tsx +37 -0
- package/src/pages/groups/Edit.tsx +58 -0
- package/src/pages/groups/EditInfo.tsx +79 -0
- package/src/pages/groups/EditRoles.tsx +84 -0
- package/src/pages/groups/Index.tsx +159 -0
- package/src/pages/groups/Info.tsx +197 -0
- package/src/pages/groups/Members.tsx +55 -0
- package/src/pages/groups/New.tsx +80 -0
- package/src/pages/groups/Show.tsx +212 -0
- package/src/pages/index.ts +66 -0
- package/src/pages/jams/Event.tsx +49 -0
- package/src/pages/jams/Index.tsx +137 -0
- package/src/pages/jams/My.tsx +4 -0
- package/src/pages/jams/New.tsx +121 -0
- package/src/pages/posts/Edit.tsx +157 -0
- package/src/pages/posts/New.tsx +334 -0
- package/src/pages/posts/Reply.tsx +351 -0
- package/src/pages/profile/Followers.tsx +45 -0
- package/src/pages/profile/Following.tsx +44 -0
- package/src/pages/resources/Edit.tsx +72 -0
- package/src/pages/resources/Index.tsx +25 -0
- package/src/pages/resources/New.tsx +55 -0
- package/src/pages/settings/AccessTokens.tsx +276 -0
- package/src/pages/settings/Account.tsx +272 -0
- package/src/pages/settings/Blocked.tsx +81 -0
- package/src/pages/settings/Feed.tsx +78 -0
- package/src/pages/settings/Index.tsx +75 -0
- package/src/pages/settings/Language.tsx +81 -0
- package/src/pages/settings/NotificationPreferences.tsx +131 -0
- package/src/pages/settings/Notifications.tsx +36 -0
- package/src/pages/settings/PublicProfile.tsx +20 -0
- package/src/pages/settings/PushEnabledDevices.tsx +151 -0
- package/src/pages/settings/Theme.tsx +106 -0
- package/src/pages/settings/Timezone.tsx +75 -0
- package/src/stores/useAppImagesStore.ts +15 -0
- package/src/stores/useLocalPostStore.ts +62 -0
- package/src/stores/useNewConversationStore.ts +39 -0
- package/src/theme/OpenPeepsThemeProvider.tsx +98 -0
- package/src/theme/defaults.ts +40 -0
- package/src/theme/types.ts +37 -0
- package/src/theme/utils.ts +62 -0
- package/src/types/env.d.ts +11 -0
- package/src/types/goto.ts +12 -0
- package/src/types/markdown-plugin.ts +17 -0
- package/src/types/react-native-convert-ph-asset.d.ts +24 -0
- package/src/types.ts +56 -0
- package/src/utils/media-cache.ts +178 -0
- package/tailwind.config.js +128 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import type { PushMessage, PushSubscriptionData } from '@openpeepshq/common';
|
|
3
|
+
import { getApp } from '@react-native-firebase/app';
|
|
4
|
+
import {
|
|
5
|
+
FirebaseMessagingTypes,
|
|
6
|
+
getToken,
|
|
7
|
+
requestPermission,
|
|
8
|
+
AuthorizationStatus,
|
|
9
|
+
onMessage,
|
|
10
|
+
onNotificationOpenedApp,
|
|
11
|
+
getInitialNotification,
|
|
12
|
+
setBackgroundMessageHandler,
|
|
13
|
+
} from '@react-native-firebase/messaging';
|
|
14
|
+
import notifee, { Event, EventType } from '@notifee/react-native';
|
|
15
|
+
import { setAppBadgeCount } from './notification-helpers';
|
|
16
|
+
import { handlePushOnNotificationsScreen } from './notifications-screen-state';
|
|
17
|
+
import { MainStackParamList } from '../components/navigation/types';
|
|
18
|
+
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
19
|
+
import { buildGoto } from '../components/navigation/helpers';
|
|
20
|
+
import { handleInternalURLNavigation } from './utils';
|
|
21
|
+
import {
|
|
22
|
+
consumePendingPushAction,
|
|
23
|
+
setPendingPushAction,
|
|
24
|
+
} from './push-notification-navigation';
|
|
25
|
+
import './push-notifications-background';
|
|
26
|
+
|
|
27
|
+
const messageToPushNotification = (
|
|
28
|
+
message: FirebaseMessagingTypes.RemoteMessage
|
|
29
|
+
): PushMessage | undefined =>
|
|
30
|
+
message.data?.payload
|
|
31
|
+
? (JSON.parse(message.data.payload as string) as PushMessage)
|
|
32
|
+
: undefined;
|
|
33
|
+
|
|
34
|
+
export const getDefaultActionFromRemoteMessage = (
|
|
35
|
+
remoteMessage: FirebaseMessagingTypes.RemoteMessage
|
|
36
|
+
): string | undefined => {
|
|
37
|
+
const pushNotification = messageToPushNotification(remoteMessage);
|
|
38
|
+
const action = pushNotification?.notification?.options?.actions?.[0]?.action;
|
|
39
|
+
return typeof action === 'string' ? action : undefined;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const updateBadgeFromRemoteMessage = async (
|
|
43
|
+
remoteMessage: FirebaseMessagingTypes.RemoteMessage
|
|
44
|
+
) => {
|
|
45
|
+
const pushNotification = messageToPushNotification(remoteMessage);
|
|
46
|
+
if (!pushNotification) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const { notificationStats } = pushNotification;
|
|
51
|
+
const handledOnNotificationsScreen = await handlePushOnNotificationsScreen(
|
|
52
|
+
notificationStats.unseen
|
|
53
|
+
);
|
|
54
|
+
if (!handledOnNotificationsScreen) {
|
|
55
|
+
setAppBadgeCount(notificationStats.unseen);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const displayRemoteMessageNotification = async (
|
|
60
|
+
remoteMessage: FirebaseMessagingTypes.RemoteMessage
|
|
61
|
+
) => {
|
|
62
|
+
const pushNotification = messageToPushNotification(remoteMessage);
|
|
63
|
+
if (!pushNotification?.notification) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const { notification } = pushNotification;
|
|
68
|
+
const defaultAction = notification.options?.actions?.[0]?.action;
|
|
69
|
+
|
|
70
|
+
await notifee.displayNotification({
|
|
71
|
+
title: notification.title,
|
|
72
|
+
body: notification.options?.body,
|
|
73
|
+
data: defaultAction ? { defaultAction } : undefined,
|
|
74
|
+
android: {
|
|
75
|
+
largeIcon: notification.options?.icon ?? 'ic_launcher',
|
|
76
|
+
channelId: 'default',
|
|
77
|
+
pressAction: {
|
|
78
|
+
id: 'default',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const handleRemoteMessage = async (
|
|
85
|
+
remoteMessage: FirebaseMessagingTypes.RemoteMessage
|
|
86
|
+
) => {
|
|
87
|
+
await updateBadgeFromRemoteMessage(remoteMessage);
|
|
88
|
+
await displayRemoteMessageNotification(remoteMessage);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const navigateFromPushAction = (
|
|
92
|
+
defaultAction: string,
|
|
93
|
+
goto: ReturnType<typeof buildGoto>
|
|
94
|
+
) => {
|
|
95
|
+
handleInternalURLNavigation(defaultAction, goto);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const handleNotificationOpen = (
|
|
99
|
+
remoteMessage: FirebaseMessagingTypes.RemoteMessage,
|
|
100
|
+
goto?: ReturnType<typeof buildGoto>
|
|
101
|
+
) => {
|
|
102
|
+
const defaultAction = getDefaultActionFromRemoteMessage(remoteMessage);
|
|
103
|
+
if (!defaultAction) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (goto) {
|
|
108
|
+
navigateFromPushAction(defaultAction, goto);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
setPendingPushAction(defaultAction);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const registerMessageHandler = async (
|
|
116
|
+
navigation: NativeStackNavigationProp<MainStackParamList>
|
|
117
|
+
) => {
|
|
118
|
+
const goto = buildGoto(navigation);
|
|
119
|
+
|
|
120
|
+
const handleNotificationEvent = async (event: Event) => {
|
|
121
|
+
if (event.type !== EventType.PRESS) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const defaultAction = event.detail?.notification?.data?.defaultAction;
|
|
126
|
+
if (typeof defaultAction === 'string') {
|
|
127
|
+
navigateFromPushAction(defaultAction, goto);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
await notifee.requestPermission();
|
|
132
|
+
|
|
133
|
+
await notifee.createChannel({
|
|
134
|
+
id: 'default',
|
|
135
|
+
name: 'Default Channel',
|
|
136
|
+
});
|
|
137
|
+
await notifee.setNotificationCategories([
|
|
138
|
+
{
|
|
139
|
+
id: 'default',
|
|
140
|
+
},
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
const app = getApp();
|
|
144
|
+
|
|
145
|
+
const pendingAction = consumePendingPushAction();
|
|
146
|
+
if (pendingAction) {
|
|
147
|
+
navigateFromPushAction(pendingAction, goto);
|
|
148
|
+
} else {
|
|
149
|
+
const initialNotification = await getInitialNotification(app.messaging());
|
|
150
|
+
if (initialNotification) {
|
|
151
|
+
await updateBadgeFromRemoteMessage(initialNotification);
|
|
152
|
+
handleNotificationOpen(initialNotification, goto);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const unsubscribeOnMessage = onMessage(
|
|
157
|
+
app.messaging(),
|
|
158
|
+
async (remoteMessage) => {
|
|
159
|
+
await handleRemoteMessage(remoteMessage);
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
const unsubscribeOpened = onNotificationOpenedApp(
|
|
163
|
+
app.messaging(),
|
|
164
|
+
async (remoteMessage) => {
|
|
165
|
+
await updateBadgeFromRemoteMessage(remoteMessage);
|
|
166
|
+
handleNotificationOpen(remoteMessage, goto);
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
setBackgroundMessageHandler(app.messaging(), async (remoteMessage) => {
|
|
170
|
+
await handleRemoteMessage(remoteMessage);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const unsubscribeForeground = notifee.onForegroundEvent(async (event) => {
|
|
174
|
+
await handleNotificationEvent(event);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
return () => {
|
|
178
|
+
unsubscribeOnMessage();
|
|
179
|
+
unsubscribeOpened();
|
|
180
|
+
unsubscribeForeground();
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export const useRegisterPushMessageHandler = (
|
|
185
|
+
navigation: NativeStackNavigationProp<MainStackParamList>
|
|
186
|
+
) => {
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
let cancelled = false;
|
|
189
|
+
let unsubscribe: (() => void) | undefined;
|
|
190
|
+
void registerMessageHandler(navigation).then((unsub) => {
|
|
191
|
+
if (cancelled) {
|
|
192
|
+
unsub();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
unsubscribe = unsub;
|
|
196
|
+
});
|
|
197
|
+
return () => {
|
|
198
|
+
cancelled = true;
|
|
199
|
+
unsubscribe?.();
|
|
200
|
+
};
|
|
201
|
+
}, [navigation]);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
let fcmRegistration: Promise<PushSubscriptionData | undefined> | undefined;
|
|
205
|
+
|
|
206
|
+
const registerFcmToken = async (
|
|
207
|
+
pushSubscriptions: PushSubscriptionData[]
|
|
208
|
+
): Promise<PushSubscriptionData | undefined> => {
|
|
209
|
+
const app = getApp();
|
|
210
|
+
|
|
211
|
+
const authStatus = await requestPermission(app.messaging());
|
|
212
|
+
const enabled =
|
|
213
|
+
authStatus === AuthorizationStatus.AUTHORIZED ||
|
|
214
|
+
authStatus === AuthorizationStatus.PROVISIONAL;
|
|
215
|
+
|
|
216
|
+
try {
|
|
217
|
+
if (enabled) {
|
|
218
|
+
const token = await getToken(app.messaging());
|
|
219
|
+
if (
|
|
220
|
+
pushSubscriptions.find(
|
|
221
|
+
(subscription) =>
|
|
222
|
+
subscription.type === 'fcm' && subscription.fcmToken === token
|
|
223
|
+
)
|
|
224
|
+
) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
type: 'fcm',
|
|
230
|
+
fcmToken: token,
|
|
231
|
+
} as PushSubscriptionData;
|
|
232
|
+
}
|
|
233
|
+
} catch {
|
|
234
|
+
console.info('Error initializing push notifications');
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export const initializePushNotifications = async (
|
|
239
|
+
pushSubscriptions: PushSubscriptionData[]
|
|
240
|
+
): Promise<PushSubscriptionData | undefined> => {
|
|
241
|
+
if (!fcmRegistration) {
|
|
242
|
+
fcmRegistration = registerFcmToken(pushSubscriptions).finally(() => {
|
|
243
|
+
fcmRegistration = undefined;
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return fcmRegistration;
|
|
247
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import RNFS from 'react-native-fs';
|
|
2
|
+
import RNConvertPhAsset from 'react-native-convert-ph-asset';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import Toast from 'react-native-toast-message';
|
|
5
|
+
import type { MediaAttachment } from '@openpeepshq/common';
|
|
6
|
+
import i18next from '../i18n/index';
|
|
7
|
+
import { decodeFileUri, resolveDocumentMime } from './mediaUriHelpers';
|
|
8
|
+
|
|
9
|
+
type UploadProgressInfo = {
|
|
10
|
+
loaded: number;
|
|
11
|
+
total: number;
|
|
12
|
+
percent: number;
|
|
13
|
+
estimatedRemainingMs?: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type UploadProgressMap = {
|
|
17
|
+
[key: string]: { percent: number; estimatedRemainingMs?: number };
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type UploadMediaType = {
|
|
21
|
+
mediaUri: string;
|
|
22
|
+
createAttachments: (
|
|
23
|
+
data: any,
|
|
24
|
+
pathParams?: undefined,
|
|
25
|
+
queryParams?: undefined,
|
|
26
|
+
headers?: Record<string, string>,
|
|
27
|
+
onUploadProgress?: (info: UploadProgressInfo) => void
|
|
28
|
+
) => Promise<any>;
|
|
29
|
+
type: 'image' | 'video' | 'audio' | 'document';
|
|
30
|
+
usage: string;
|
|
31
|
+
alt?: string;
|
|
32
|
+
name?: string | null;
|
|
33
|
+
mimeType?: string | null;
|
|
34
|
+
setUploadProgress?: React.Dispatch<React.SetStateAction<UploadProgressMap>>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const uploadMedia = async ({
|
|
38
|
+
mediaUri,
|
|
39
|
+
createAttachments,
|
|
40
|
+
type,
|
|
41
|
+
usage,
|
|
42
|
+
alt,
|
|
43
|
+
name,
|
|
44
|
+
mimeType,
|
|
45
|
+
setUploadProgress,
|
|
46
|
+
}: UploadMediaType) => {
|
|
47
|
+
const decodedMediaUri = decodeFileUri(mediaUri);
|
|
48
|
+
let finalUri = decodedMediaUri;
|
|
49
|
+
|
|
50
|
+
let fileExtension = 'bin';
|
|
51
|
+
let finalMimeType = 'application/octet-stream';
|
|
52
|
+
|
|
53
|
+
if (type === 'video') {
|
|
54
|
+
fileExtension = 'mp4';
|
|
55
|
+
finalMimeType = 'video/mp4';
|
|
56
|
+
} else if (type === 'image') {
|
|
57
|
+
fileExtension = 'jpg';
|
|
58
|
+
finalMimeType = 'image/jpeg';
|
|
59
|
+
} else if (type === 'document') {
|
|
60
|
+
if (name) {
|
|
61
|
+
const extractedExt = name.split('.').pop();
|
|
62
|
+
if (extractedExt && extractedExt !== name) {
|
|
63
|
+
fileExtension = extractedExt;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
finalMimeType = resolveDocumentMime(mimeType, name);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const tempFileName = `${Date.now()}_${Math.random().toString(36).substring(2, 9)}.${fileExtension}`;
|
|
70
|
+
|
|
71
|
+
if (setUploadProgress) {
|
|
72
|
+
setUploadProgress((prev) => ({
|
|
73
|
+
...prev,
|
|
74
|
+
[mediaUri]: { percent: 0, estimatedRemainingMs: undefined },
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (mediaUri.startsWith('ph://')) {
|
|
79
|
+
const destPath = `${RNFS.TemporaryDirectoryPath}/${tempFileName}`;
|
|
80
|
+
|
|
81
|
+
if (type === 'image') {
|
|
82
|
+
try {
|
|
83
|
+
await RNFS.copyAssetsFileIOS(mediaUri, destPath, 1024, 1024);
|
|
84
|
+
finalUri = `file://${destPath}`;
|
|
85
|
+
} catch {
|
|
86
|
+
const base64Data = await RNFS.readFile(mediaUri, 'base64');
|
|
87
|
+
await RNFS.writeFile(destPath, base64Data, 'base64');
|
|
88
|
+
finalUri = `file://${destPath}`;
|
|
89
|
+
}
|
|
90
|
+
} else if (type === 'video') {
|
|
91
|
+
try {
|
|
92
|
+
const res = await RNConvertPhAsset.convertVideoFromUrl({
|
|
93
|
+
url: mediaUri,
|
|
94
|
+
convertTo: 'mov',
|
|
95
|
+
quality: 'medium',
|
|
96
|
+
});
|
|
97
|
+
finalUri = res.path;
|
|
98
|
+
} catch (videoError) {
|
|
99
|
+
console.error('Failed to convert ph:// video asset:', videoError);
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// iOS document picker import mode already copies into the app sandbox;
|
|
106
|
+
// copying again often fails on encoded paths. Android needs content:// copied.
|
|
107
|
+
const shouldCopyPickerFile =
|
|
108
|
+
decodedMediaUri.startsWith('content://') ||
|
|
109
|
+
(Platform.OS === 'android' && decodedMediaUri.startsWith('file://'));
|
|
110
|
+
|
|
111
|
+
if (shouldCopyPickerFile) {
|
|
112
|
+
const destPath = `${RNFS.CachesDirectoryPath}/${tempFileName}`;
|
|
113
|
+
|
|
114
|
+
try {
|
|
115
|
+
if (await RNFS.exists(destPath)) {
|
|
116
|
+
await RNFS.unlink(destPath);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
await RNFS.copyFile(decodedMediaUri, destPath);
|
|
120
|
+
finalUri = `file://${destPath}`;
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error('Failed to copy picker file:', error);
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
const cleanPath = finalUri.replace(/^file:\/\//, '');
|
|
129
|
+
const fileStat = await RNFS.stat(cleanPath);
|
|
130
|
+
|
|
131
|
+
const file = {
|
|
132
|
+
uri: finalUri,
|
|
133
|
+
name: name || `${type}_${Date.now()}.${fileExtension}`,
|
|
134
|
+
type: finalMimeType,
|
|
135
|
+
size: fileStat.size,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const mediaAttachment: MediaAttachment = await createAttachments(
|
|
139
|
+
{
|
|
140
|
+
file: file as unknown as File,
|
|
141
|
+
usage: usage,
|
|
142
|
+
description: alt,
|
|
143
|
+
},
|
|
144
|
+
undefined,
|
|
145
|
+
undefined,
|
|
146
|
+
undefined,
|
|
147
|
+
({ percent, estimatedRemainingMs }) => {
|
|
148
|
+
if (setUploadProgress) {
|
|
149
|
+
setUploadProgress((prev) => ({
|
|
150
|
+
...prev,
|
|
151
|
+
[mediaUri]: { percent, estimatedRemainingMs },
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
id: mediaAttachment.id,
|
|
159
|
+
type: mediaAttachment.type ?? type,
|
|
160
|
+
url: mediaAttachment.url,
|
|
161
|
+
previewUrl: mediaAttachment.previewUrl,
|
|
162
|
+
textUrl: null,
|
|
163
|
+
filename: mediaAttachment.filename || file.name,
|
|
164
|
+
meta: {
|
|
165
|
+
usage: mediaAttachment.meta?.usage ?? usage,
|
|
166
|
+
mimetype: mediaAttachment.meta?.mimetype ?? finalMimeType,
|
|
167
|
+
size: fileStat.size,
|
|
168
|
+
},
|
|
169
|
+
description: mediaAttachment.description,
|
|
170
|
+
blurhash: mediaAttachment.blurhash,
|
|
171
|
+
status: mediaAttachment.status,
|
|
172
|
+
};
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.error(`Failed to upload ${type}: ${mediaUri}`, error);
|
|
175
|
+
const reason = error instanceof Error ? error.message : undefined;
|
|
176
|
+
Toast.show({
|
|
177
|
+
type: 'error',
|
|
178
|
+
text1: i18next.t('form.upload.failed'),
|
|
179
|
+
text2: reason,
|
|
180
|
+
});
|
|
181
|
+
return null;
|
|
182
|
+
} finally {
|
|
183
|
+
if (setUploadProgress) {
|
|
184
|
+
setUploadProgress((prev) => {
|
|
185
|
+
const next = { ...prev };
|
|
186
|
+
delete next[mediaUri];
|
|
187
|
+
return next;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
package/src/lib/utils.ts
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { clsx, type ClassValue } from 'clsx';
|
|
2
|
+
import { twMerge } from 'tailwind-merge';
|
|
3
|
+
import { lightFormat, parse, parseJSON } from 'date-fns';
|
|
4
|
+
import {
|
|
5
|
+
GroupData,
|
|
6
|
+
Profile,
|
|
7
|
+
PublicProfile,
|
|
8
|
+
SuccessFailureResponse,
|
|
9
|
+
groupSectionFromHash,
|
|
10
|
+
} from '@openpeepshq/common';
|
|
11
|
+
import { NativeScrollEvent } from 'react-native';
|
|
12
|
+
import { buildGoto } from '../components/navigation/helpers';
|
|
13
|
+
import { BASE_URL } from './constants';
|
|
14
|
+
import { UseInfiniteQueryResult } from '@tanstack/react-query';
|
|
15
|
+
|
|
16
|
+
export function cn(...inputs: ClassValue[]) {
|
|
17
|
+
return twMerge(clsx(inputs));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const DATE_FORMAT = 'MM/dd/yyyy';
|
|
21
|
+
const TIME_FORMAT = 'hh:mm aaa';
|
|
22
|
+
const DATE_TIME_FORMAT = `${DATE_FORMAT} ${TIME_FORMAT}`;
|
|
23
|
+
|
|
24
|
+
export const maxContentLength = 500;
|
|
25
|
+
export const maxArticleContentLength = 10000;
|
|
26
|
+
|
|
27
|
+
export const formatDateTime = (date: Date) =>
|
|
28
|
+
lightFormat(date, DATE_TIME_FORMAT);
|
|
29
|
+
export const formatDate = (date: Date) => lightFormat(date, DATE_FORMAT);
|
|
30
|
+
export const formatTime = (date: Date) => lightFormat(date, TIME_FORMAT);
|
|
31
|
+
|
|
32
|
+
export const reformatDateTime = (dateString: string) =>
|
|
33
|
+
formatDateTime(parseJSON(dateString));
|
|
34
|
+
export const parseDateTime = (dateString: string) =>
|
|
35
|
+
parse(dateString, DATE_TIME_FORMAT, Date.now());
|
|
36
|
+
|
|
37
|
+
export const sortBy =
|
|
38
|
+
(key: string | ((object: any) => string | number)) => (a: any, b: any) =>
|
|
39
|
+
typeof key === 'string'
|
|
40
|
+
? a[key] > b[key]
|
|
41
|
+
? 1
|
|
42
|
+
: b[key] > a[key]
|
|
43
|
+
? -1
|
|
44
|
+
: 0
|
|
45
|
+
: key(a) > key(b)
|
|
46
|
+
? 1
|
|
47
|
+
: key(b) > key(a)
|
|
48
|
+
? -1
|
|
49
|
+
: 0;
|
|
50
|
+
|
|
51
|
+
export const truncateText = (text?: string, maxLength: number = 15) => {
|
|
52
|
+
if (!text) {
|
|
53
|
+
return '';
|
|
54
|
+
}
|
|
55
|
+
return text.length > maxLength ? `${text.slice(0, maxLength)}...` : text;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const profileMatchesQuery = (profile: Profile, query: string) => {
|
|
59
|
+
const queryLower = query.toLowerCase();
|
|
60
|
+
return (
|
|
61
|
+
profile?.displayName?.toLowerCase().includes(queryLower) ||
|
|
62
|
+
profile?.handle.toLowerCase().includes(queryLower)
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const formatEventDate = (dateString: string) => {
|
|
67
|
+
return new Date(dateString).toLocaleString('en-US', {
|
|
68
|
+
month: 'short',
|
|
69
|
+
day: 'numeric',
|
|
70
|
+
year: 'numeric',
|
|
71
|
+
hour: 'numeric',
|
|
72
|
+
minute: '2-digit',
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const ChatDateFormatter = (date: string) => {
|
|
77
|
+
const options: Intl.DateTimeFormatOptions = {
|
|
78
|
+
weekday: 'long',
|
|
79
|
+
year: 'numeric',
|
|
80
|
+
month: 'long',
|
|
81
|
+
day: 'numeric',
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const today = new Date();
|
|
85
|
+
const messageDate = new Date(date);
|
|
86
|
+
if (
|
|
87
|
+
today.getDate() === messageDate.getDate() &&
|
|
88
|
+
today.getMonth() === messageDate.getMonth() &&
|
|
89
|
+
today.getFullYear() === messageDate.getFullYear()
|
|
90
|
+
) {
|
|
91
|
+
return 'Today';
|
|
92
|
+
} else if (
|
|
93
|
+
today.getDate() - 1 === messageDate.getDate() &&
|
|
94
|
+
today.getMonth() === messageDate.getMonth() &&
|
|
95
|
+
today.getFullYear() === messageDate.getFullYear()
|
|
96
|
+
) {
|
|
97
|
+
return 'Yesterday';
|
|
98
|
+
} else {
|
|
99
|
+
return new Date(date).toLocaleDateString(undefined, options);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const profileName = (profile?: PublicProfile) =>
|
|
104
|
+
profile?.displayName || profile?.handle;
|
|
105
|
+
|
|
106
|
+
export const groupName = (group?: GroupData) =>
|
|
107
|
+
group?.displayName || group?.handle || '';
|
|
108
|
+
|
|
109
|
+
export const hasValue = (v: unknown): boolean => v === 0 || !!v;
|
|
110
|
+
|
|
111
|
+
export const handleScroll = (
|
|
112
|
+
event: NativeScrollEvent,
|
|
113
|
+
query: UseInfiniteQueryResult<unknown, SuccessFailureResponse>
|
|
114
|
+
) => {
|
|
115
|
+
const { layoutMeasurement, contentOffset, contentSize } = event;
|
|
116
|
+
const isCloseToBottom =
|
|
117
|
+
layoutMeasurement.height + contentOffset.y >= contentSize.height - 20;
|
|
118
|
+
|
|
119
|
+
if (isCloseToBottom && query.hasNextPage && !query.isFetchingNextPage) {
|
|
120
|
+
query.fetchNextPage();
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const handleInternalURLNavigation = (
|
|
125
|
+
defaultAction: string,
|
|
126
|
+
goto: ReturnType<typeof buildGoto>
|
|
127
|
+
) => {
|
|
128
|
+
const navigatePath = (path: string) => {
|
|
129
|
+
const hashStart = path.indexOf('#');
|
|
130
|
+
const hash = hashStart === -1 ? '' : path.slice(hashStart);
|
|
131
|
+
const pathWithoutHash = hashStart === -1 ? path : path.slice(0, hashStart);
|
|
132
|
+
|
|
133
|
+
if (isGroupPath(pathWithoutHash)) {
|
|
134
|
+
const pathname = pathWithoutHash.split('?')[0] ?? pathWithoutHash;
|
|
135
|
+
goto({
|
|
136
|
+
target: 'group',
|
|
137
|
+
params: {
|
|
138
|
+
handle: pathname.slice('/groups/@'.length).split('/')[0],
|
|
139
|
+
tab: groupSectionFromHash(hash),
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
if (isJamPath(pathWithoutHash)) {
|
|
145
|
+
goto({ target: 'event', params: { id: pathWithoutHash.split('/')[2] } });
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
if (isPostPath(pathWithoutHash)) {
|
|
149
|
+
goto({
|
|
150
|
+
target: 'posts',
|
|
151
|
+
params: { id: pathWithoutHash.split('/')[2] },
|
|
152
|
+
});
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
if (isProfilePath(pathWithoutHash)) {
|
|
156
|
+
goto({
|
|
157
|
+
target: 'profile',
|
|
158
|
+
params: { handle: pathWithoutHash.slice(2).split('/')[0] },
|
|
159
|
+
});
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
if (defaultAction.startsWith('goto:')) {
|
|
166
|
+
const gotoPath = defaultAction.slice('goto:'.length);
|
|
167
|
+
const path = gotoPath.startsWith('/') ? gotoPath : `/${gotoPath}`;
|
|
168
|
+
if (navigatePath(path)) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (isLocalLink(defaultAction, BASE_URL as string)) {
|
|
174
|
+
const url = new URL(defaultAction);
|
|
175
|
+
if (navigatePath(`${url.pathname}${url.hash}`)) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const actionList = defaultAction.replace('goto:/', '').split('/');
|
|
181
|
+
|
|
182
|
+
if (actionList[0].startsWith('@')) {
|
|
183
|
+
goto({
|
|
184
|
+
target: 'profile',
|
|
185
|
+
params: { handle: actionList[0].replace('@', '') },
|
|
186
|
+
});
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (actionList[0].startsWith('#')) {
|
|
191
|
+
goto({
|
|
192
|
+
target: 'HashtagPosts',
|
|
193
|
+
params: { tag: actionList[0].replace('#', '') },
|
|
194
|
+
});
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (actionList[0] === 'events' && actionList[2] === 'jam') {
|
|
199
|
+
goto({ target: 'JamSession', params: { jamId: actionList[1] } });
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
goto({ target: actionList[0], params: { id: actionList[1] } });
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export const isProfilePath = (path: string) => path.startsWith('/@');
|
|
207
|
+
export const isGroupPath = (path: string) => path.startsWith('/groups/@');
|
|
208
|
+
export const isJamPath = (path: string) =>
|
|
209
|
+
path.startsWith('/events/') && path.endsWith('/jam');
|
|
210
|
+
export const isPostPath = (path: string) =>
|
|
211
|
+
path.startsWith('/posts/') && path.substring(7);
|
|
212
|
+
|
|
213
|
+
export const isLocalLink = (url: string, origin: string) => {
|
|
214
|
+
try {
|
|
215
|
+
const urlObj = new URL(url);
|
|
216
|
+
return (
|
|
217
|
+
urlObj.origin === origin &&
|
|
218
|
+
(isPostPath(urlObj.pathname) ||
|
|
219
|
+
isJamPath(urlObj.pathname) ||
|
|
220
|
+
isGroupPath(urlObj.pathname))
|
|
221
|
+
);
|
|
222
|
+
} catch {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export const isValidUrl = (url?: string) => {
|
|
228
|
+
if (!url) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
// eslint-disable-next-line no-new
|
|
233
|
+
new URL(url);
|
|
234
|
+
return true;
|
|
235
|
+
} catch {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
export {
|
|
241
|
+
calculateEffectiveRsvps,
|
|
242
|
+
countYesRsvps,
|
|
243
|
+
canManageEventRsvps,
|
|
244
|
+
displayRsvpForProfile,
|
|
245
|
+
isCapacityEvent,
|
|
246
|
+
recurringEventHasOpenOccurrence,
|
|
247
|
+
} from '@openpeepshq/common/lib';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="nativewind/types" />
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollView } from 'react-native';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { useCommunityInfoPages } from '@openpeepshq/react';
|
|
5
|
+
import { AuthLayout } from '../components/layout';
|
|
6
|
+
import { OpenpeepsMarkdown } from '../components/markdown/index';
|
|
7
|
+
import { MainScreenProps } from '../components/navigation/types/index';
|
|
8
|
+
import { ThemedText } from '../components/ui/themed-text';
|
|
9
|
+
|
|
10
|
+
export const About: React.FC<MainScreenProps<'About'>> = () => {
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
const { communityName, aboutPage } = useCommunityInfoPages();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<AuthLayout noRedirect>
|
|
16
|
+
<ScrollView contentContainerClassName="p-4 pb-12">
|
|
17
|
+
<ThemedText className="text-2xl font-bold pb-4">
|
|
18
|
+
{t('about.welcomeTo', {
|
|
19
|
+
defaultValue: `Welcome to ${communityName}`,
|
|
20
|
+
name: communityName,
|
|
21
|
+
})}
|
|
22
|
+
</ThemedText>
|
|
23
|
+
<OpenpeepsMarkdown source={aboutPage} />
|
|
24
|
+
</ScrollView>
|
|
25
|
+
</AuthLayout>
|
|
26
|
+
);
|
|
27
|
+
};
|