@openpeepshq/react 0.2.3
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 +1 -0
- package/dist/auth/credentials/index.d.ts +11 -0
- package/dist/auth/credentials/index.js +57 -0
- package/dist/auth/credentials/types.d.ts +6 -0
- package/dist/auth/credentials/types.js +1 -0
- package/dist/components/accounts/SignUpLoginModal.d.ts +9 -0
- package/dist/components/accounts/SignUpLoginModal.js +19 -0
- package/dist/components/accounts/SignUpLoginModalContext.d.ts +10 -0
- package/dist/components/accounts/SignUpLoginModalContext.js +16 -0
- package/dist/components/accounts/index.d.ts +3 -0
- package/dist/components/accounts/index.js +2 -0
- package/dist/components/configuration/ConfigurationCategory.d.ts +12 -0
- package/dist/components/configuration/ConfigurationCategory.js +61 -0
- package/dist/components/configuration/ConfigurationList.d.ts +10 -0
- package/dist/components/configuration/ConfigurationList.js +30 -0
- package/dist/components/configuration/ConfigurationTree.d.ts +8 -0
- package/dist/components/configuration/ConfigurationTree.js +20 -0
- package/dist/components/configuration/ConfigurationValueEditor.d.ts +11 -0
- package/dist/components/configuration/ConfigurationValueEditor.js +45 -0
- package/dist/components/configuration/index.d.ts +4 -0
- package/dist/components/configuration/index.js +4 -0
- package/dist/components/conversations/ConversationMessageBubble.d.ts +4 -0
- package/dist/components/conversations/ConversationMessageBubble.js +10 -0
- package/dist/components/conversations/CreateNewConversation.d.ts +8 -0
- package/dist/components/conversations/CreateNewConversation.js +62 -0
- package/dist/components/conversations/CreateNewConversationContext.d.ts +15 -0
- package/dist/components/conversations/CreateNewConversationContext.js +18 -0
- package/dist/components/conversations/DirectMessagesHeaderActions.d.ts +1 -0
- package/dist/components/conversations/DirectMessagesHeaderActions.js +10 -0
- package/dist/components/conversations/MessageInThread.d.ts +13 -0
- package/dist/components/conversations/MessageInThread.js +41 -0
- package/dist/components/conversations/index.d.ts +8 -0
- package/dist/components/conversations/index.js +5 -0
- package/dist/components/form/HeaderAvatarInput.d.ts +13 -0
- package/dist/components/form/HeaderAvatarInput.js +16 -0
- package/dist/components/form/ImageEditModal.d.ts +23 -0
- package/dist/components/form/ImageEditModal.js +75 -0
- package/dist/components/form/ImageInput.d.ts +32 -0
- package/dist/components/form/ImageInput.js +65 -0
- package/dist/components/form/LocationInput.d.ts +20 -0
- package/dist/components/form/LocationInput.js +59 -0
- package/dist/components/form/index.d.ts +8 -0
- package/dist/components/form/index.js +4 -0
- package/dist/components/groups/AddGroupMemberModal.d.ts +6 -0
- package/dist/components/groups/AddGroupMemberModal.js +40 -0
- package/dist/components/groups/AddGroupMembersButton.d.ts +5 -0
- package/dist/components/groups/AddGroupMembersButton.js +17 -0
- package/dist/components/groups/ChangeGroupRolesModal.d.ts +7 -0
- package/dist/components/groups/ChangeGroupRolesModal.js +45 -0
- package/dist/components/groups/ConfirmGroupExitModal.d.ts +6 -0
- package/dist/components/groups/ConfirmGroupExitModal.js +35 -0
- package/dist/components/groups/ConfirmMemberRemovalModal.d.ts +7 -0
- package/dist/components/groups/ConfirmMemberRemovalModal.js +33 -0
- package/dist/components/groups/DeleteGroupModal.d.ts +6 -0
- package/dist/components/groups/DeleteGroupModal.js +34 -0
- package/dist/components/groups/GroupAvatar.d.ts +14 -0
- package/dist/components/groups/GroupAvatar.js +32 -0
- package/dist/components/groups/GroupCard.d.ts +19 -0
- package/dist/components/groups/GroupCard.js +12 -0
- package/dist/components/groups/GroupFeed.d.ts +9 -0
- package/dist/components/groups/GroupFeed.js +14 -0
- package/dist/components/groups/GroupForm.d.ts +7 -0
- package/dist/components/groups/GroupForm.js +73 -0
- package/dist/components/groups/GroupHeader.d.ts +5 -0
- package/dist/components/groups/GroupHeader.js +14 -0
- package/dist/components/groups/GroupMembersList.d.ts +5 -0
- package/dist/components/groups/GroupMembersList.js +38 -0
- package/dist/components/groups/GroupOptionsMenu.d.ts +5 -0
- package/dist/components/groups/GroupOptionsMenu.js +61 -0
- package/dist/components/groups/GroupShareMenu.d.ts +5 -0
- package/dist/components/groups/GroupShareMenu.js +29 -0
- package/dist/components/groups/JoinGroupButton.d.ts +6 -0
- package/dist/components/groups/JoinGroupButton.js +28 -0
- package/dist/components/groups/index.d.ts +30 -0
- package/dist/components/groups/index.js +15 -0
- package/dist/components/index.d.ts +15 -0
- package/dist/components/index.js +15 -0
- package/dist/components/jams/CreateNewJam.d.ts +4 -0
- package/dist/components/jams/CreateNewJam.js +138 -0
- package/dist/components/jams/CreateNewJamContext.d.ts +9 -0
- package/dist/components/jams/CreateNewJamContext.js +16 -0
- package/dist/components/jams/JamAnimatedEmoji.d.ts +4 -0
- package/dist/components/jams/JamAnimatedEmoji.js +12 -0
- package/dist/components/jams/JamCallParticipant.d.ts +15 -0
- package/dist/components/jams/JamCallParticipant.js +101 -0
- package/dist/components/jams/JamCapacityGate.d.ts +7 -0
- package/dist/components/jams/JamCapacityGate.js +30 -0
- package/dist/components/jams/JamChatDrawer.d.ts +6 -0
- package/dist/components/jams/JamChatDrawer.js +88 -0
- package/dist/components/jams/JamChatMessage.d.ts +5 -0
- package/dist/components/jams/JamChatMessage.js +35 -0
- package/dist/components/jams/JamConference.d.ts +8 -0
- package/dist/components/jams/JamConference.js +38 -0
- package/dist/components/jams/JamContext.d.ts +20 -0
- package/dist/components/jams/JamContext.js +24 -0
- package/dist/components/jams/JamDetailsDrawer.d.ts +9 -0
- package/dist/components/jams/JamDetailsDrawer.js +39 -0
- package/dist/components/jams/JamDeviceSelectors.d.ts +12 -0
- package/dist/components/jams/JamDeviceSelectors.js +71 -0
- package/dist/components/jams/JamEventsContext.d.ts +14 -0
- package/dist/components/jams/JamEventsContext.js +143 -0
- package/dist/components/jams/JamFooter.d.ts +18 -0
- package/dist/components/jams/JamFooter.js +171 -0
- package/dist/components/jams/JamGuestForm.d.ts +1 -0
- package/dist/components/jams/JamGuestForm.js +55 -0
- package/dist/components/jams/JamLobby.d.ts +17 -0
- package/dist/components/jams/JamLobby.js +159 -0
- package/dist/components/jams/JamObserverShell.d.ts +6 -0
- package/dist/components/jams/JamObserverShell.js +11 -0
- package/dist/components/jams/JamParticipantConference.d.ts +7 -0
- package/dist/components/jams/JamParticipantConference.js +80 -0
- package/dist/components/jams/JamPeopleDrawer.d.ts +10 -0
- package/dist/components/jams/JamPeopleDrawer.js +76 -0
- package/dist/components/jams/JamReactionMenu.d.ts +12 -0
- package/dist/components/jams/JamReactionMenu.js +79 -0
- package/dist/components/jams/JamRequestJoin.d.ts +9 -0
- package/dist/components/jams/JamRequestJoin.js +34 -0
- package/dist/components/jams/JamRoom.d.ts +21 -0
- package/dist/components/jams/JamRoom.js +166 -0
- package/dist/components/jams/JamRoomIndicators.d.ts +10 -0
- package/dist/components/jams/JamRoomIndicators.js +39 -0
- package/dist/components/jams/JamVideoCall.d.ts +15 -0
- package/dist/components/jams/JamVideoCall.js +18 -0
- package/dist/components/jams/JamVideoLayout.d.ts +13 -0
- package/dist/components/jams/JamVideoLayout.js +68 -0
- package/dist/components/jams/LeaveCloseButton.d.ts +6 -0
- package/dist/components/jams/LeaveCloseButton.js +58 -0
- package/dist/components/jams/LiveJamsSection.d.ts +1 -0
- package/dist/components/jams/LiveJamsSection.js +16 -0
- package/dist/components/jams/animateEmoji.d.ts +1 -0
- package/dist/components/jams/animateEmoji.js +48 -0
- package/dist/components/jams/blurProcessor.d.ts +8 -0
- package/dist/components/jams/blurProcessor.js +28 -0
- package/dist/components/jams/constants.d.ts +10 -0
- package/dist/components/jams/constants.js +44 -0
- package/dist/components/jams/index.d.ts +24 -0
- package/dist/components/jams/index.js +19 -0
- package/dist/components/jams/jamEventActions.d.ts +26 -0
- package/dist/components/jams/jamEventActions.js +76 -0
- package/dist/components/jams/jamLocalSettings.d.ts +17 -0
- package/dist/components/jams/jamLocalSettings.js +53 -0
- package/dist/components/jams/jamReactionPreferences.d.ts +15 -0
- package/dist/components/jams/jamReactionPreferences.js +53 -0
- package/dist/components/jams/jamRecordingState.d.ts +10 -0
- package/dist/components/jams/jamRecordingState.js +25 -0
- package/dist/components/jams/reactionEmojis.d.ts +30 -0
- package/dist/components/jams/reactionEmojis.js +73 -0
- package/dist/components/jams/useJamHands.d.ts +7 -0
- package/dist/components/jams/useJamHands.js +39 -0
- package/dist/components/jams/useJamLiveKitTheme.d.ts +3 -0
- package/dist/components/jams/useJamLiveKitTheme.js +10 -0
- package/dist/components/layout/AccessDenied.d.ts +14 -0
- package/dist/components/layout/AccessDenied.js +28 -0
- package/dist/components/layout/AccessDeniedLoader.d.ts +16 -0
- package/dist/components/layout/AccessDeniedLoader.js +12 -0
- package/dist/components/layout/Auth.d.ts +22 -0
- package/dist/components/layout/Auth.js +82 -0
- package/dist/components/layout/IdentityContext.d.ts +17 -0
- package/dist/components/layout/IdentityContext.js +38 -0
- package/dist/components/layout/Infos.d.ts +5 -0
- package/dist/components/layout/Infos.js +42 -0
- package/dist/components/layout/OpenpeepsContextProvider.d.ts +10 -0
- package/dist/components/layout/OpenpeepsContextProvider.js +63 -0
- package/dist/components/layout/OpenpeepsThemeProvider.d.ts +11 -0
- package/dist/components/layout/OpenpeepsThemeProvider.js +47 -0
- package/dist/components/layout/ProfileGuard.d.ts +14 -0
- package/dist/components/layout/ProfileGuard.js +38 -0
- package/dist/components/layout/ProfileProvider.d.ts +10 -0
- package/dist/components/layout/ProfileProvider.js +60 -0
- package/dist/components/layout/Root.d.ts +16 -0
- package/dist/components/layout/Root.js +36 -0
- package/dist/components/layout/ToastProvider.d.ts +22 -0
- package/dist/components/layout/ToastProvider.js +37 -0
- package/dist/components/layout/index.d.ts +21 -0
- package/dist/components/layout/index.js +11 -0
- package/dist/components/markdown/CompiledMarkdown.d.ts +5 -0
- package/dist/components/markdown/CompiledMarkdown.js +3 -0
- package/dist/components/markdown/OpenpeepsMarkdown.d.ts +16 -0
- package/dist/components/markdown/OpenpeepsMarkdown.js +66 -0
- package/dist/components/markdown/classes.d.ts +2 -0
- package/dist/components/markdown/classes.js +2 -0
- package/dist/components/markdown/compileMarkdown.d.ts +5 -0
- package/dist/components/markdown/compileMarkdown.js +36 -0
- package/dist/components/markdown/index.d.ts +11 -0
- package/dist/components/markdown/index.js +7 -0
- package/dist/components/markdown/linkTargets.d.ts +3 -0
- package/dist/components/markdown/linkTargets.js +27 -0
- package/dist/components/markdown/staticRender.d.ts +16 -0
- package/dist/components/markdown/staticRender.js +17 -0
- package/dist/components/navigation/ContentHeader.d.ts +1 -0
- package/dist/components/navigation/ContentHeader.js +18 -0
- package/dist/components/navigation/FooterMobile.d.ts +5 -0
- package/dist/components/navigation/FooterMobile.js +8 -0
- package/dist/components/navigation/HeaderMobile.d.ts +11 -0
- package/dist/components/navigation/HeaderMobile.js +26 -0
- package/dist/components/navigation/MobileMenuItem.d.ts +7 -0
- package/dist/components/navigation/MobileMenuItem.js +13 -0
- package/dist/components/navigation/PageHeaderAction.d.ts +5 -0
- package/dist/components/navigation/PageHeaderAction.js +7 -0
- package/dist/components/navigation/PlusButton.d.ts +1 -0
- package/dist/components/navigation/PlusButton.js +11 -0
- package/dist/components/navigation/SideBar.d.ts +16 -0
- package/dist/components/navigation/SideBar.js +24 -0
- package/dist/components/navigation/SidebarNavContext.d.ts +3 -0
- package/dist/components/navigation/SidebarNavContext.js +4 -0
- package/dist/components/navigation/breadcrumbs/Breadcrumbs.d.ts +1 -0
- package/dist/components/navigation/breadcrumbs/Breadcrumbs.js +10 -0
- package/dist/components/navigation/breadcrumbs/Crumb.d.ts +5 -0
- package/dist/components/navigation/breadcrumbs/Crumb.js +4 -0
- package/dist/components/navigation/index.d.ts +17 -0
- package/dist/components/navigation/index.js +11 -0
- package/dist/components/navigation/sideBarNavLinkClass.d.ts +4 -0
- package/dist/components/navigation/sideBarNavLinkClass.js +3 -0
- package/dist/components/notifications/NotificationErrorBoundary.d.ts +16 -0
- package/dist/components/notifications/NotificationErrorBoundary.js +21 -0
- package/dist/components/notifications/NotificationHeaderActions.d.ts +6 -0
- package/dist/components/notifications/NotificationHeaderActions.js +35 -0
- package/dist/components/notifications/NotificationItem.d.ts +5 -0
- package/dist/components/notifications/NotificationItem.js +6 -0
- package/dist/components/notifications/NotificationWrapper.d.ts +10 -0
- package/dist/components/notifications/NotificationWrapper.js +6 -0
- package/dist/components/notifications/NotificationsList.d.ts +12 -0
- package/dist/components/notifications/NotificationsList.js +88 -0
- package/dist/components/notifications/TypedNotification.d.ts +4 -0
- package/dist/components/notifications/TypedNotification.js +201 -0
- package/dist/components/notifications/index.d.ts +7 -0
- package/dist/components/notifications/index.js +5 -0
- package/dist/components/post/Feed.d.ts +20 -0
- package/dist/components/post/Feed.js +63 -0
- package/dist/components/post/FeedPost.d.ts +17 -0
- package/dist/components/post/FeedPost.js +31 -0
- package/dist/components/post/FeedPostContent.d.ts +5 -0
- package/dist/components/post/FeedPostContent.js +22 -0
- package/dist/components/post/FullPostLayout.d.ts +7 -0
- package/dist/components/post/FullPostLayout.js +23 -0
- package/dist/components/post/Markdown.d.ts +2 -0
- package/dist/components/post/Markdown.js +1 -0
- package/dist/components/post/NewEventButton.d.ts +14 -0
- package/dist/components/post/NewEventButton.js +39 -0
- package/dist/components/post/NewNoteButton.d.ts +14 -0
- package/dist/components/post/NewNoteButton.js +38 -0
- package/dist/components/post/PinnedPost.d.ts +5 -0
- package/dist/components/post/PinnedPost.js +15 -0
- package/dist/components/post/PostDetail.d.ts +4 -0
- package/dist/components/post/PostDetail.js +31 -0
- package/dist/components/post/ReplyBox.d.ts +5 -0
- package/dist/components/post/ReplyBox.js +30 -0
- package/dist/components/post/VideoPlayOverlay.d.ts +5 -0
- package/dist/components/post/VideoPlayOverlay.js +8 -0
- package/dist/components/post/attachmentPreview.d.ts +5 -0
- package/dist/components/post/attachmentPreview.js +14 -0
- package/dist/components/post/feed/events/EventsFeed.d.ts +7 -0
- package/dist/components/post/feed/events/EventsFeed.js +44 -0
- package/dist/components/post/feed/threaded/ThreadPost.d.ts +9 -0
- package/dist/components/post/feed/threaded/ThreadPost.js +19 -0
- package/dist/components/post/feed/threaded/ThreadedFeed.d.ts +10 -0
- package/dist/components/post/feed/threaded/ThreadedFeed.js +8 -0
- package/dist/components/post/helpers.d.ts +6 -0
- package/dist/components/post/helpers.js +24 -0
- package/dist/components/post/index.d.ts +78 -0
- package/dist/components/post/index.js +57 -0
- package/dist/components/post/pieces/Attachments.d.ts +5 -0
- package/dist/components/post/pieces/Attachments.js +44 -0
- package/dist/components/post/pieces/EventLocation.d.ts +7 -0
- package/dist/components/post/pieces/EventLocation.js +28 -0
- package/dist/components/post/pieces/EventMenu.d.ts +6 -0
- package/dist/components/post/pieces/EventMenu.js +35 -0
- package/dist/components/post/pieces/EventRsvpButton.d.ts +5 -0
- package/dist/components/post/pieces/EventRsvpButton.js +60 -0
- package/dist/components/post/pieces/FeedPostStats.d.ts +5 -0
- package/dist/components/post/pieces/FeedPostStats.js +27 -0
- package/dist/components/post/pieces/GalleryModal.d.ts +7 -0
- package/dist/components/post/pieces/GalleryModal.js +16 -0
- package/dist/components/post/pieces/ParticipantsCard.d.ts +8 -0
- package/dist/components/post/pieces/ParticipantsCard.js +13 -0
- package/dist/components/post/pieces/PollContent.d.ts +5 -0
- package/dist/components/post/pieces/PollContent.js +109 -0
- package/dist/components/post/pieces/PostActions.d.ts +6 -0
- package/dist/components/post/pieces/PostActions.js +63 -0
- package/dist/components/post/pieces/PostInfoHeader.d.ts +7 -0
- package/dist/components/post/pieces/PostInfoHeader.js +8 -0
- package/dist/components/post/pieces/PostMenu.d.ts +6 -0
- package/dist/components/post/pieces/PostMenu.js +77 -0
- package/dist/components/post/pieces/PostReactionHeader.d.ts +12 -0
- package/dist/components/post/pieces/PostReactionHeader.js +31 -0
- package/dist/components/post/pieces/ShareMenu.d.ts +6 -0
- package/dist/components/post/pieces/ShareMenu.js +46 -0
- package/dist/components/post/pieces/UnreadPostIndicator.d.ts +9 -0
- package/dist/components/post/pieces/UnreadPostIndicator.js +6 -0
- package/dist/components/post/pieces/VideoPlayer.d.ts +16 -0
- package/dist/components/post/pieces/VideoPlayer.js +127 -0
- package/dist/components/post/pieces/modals/DeletePostModal.d.ts +8 -0
- package/dist/components/post/pieces/modals/DeletePostModal.js +20 -0
- package/dist/components/post/pieces/modals/ReactionsModal.d.ts +7 -0
- package/dist/components/post/pieces/modals/ReactionsModal.js +11 -0
- package/dist/components/post/pieces/modals/RepostModal.d.ts +7 -0
- package/dist/components/post/pieces/modals/RepostModal.js +13 -0
- package/dist/components/post/post-form/ArticleForm.d.ts +7 -0
- package/dist/components/post/post-form/ArticleForm.js +45 -0
- package/dist/components/post/post-form/AttachmentCard.d.ts +29 -0
- package/dist/components/post/post-form/AttachmentCard.js +120 -0
- package/dist/components/post/post-form/ComposeAttachments.d.ts +25 -0
- package/dist/components/post/post-form/ComposeAttachments.js +137 -0
- package/dist/components/post/post-form/ComposePreviewLinks.d.ts +4 -0
- package/dist/components/post/post-form/ComposePreviewLinks.js +9 -0
- package/dist/components/post/post-form/DescriptionEditModal.d.ts +13 -0
- package/dist/components/post/post-form/DescriptionEditModal.js +22 -0
- package/dist/components/post/post-form/EditPostModal.d.ts +6 -0
- package/dist/components/post/post-form/EditPostModal.js +81 -0
- package/dist/components/post/post-form/EditPostModalContext.d.ts +10 -0
- package/dist/components/post/post-form/EditPostModalContext.js +18 -0
- package/dist/components/post/post-form/EventForm.d.ts +7 -0
- package/dist/components/post/post-form/EventForm.js +104 -0
- package/dist/components/post/post-form/EventTypeSwitcher.d.ts +8 -0
- package/dist/components/post/post-form/EventTypeSwitcher.js +165 -0
- package/dist/components/post/post-form/NewPostModal.d.ts +13 -0
- package/dist/components/post/post-form/NewPostModal.js +272 -0
- package/dist/components/post/post-form/NewPostModalContext.d.ts +15 -0
- package/dist/components/post/post-form/NewPostModalContext.js +20 -0
- package/dist/components/post/post-form/OpenpeepsMarkdownInput.d.ts +19 -0
- package/dist/components/post/post-form/OpenpeepsMarkdownInput.js +65 -0
- package/dist/components/post/post-form/PollComposerFields.d.ts +12 -0
- package/dist/components/post/post-form/PollComposerFields.js +19 -0
- package/dist/components/post/post-form/PostAudienceSelector.d.ts +12 -0
- package/dist/components/post/post-form/PostAudienceSelector.js +83 -0
- package/dist/components/post/post-form/PostTypeSwitcher.d.ts +16 -0
- package/dist/components/post/post-form/PostTypeSwitcher.js +22 -0
- package/dist/components/post/post-form/ReplyModal.d.ts +6 -0
- package/dist/components/post/post-form/ReplyModal.js +202 -0
- package/dist/components/post/post-form/ReplyModalContext.d.ts +10 -0
- package/dist/components/post/post-form/ReplyModalContext.js +18 -0
- package/dist/components/post/post-form/VisibilitySelector.d.ts +8 -0
- package/dist/components/post/post-form/VisibilitySelector.js +35 -0
- package/dist/components/post/post-form/audienceChoices.d.ts +14 -0
- package/dist/components/post/post-form/audienceChoices.js +66 -0
- package/dist/components/post/types/Article.d.ts +5 -0
- package/dist/components/post/types/Article.js +14 -0
- package/dist/components/post/types/Event.d.ts +5 -0
- package/dist/components/post/types/Event.js +19 -0
- package/dist/components/post/types/Note.d.ts +5 -0
- package/dist/components/post/types/Note.js +10 -0
- package/dist/components/post/types/Poll.d.ts +7 -0
- package/dist/components/post/types/Poll.js +11 -0
- package/dist/components/post/types/article/FullArticle.d.ts +5 -0
- package/dist/components/post/types/article/FullArticle.js +8 -0
- package/dist/components/post/types/event/CardEvent.d.ts +5 -0
- package/dist/components/post/types/event/CardEvent.js +45 -0
- package/dist/components/post/types/event/FullEvent.d.ts +5 -0
- package/dist/components/post/types/event/FullEvent.js +161 -0
- package/dist/components/post/types/event/ProfileEventRelationship.d.ts +5 -0
- package/dist/components/post/types/event/ProfileEventRelationship.js +31 -0
- package/dist/components/post/types/note/FullNote.d.ts +5 -0
- package/dist/components/post/types/note/FullNote.js +5 -0
- package/dist/components/post/types/poll/FullPoll.d.ts +5 -0
- package/dist/components/post/types/poll/FullPoll.js +7 -0
- package/dist/components/post/visibility.d.ts +7 -0
- package/dist/components/post/visibility.js +10 -0
- package/dist/components/preview-link/LocalPreviewLink.d.ts +4 -0
- package/dist/components/preview-link/LocalPreviewLink.js +12 -0
- package/dist/components/preview-link/PreviewLink.d.ts +4 -0
- package/dist/components/preview-link/PreviewLink.js +11 -0
- package/dist/components/preview-link/RemotePreviewLink.d.ts +4 -0
- package/dist/components/preview-link/RemotePreviewLink.js +21 -0
- package/dist/components/preview-link/helpers.d.ts +7 -0
- package/dist/components/preview-link/helpers.js +31 -0
- package/dist/components/preview-link/index.d.ts +3 -0
- package/dist/components/preview-link/index.js +2 -0
- package/dist/components/preview-link/local/GroupPreview.d.ts +4 -0
- package/dist/components/preview-link/local/GroupPreview.js +15 -0
- package/dist/components/preview-link/local/JamPreview.d.ts +9 -0
- package/dist/components/preview-link/local/JamPreview.js +20 -0
- package/dist/components/preview-link/local/PostPreview.d.ts +4 -0
- package/dist/components/preview-link/local/PostPreview.js +15 -0
- package/dist/components/profile/Avatar.d.ts +17 -0
- package/dist/components/profile/Avatar.js +36 -0
- package/dist/components/profile/AvatarWithName.d.ts +5 -0
- package/dist/components/profile/AvatarWithName.js +5 -0
- package/dist/components/profile/FollowUnfollowButton.d.ts +8 -0
- package/dist/components/profile/FollowUnfollowButton.js +27 -0
- package/dist/components/profile/ProfileBadge.d.ts +7 -0
- package/dist/components/profile/ProfileBadge.js +12 -0
- package/dist/components/profile/ProfileCard.d.ts +24 -0
- package/dist/components/profile/ProfileCard.js +12 -0
- package/dist/components/profile/ProfileFromId.d.ts +6 -0
- package/dist/components/profile/ProfileFromId.js +15 -0
- package/dist/components/profile/ProfileHeader.d.ts +10 -0
- package/dist/components/profile/ProfileHeader.js +16 -0
- package/dist/components/profile/ProfileLink.d.ts +9 -0
- package/dist/components/profile/ProfileLink.js +9 -0
- package/dist/components/profile/ProfilePageAction.d.ts +6 -0
- package/dist/components/profile/ProfilePageAction.js +35 -0
- package/dist/components/profile/ProfilePostsAndReplies.d.ts +9 -0
- package/dist/components/profile/ProfilePostsAndReplies.js +24 -0
- package/dist/components/profile/ProfileSelector.d.ts +14 -0
- package/dist/components/profile/ProfileSelector.js +72 -0
- package/dist/components/profile/ProfileStats.d.ts +5 -0
- package/dist/components/profile/ProfileStats.js +6 -0
- package/dist/components/profile/ProfileWithActionCard.d.ts +5 -0
- package/dist/components/profile/ProfileWithActionCard.js +6 -0
- package/dist/components/profile/ProfilesInput.d.ts +15 -0
- package/dist/components/profile/ProfilesInput.js +31 -0
- package/dist/components/profile/ReportProfileOrPostModal.d.ts +9 -0
- package/dist/components/profile/ReportProfileOrPostModal.js +75 -0
- package/dist/components/profile/index.d.ts +30 -0
- package/dist/components/profile/index.js +15 -0
- package/dist/components/registry/ErrorComponent.d.ts +6 -0
- package/dist/components/registry/ErrorComponent.js +7 -0
- package/dist/components/registry/PluginLoader.d.ts +3 -0
- package/dist/components/registry/PluginLoader.js +51 -0
- package/dist/components/registry/PluginRegistryProvider.d.ts +23 -0
- package/dist/components/registry/PluginRegistryProvider.js +57 -0
- package/dist/components/registry/PluginSlot.d.ts +7 -0
- package/dist/components/registry/PluginSlot.js +31 -0
- package/dist/components/registry/index.d.ts +10 -0
- package/dist/components/registry/index.js +16 -0
- package/dist/components/server-data/ServerDataProvider.d.ts +8 -0
- package/dist/components/server-data/ServerDataProvider.js +30 -0
- package/dist/components/server-data/context.d.ts +121 -0
- package/dist/components/server-data/context.js +10 -0
- package/dist/components/server-data/index.d.ts +4 -0
- package/dist/components/server-data/index.js +2 -0
- package/dist/components/server-data/types.d.ts +5 -0
- package/dist/components/server-data/types.js +1 -0
- package/dist/contexts/credentialsStore/index.d.ts +8 -0
- package/dist/contexts/credentialsStore/index.js +13 -0
- package/dist/contexts/credentialsStore/types.d.ts +4 -0
- package/dist/contexts/credentialsStore/types.js +1 -0
- package/dist/contexts/index.d.ts +3 -0
- package/dist/contexts/index.js +3 -0
- package/dist/contexts/openpeeps/helpers.d.ts +93 -0
- package/dist/contexts/openpeeps/helpers.js +311 -0
- package/dist/contexts/openpeeps/hooks/accounts.d.ts +302 -0
- package/dist/contexts/openpeeps/hooks/accounts.js +17 -0
- package/dist/contexts/openpeeps/hooks/admin.d.ts +17177 -0
- package/dist/contexts/openpeeps/hooks/admin.js +115 -0
- package/dist/contexts/openpeeps/hooks/auth.d.ts +55 -0
- package/dist/contexts/openpeeps/hooks/auth.js +22 -0
- package/dist/contexts/openpeeps/hooks/conversations.d.ts +9815 -0
- package/dist/contexts/openpeeps/hooks/conversations.js +6 -0
- package/dist/contexts/openpeeps/hooks/groups.d.ts +319 -0
- package/dist/contexts/openpeeps/hooks/groups.js +31 -0
- package/dist/contexts/openpeeps/hooks/index.d.ts +18 -0
- package/dist/contexts/openpeeps/hooks/index.js +26 -0
- package/dist/contexts/openpeeps/hooks/jams.d.ts +3318 -0
- package/dist/contexts/openpeeps/hooks/jams.js +32 -0
- package/dist/contexts/openpeeps/hooks/other.d.ts +239 -0
- package/dist/contexts/openpeeps/hooks/other.js +89 -0
- package/dist/contexts/openpeeps/hooks/payments.d.ts +36 -0
- package/dist/contexts/openpeeps/hooks/payments.js +10 -0
- package/dist/contexts/openpeeps/hooks/posts.d.ts +26001 -0
- package/dist/contexts/openpeeps/hooks/posts.js +139 -0
- package/dist/contexts/openpeeps/hooks/profiles.d.ts +6896 -0
- package/dist/contexts/openpeeps/hooks/profiles.js +43 -0
- package/dist/contexts/openpeeps/hooks/search.d.ts +9620 -0
- package/dist/contexts/openpeeps/hooks/search.js +24 -0
- package/dist/contexts/openpeeps/hooks/streaming.d.ts +26 -0
- package/dist/contexts/openpeeps/hooks/streaming.js +10 -0
- package/dist/contexts/openpeeps/hooks/useHasAuthToken.d.ts +2 -0
- package/dist/contexts/openpeeps/hooks/useHasAuthToken.js +35 -0
- package/dist/contexts/openpeeps/index.d.ts +21 -0
- package/dist/contexts/openpeeps/index.js +180 -0
- package/dist/contexts/openpeeps/types.d.ts +11 -0
- package/dist/contexts/openpeeps/types.js +1 -0
- package/dist/contexts/router/index.d.ts +28 -0
- package/dist/contexts/router/index.js +69 -0
- package/dist/email/index.d.ts +13 -0
- package/dist/email/index.js +10 -0
- package/dist/i18n/I18nProvider.d.ts +19 -0
- package/dist/i18n/I18nProvider.js +33 -0
- package/dist/i18n/context.d.ts +8 -0
- package/dist/i18n/context.js +10 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/index.js +23 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +14 -0
- package/dist/lib/apiErrorMessage.d.ts +3 -0
- package/dist/lib/apiErrorMessage.js +14 -0
- package/dist/lib/canvasUtils.d.ts +12 -0
- package/dist/lib/canvasUtils.js +104 -0
- package/dist/lib/configuration/helpers.d.ts +7 -0
- package/dist/lib/configuration/helpers.js +83 -0
- package/dist/lib/configuration/resolveSchema.d.ts +3 -0
- package/dist/lib/configuration/resolveSchema.js +8 -0
- package/dist/lib/groupCapabilityHelpers.d.ts +24 -0
- package/dist/lib/groupCapabilityHelpers.js +119 -0
- package/dist/lib/notificationBadge.d.ts +5 -0
- package/dist/lib/notificationBadge.js +25 -0
- package/dist/lib/postUnread.d.ts +2 -0
- package/dist/lib/postUnread.js +1 -0
- package/dist/lib/postViewCounter.d.ts +17 -0
- package/dist/lib/postViewCounter.js +162 -0
- package/dist/lib/threadHelpers.d.ts +5 -0
- package/dist/lib/threadHelpers.js +23 -0
- package/dist/lib/unseenCountsOptimistic.d.ts +15 -0
- package/dist/lib/unseenCountsOptimistic.js +43 -0
- package/dist/log/index.d.ts +11 -0
- package/dist/log/index.js +14 -0
- package/dist/push/index.d.ts +16 -0
- package/dist/push/index.js +145 -0
- package/dist/push/usePushSubscription.d.ts +18 -0
- package/dist/push/usePushSubscription.js +102 -0
- package/dist/push/vapid.d.ts +6 -0
- package/dist/push/vapid.js +12 -0
- package/dist/pwa/InstallPrompt.d.ts +13 -0
- package/dist/pwa/InstallPrompt.js +17 -0
- package/dist/pwa/NotificationPermissionPrompt.d.ts +22 -0
- package/dist/pwa/NotificationPermissionPrompt.js +56 -0
- package/dist/pwa/PwaProvider.d.ts +16 -0
- package/dist/pwa/PwaProvider.js +56 -0
- package/dist/pwa/UpdatePrompt.d.ts +14 -0
- package/dist/pwa/UpdatePrompt.js +14 -0
- package/dist/pwa/index.d.ts +18 -0
- package/dist/pwa/index.js +16 -0
- package/dist/pwa/navigationUrl.d.ts +16 -0
- package/dist/pwa/navigationUrl.js +51 -0
- package/dist/pwa/pushInvalidate.d.ts +7 -0
- package/dist/pwa/pushInvalidate.js +29 -0
- package/dist/pwa/registration.d.ts +28 -0
- package/dist/pwa/registration.js +71 -0
- package/dist/pwa/sw-types.d.ts +14 -0
- package/dist/pwa/sw-types.js +1 -0
- package/dist/pwa/sw.d.ts +2 -0
- package/dist/pwa/sw.js +171 -0
- package/dist/pwa/useInstallPrompt.d.ts +10 -0
- package/dist/pwa/useInstallPrompt.js +45 -0
- package/dist/pwa/useNotificationBadgeSync.d.ts +2 -0
- package/dist/pwa/useNotificationBadgeSync.js +23 -0
- package/dist/pwa/useServiceWorker.d.ts +19 -0
- package/dist/pwa/useServiceWorker.js +49 -0
- package/dist/pwa/vite.d.ts +50 -0
- package/dist/pwa/vite.js +53 -0
- package/dist/react-native.d.ts +11 -0
- package/dist/react-native.js +11 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +5 -0
- package/dist/stores/breadcrumbs.d.ts +5 -0
- package/dist/stores/breadcrumbs.js +5 -0
- package/dist/stores/createStore.d.ts +19 -0
- package/dist/stores/createStore.js +63 -0
- package/dist/stores/index.d.ts +7 -0
- package/dist/stores/index.js +9 -0
- package/dist/stores/newPosts.d.ts +591 -0
- package/dist/stores/newPosts.js +191 -0
- package/dist/stores/pageHeader.d.ts +15 -0
- package/dist/stores/pageHeader.js +22 -0
- package/dist/stores/plusButton.d.ts +5 -0
- package/dist/stores/plusButton.js +13 -0
- package/dist/stores/types.d.ts +35 -0
- package/dist/stores/types.js +1 -0
- package/dist/streaming.d.ts +6 -0
- package/dist/streaming.js +6 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/index.js +1 -0
- package/package.json +72 -0
- package/src/pwa/navigationUrl.ts +61 -0
- package/src/pwa/sw-types.ts +9 -0
- package/src/pwa/sw.ts +228 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { randomString } from '@openpeepshq/common/lib';
|
|
2
|
+
const imageFileExtension = 'webp';
|
|
3
|
+
const imageFileFormat = `image/${imageFileExtension}`;
|
|
4
|
+
const canvasToFile = (canvas) => new Promise((resolve, reject) => canvas.toBlob((blob) => blob
|
|
5
|
+
? resolve(new File([blob], `${randomString(8)}.${imageFileExtension}`, {
|
|
6
|
+
type: imageFileFormat,
|
|
7
|
+
}))
|
|
8
|
+
: reject(new Error('Error converting canvas to file')), imageFileFormat, 0.9));
|
|
9
|
+
export const createImage = (imageSrc) => new Promise((resolve, reject) => {
|
|
10
|
+
const image = new Image();
|
|
11
|
+
image.addEventListener('load', () => resolve(image));
|
|
12
|
+
image.addEventListener('error', (error) => reject(error));
|
|
13
|
+
image.setAttribute('crossOrigin', 'anonymous');
|
|
14
|
+
image.src =
|
|
15
|
+
typeof imageSrc === 'string' ? imageSrc : URL.createObjectURL(imageSrc);
|
|
16
|
+
});
|
|
17
|
+
export const getCroppedImg = async (imageSrc, pixelCrop) => {
|
|
18
|
+
const image = await createImage(imageSrc);
|
|
19
|
+
const canvas = document.createElement('canvas');
|
|
20
|
+
const ctx = canvas.getContext('2d');
|
|
21
|
+
canvas.width = pixelCrop.width;
|
|
22
|
+
canvas.height = pixelCrop.height;
|
|
23
|
+
ctx?.drawImage(image, pixelCrop.x, pixelCrop.y, pixelCrop.width, pixelCrop.height, 0, 0, pixelCrop.width, pixelCrop.height);
|
|
24
|
+
return canvasToFile(canvas);
|
|
25
|
+
};
|
|
26
|
+
export const centerCropToAspectRatio = async (imageSrc, aspectW, aspectH) => {
|
|
27
|
+
const image = await createImage(imageSrc);
|
|
28
|
+
const iw = image.width;
|
|
29
|
+
const ih = image.height;
|
|
30
|
+
const targetRatio = aspectW / aspectH;
|
|
31
|
+
const imgRatio = iw / ih;
|
|
32
|
+
let sx;
|
|
33
|
+
let sy;
|
|
34
|
+
let sw;
|
|
35
|
+
let sh;
|
|
36
|
+
if (imgRatio > targetRatio) {
|
|
37
|
+
sh = ih;
|
|
38
|
+
sw = Math.round(ih * targetRatio);
|
|
39
|
+
sx = Math.round((iw - sw) / 2);
|
|
40
|
+
sy = 0;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
sw = iw;
|
|
44
|
+
sh = Math.round(iw / targetRatio);
|
|
45
|
+
sx = 0;
|
|
46
|
+
sy = Math.round((ih - sh) / 2);
|
|
47
|
+
}
|
|
48
|
+
const canvas = document.createElement('canvas');
|
|
49
|
+
canvas.width = sw;
|
|
50
|
+
canvas.height = sh;
|
|
51
|
+
const ctx = canvas.getContext('2d');
|
|
52
|
+
ctx?.drawImage(image, sx, sy, sw, sh, 0, 0, sw, sh);
|
|
53
|
+
return canvasToFile(canvas);
|
|
54
|
+
};
|
|
55
|
+
export const getRotatedImage = async (imageSrc, rotation = 0) => {
|
|
56
|
+
const image = await createImage(imageSrc);
|
|
57
|
+
const canvas = document.createElement('canvas');
|
|
58
|
+
const ctx = canvas.getContext('2d');
|
|
59
|
+
const orientationChanged = rotation === 90 || rotation === -90 || rotation === 270 || rotation === -270;
|
|
60
|
+
if (orientationChanged) {
|
|
61
|
+
canvas.width = image.height;
|
|
62
|
+
canvas.height = image.width;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
canvas.width = image.width;
|
|
66
|
+
canvas.height = image.height;
|
|
67
|
+
}
|
|
68
|
+
ctx?.translate(canvas.width / 2, canvas.height / 2);
|
|
69
|
+
ctx?.rotate((rotation * Math.PI) / 180);
|
|
70
|
+
ctx?.drawImage(image, -image.width / 2, -image.height / 2);
|
|
71
|
+
return canvasToFile(canvas);
|
|
72
|
+
};
|
|
73
|
+
export const getZoomedImage = async (imageSrc, zoom) => {
|
|
74
|
+
const image = await createImage(imageSrc);
|
|
75
|
+
const canvas = document.createElement('canvas');
|
|
76
|
+
const ctx = canvas.getContext('2d');
|
|
77
|
+
const scaledWidth = Math.round(image.width * zoom);
|
|
78
|
+
const scaledHeight = Math.round(image.height * zoom);
|
|
79
|
+
canvas.width = scaledWidth;
|
|
80
|
+
canvas.height = scaledHeight;
|
|
81
|
+
ctx?.drawImage(image, 0, 0, scaledWidth, scaledHeight);
|
|
82
|
+
return canvasToFile(canvas);
|
|
83
|
+
};
|
|
84
|
+
export async function convertToWebpIfHeic(file) {
|
|
85
|
+
const isHeic = file.name.toLowerCase().endsWith('.heic') ||
|
|
86
|
+
file.name.toLowerCase().endsWith('.heif') ||
|
|
87
|
+
file.type.includes('heic');
|
|
88
|
+
if (!isHeic)
|
|
89
|
+
return file;
|
|
90
|
+
if (typeof window === 'undefined')
|
|
91
|
+
return file;
|
|
92
|
+
try {
|
|
93
|
+
const heic2any = (await import('heic2any')).default;
|
|
94
|
+
const convertedBlob = await heic2any({
|
|
95
|
+
blob: file,
|
|
96
|
+
toType: 'image/webp',
|
|
97
|
+
quality: 0.9,
|
|
98
|
+
});
|
|
99
|
+
return new File([convertedBlob], file.name.replace(/\.(heic|heif)$/i, '.webp'), { type: 'image/webp' });
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return file;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ZodType } from 'zod';
|
|
2
|
+
import type { ConfigElement, ConfigTree } from '@openpeepshq/common/types';
|
|
3
|
+
export declare const unwrap: (schema: ZodType) => ZodType;
|
|
4
|
+
export declare const diffConfigTrees: (lhs: ConfigTree, rhs: ConfigTree) => any;
|
|
5
|
+
export declare const diffConfigElements: (lhs: ConfigElement, rhs: ConfigElement) => any;
|
|
6
|
+
export declare const equal: (lhs: ConfigTree, rhs: ConfigTree) => boolean;
|
|
7
|
+
export declare const isFieldHidden: (schema: ZodType) => boolean;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const unwrap = (schema) => {
|
|
3
|
+
const s = schema;
|
|
4
|
+
switch (s.def?.type) {
|
|
5
|
+
case 'optional':
|
|
6
|
+
case 'nullable':
|
|
7
|
+
return unwrap(s.unwrap());
|
|
8
|
+
case 'default':
|
|
9
|
+
return unwrap(s.removeDefault());
|
|
10
|
+
case 'pipe':
|
|
11
|
+
return unwrap((s.in ?? s.def?.in));
|
|
12
|
+
case 'readonly':
|
|
13
|
+
case 'catch':
|
|
14
|
+
case 'prefault':
|
|
15
|
+
return unwrap(s.def.innerType);
|
|
16
|
+
}
|
|
17
|
+
const zodClassic = z;
|
|
18
|
+
if (zodClassic.ZodEffects &&
|
|
19
|
+
schema instanceof zodClassic.ZodEffects) {
|
|
20
|
+
return unwrap(s.sourceType());
|
|
21
|
+
}
|
|
22
|
+
if (zodClassic.ZodTransformer &&
|
|
23
|
+
schema instanceof zodClassic.ZodTransformer) {
|
|
24
|
+
return unwrap(s.sourceType());
|
|
25
|
+
}
|
|
26
|
+
if (schema instanceof z.ZodOptional) {
|
|
27
|
+
return unwrap(s.unwrap());
|
|
28
|
+
}
|
|
29
|
+
if (schema instanceof z.ZodDefault) {
|
|
30
|
+
return unwrap(s.removeDefault());
|
|
31
|
+
}
|
|
32
|
+
return schema;
|
|
33
|
+
};
|
|
34
|
+
const isDate = (d) => d instanceof Date;
|
|
35
|
+
const isEmpty = (o) => Object.keys(o).length === 0;
|
|
36
|
+
const isObject = (o) => o != null && typeof o === 'object';
|
|
37
|
+
const hasOwnProperty = (o, key) => Object.prototype.hasOwnProperty.call(o, key);
|
|
38
|
+
const isEmptyObject = (o) => isObject(o) && isEmpty(o);
|
|
39
|
+
const makeObjectWithoutPrototype = () => Object.create(null);
|
|
40
|
+
export const diffConfigTrees = (lhs, rhs) => {
|
|
41
|
+
const deletedValues = Object.keys(lhs).reduce((acc, key) => {
|
|
42
|
+
if (!hasOwnProperty(rhs, key)) {
|
|
43
|
+
acc[key] = undefined;
|
|
44
|
+
}
|
|
45
|
+
return acc;
|
|
46
|
+
}, makeObjectWithoutPrototype());
|
|
47
|
+
if (isDate(lhs) || isDate(rhs)) {
|
|
48
|
+
if (lhs.valueOf() == rhs.valueOf())
|
|
49
|
+
return {};
|
|
50
|
+
return rhs;
|
|
51
|
+
}
|
|
52
|
+
return Object.keys(rhs).reduce((acc, key) => {
|
|
53
|
+
if (!hasOwnProperty(lhs, key) && rhs[key] !== undefined) {
|
|
54
|
+
acc[key] = rhs[key];
|
|
55
|
+
return acc;
|
|
56
|
+
}
|
|
57
|
+
const difference = diffConfigElements(lhs[key], rhs[key]);
|
|
58
|
+
if (isEmptyObject(difference) &&
|
|
59
|
+
!isDate(difference) &&
|
|
60
|
+
(isEmptyObject(lhs[key]) || !isEmptyObject(rhs[key]))) {
|
|
61
|
+
return acc;
|
|
62
|
+
}
|
|
63
|
+
acc[key] = difference;
|
|
64
|
+
return acc;
|
|
65
|
+
}, deletedValues);
|
|
66
|
+
};
|
|
67
|
+
export const diffConfigElements = (lhs, rhs) => {
|
|
68
|
+
if (lhs === rhs)
|
|
69
|
+
return {};
|
|
70
|
+
if (Array.isArray(lhs) || Array.isArray(rhs))
|
|
71
|
+
return rhs;
|
|
72
|
+
if (!isObject(lhs) || !isObject(rhs))
|
|
73
|
+
return rhs;
|
|
74
|
+
return diffConfigTrees(lhs, rhs);
|
|
75
|
+
};
|
|
76
|
+
export const equal = (lhs, rhs) => Object.keys(diffConfigTrees(lhs, rhs)).length === 0;
|
|
77
|
+
export const isFieldHidden = (schema) => {
|
|
78
|
+
const description = schema.description;
|
|
79
|
+
if (description === 'fixed' || description === 'hidden')
|
|
80
|
+
return true;
|
|
81
|
+
const unwrapped = unwrap(schema);
|
|
82
|
+
return (unwrapped.description === 'fixed' || unwrapped.description === 'hidden');
|
|
83
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { capabilitiesConfigSchema, communityConfigSanitizedSchema, coreConfigSanitizedSchema, } from '@openpeepshq/common/types';
|
|
2
|
+
const configSchemas = {
|
|
3
|
+
'openpeeps-core': coreConfigSanitizedSchema,
|
|
4
|
+
'openpeeps-community': communityConfigSanitizedSchema,
|
|
5
|
+
'openpeeps-capabilities': capabilitiesConfigSchema,
|
|
6
|
+
};
|
|
7
|
+
/** Client-side schemas registered in `@openpeepshq/core` config (mirrors Svelte admin). */
|
|
8
|
+
export const resolveAdminConfigSchema = (namespace, name) => configSchemas[`${namespace}-${name}`];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { GroupData } from '@openpeepshq/common/types';
|
|
2
|
+
type GroupCapabilities = GroupData['capabilities'];
|
|
3
|
+
export declare function getGroupVisibilityValue(capabilities: GroupCapabilities | undefined): "local" | "public" | "private";
|
|
4
|
+
export declare function getGroupPostsVisibilityValue(capabilities: GroupCapabilities | undefined): "local" | "public" | "private";
|
|
5
|
+
export declare function getGroupWhoCanJoinValue(capabilities: GroupCapabilities | undefined): "open" | "closed";
|
|
6
|
+
export declare function getGroupWhoCanPostValue(capabilities: GroupCapabilities | undefined): "admin" | "members";
|
|
7
|
+
export declare function getGroupWhoCanPostEventsValue(capabilities: GroupCapabilities | undefined): "admin" | "members";
|
|
8
|
+
export declare function setGroupVisibility(groupData: {
|
|
9
|
+
capabilities: GroupCapabilities;
|
|
10
|
+
}, value: string): void;
|
|
11
|
+
export declare function setGroupPostsVisibility(groupData: {
|
|
12
|
+
capabilities: GroupCapabilities;
|
|
13
|
+
}, value: string): void;
|
|
14
|
+
export declare function setGroupWhoCanJoin(groupData: {
|
|
15
|
+
capabilities: GroupCapabilities;
|
|
16
|
+
}, value: string): void;
|
|
17
|
+
export declare function setGroupWhoCanPost(groupData: {
|
|
18
|
+
capabilities: GroupCapabilities;
|
|
19
|
+
}, value: string): void;
|
|
20
|
+
export declare function setGroupWhoCanPostEvents(groupData: {
|
|
21
|
+
capabilities: GroupCapabilities;
|
|
22
|
+
}, value: string): void;
|
|
23
|
+
export declare function postsVisibilityOptionsForGroup(visibilityValue: string): string[];
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const addCapabilities = (capabilitiesToAdd, capabilities = []) => [...capabilities, ...capabilitiesToAdd];
|
|
2
|
+
const removeCapabilities = (capabilitiesToRemove, capabilities = []) => capabilities.filter((c) => !capabilitiesToRemove.includes(c));
|
|
3
|
+
export function getGroupVisibilityValue(capabilities) {
|
|
4
|
+
if (capabilities?.none?.add?.includes('core-groups-read'))
|
|
5
|
+
return 'public';
|
|
6
|
+
if (capabilities?.local?.add?.includes('core-groups-read'))
|
|
7
|
+
return 'local';
|
|
8
|
+
return 'private';
|
|
9
|
+
}
|
|
10
|
+
export function getGroupPostsVisibilityValue(capabilities) {
|
|
11
|
+
if (capabilities?.none?.add?.includes('core-posts-read'))
|
|
12
|
+
return 'public';
|
|
13
|
+
if (capabilities?.local?.add?.includes('core-posts-read'))
|
|
14
|
+
return 'local';
|
|
15
|
+
return 'private';
|
|
16
|
+
}
|
|
17
|
+
export function getGroupWhoCanJoinValue(capabilities) {
|
|
18
|
+
return capabilities?.local?.add?.includes('core-groups-join') ? 'open' : 'closed';
|
|
19
|
+
}
|
|
20
|
+
export function getGroupWhoCanPostValue(capabilities) {
|
|
21
|
+
return capabilities?.member?.add?.includes('core-posts-create-*')
|
|
22
|
+
? 'members'
|
|
23
|
+
: 'admin';
|
|
24
|
+
}
|
|
25
|
+
export function getGroupWhoCanPostEventsValue(capabilities) {
|
|
26
|
+
return capabilities?.member?.remove?.includes('core-posts-create-event')
|
|
27
|
+
? 'admin'
|
|
28
|
+
: 'members';
|
|
29
|
+
}
|
|
30
|
+
export function setGroupVisibility(groupData, value) {
|
|
31
|
+
const capabilities = groupData.capabilities;
|
|
32
|
+
groupData.capabilities = {
|
|
33
|
+
...capabilities,
|
|
34
|
+
none: {
|
|
35
|
+
add: value === 'public'
|
|
36
|
+
? addCapabilities(['core-groups-read'], capabilities.none?.add)
|
|
37
|
+
: removeCapabilities(['core-groups-read'], capabilities.none?.add),
|
|
38
|
+
},
|
|
39
|
+
local: {
|
|
40
|
+
add: value === 'local'
|
|
41
|
+
? addCapabilities(['core-groups-read'], capabilities.local?.add)
|
|
42
|
+
: removeCapabilities(['core-groups-read'], capabilities.local?.add),
|
|
43
|
+
},
|
|
44
|
+
member: {
|
|
45
|
+
add: value === 'private'
|
|
46
|
+
? addCapabilities(['core-groups-read'], capabilities.member?.add)
|
|
47
|
+
: removeCapabilities(['core-groups-read'], capabilities.member?.add),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
const postsVisibility = getGroupPostsVisibilityValue(groupData.capabilities);
|
|
51
|
+
if (value === 'local' && postsVisibility === 'public') {
|
|
52
|
+
setGroupPostsVisibility(groupData, 'local');
|
|
53
|
+
}
|
|
54
|
+
else if (value === 'private') {
|
|
55
|
+
setGroupPostsVisibility(groupData, 'private');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function setGroupPostsVisibility(groupData, value) {
|
|
59
|
+
const capabilities = groupData.capabilities;
|
|
60
|
+
groupData.capabilities = {
|
|
61
|
+
...capabilities,
|
|
62
|
+
none: {
|
|
63
|
+
add: value === 'public'
|
|
64
|
+
? addCapabilities(['core-posts-read'], capabilities.none?.add)
|
|
65
|
+
: removeCapabilities(['core-posts-read'], capabilities.none?.add),
|
|
66
|
+
},
|
|
67
|
+
local: {
|
|
68
|
+
add: value === 'local'
|
|
69
|
+
? addCapabilities(['core-posts-read'], capabilities.local?.add)
|
|
70
|
+
: removeCapabilities(['core-posts-read'], capabilities.local?.add),
|
|
71
|
+
},
|
|
72
|
+
member: {
|
|
73
|
+
add: value === 'private'
|
|
74
|
+
? addCapabilities(['core-posts-read'], capabilities.member?.add)
|
|
75
|
+
: removeCapabilities(['core-posts-read'], capabilities.member?.add),
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export function setGroupWhoCanJoin(groupData, value) {
|
|
80
|
+
const capabilities = groupData.capabilities;
|
|
81
|
+
groupData.capabilities = {
|
|
82
|
+
...capabilities,
|
|
83
|
+
local: {
|
|
84
|
+
add: value === 'open'
|
|
85
|
+
? addCapabilities(['core-groups-join'], capabilities.local?.add)
|
|
86
|
+
: removeCapabilities(['core-groups-join'], capabilities.local?.add),
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export function setGroupWhoCanPost(groupData, value) {
|
|
91
|
+
const capabilities = groupData.capabilities;
|
|
92
|
+
groupData.capabilities = {
|
|
93
|
+
...capabilities,
|
|
94
|
+
member: {
|
|
95
|
+
add: value === 'members'
|
|
96
|
+
? addCapabilities(['core-posts-create-*'], capabilities.member?.add)
|
|
97
|
+
: removeCapabilities(['core-posts-create-*'], capabilities.member?.add),
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function setGroupWhoCanPostEvents(groupData, value) {
|
|
102
|
+
const capabilities = groupData.capabilities;
|
|
103
|
+
groupData.capabilities = {
|
|
104
|
+
...capabilities,
|
|
105
|
+
member: {
|
|
106
|
+
add: capabilities.member?.add,
|
|
107
|
+
remove: value === 'admin'
|
|
108
|
+
? addCapabilities(['core-posts-create-event'], capabilities.member?.remove)
|
|
109
|
+
: removeCapabilities(['core-posts-create-event'], capabilities.member?.remove),
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export function postsVisibilityOptionsForGroup(visibilityValue) {
|
|
114
|
+
if (visibilityValue === 'private')
|
|
115
|
+
return ['private'];
|
|
116
|
+
if (visibilityValue === 'local')
|
|
117
|
+
return ['local', 'private'];
|
|
118
|
+
return ['public', 'local', 'private'];
|
|
119
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { QueryClient } from '@tanstack/react-query';
|
|
2
|
+
import type { NotificationStats } from '@openpeepshq/common/types';
|
|
3
|
+
export declare const NOTIFICATION_STATS_QUERY_KEY: readonly ["profiles", "current", "notifications", "stats"];
|
|
4
|
+
export declare const syncAppBadgeCount: (unseen: number) => Promise<void>;
|
|
5
|
+
export declare const applyNotificationStatsToCache: (queryClient: QueryClient, stats: NotificationStats) => void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const NOTIFICATION_STATS_QUERY_KEY = [
|
|
2
|
+
'profiles',
|
|
3
|
+
'current',
|
|
4
|
+
'notifications',
|
|
5
|
+
'stats',
|
|
6
|
+
];
|
|
7
|
+
export const syncAppBadgeCount = async (unseen) => {
|
|
8
|
+
if (typeof navigator === 'undefined')
|
|
9
|
+
return;
|
|
10
|
+
try {
|
|
11
|
+
if (unseen <= 0 && navigator.clearAppBadge) {
|
|
12
|
+
await navigator.clearAppBadge();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (navigator.setAppBadge) {
|
|
16
|
+
await navigator.setAppBadge(unseen);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Badge API is best-effort.
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export const applyNotificationStatsToCache = (queryClient, stats) => {
|
|
24
|
+
queryClient.setQueryData(NOTIFICATION_STATS_QUERY_KEY, stats);
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isUnreadPostForViewer = (post, viewerId) => post.seen === false && !!viewerId && post.profile.id !== viewerId;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export type PostViewContext = {
|
|
3
|
+
groupId?: string | null;
|
|
4
|
+
conversationRootId?: string;
|
|
5
|
+
adjustUnread?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const usePostViewFlush: () => (() => Promise<void>);
|
|
8
|
+
export declare const useQueuePostView: () => ((postId: string, viewContext?: PostViewContext) => void);
|
|
9
|
+
export declare const PostViewCounterProvider: ({ markPostsSeen, hasAuthToken, onPostQueued, onFlushFailed, children, }: {
|
|
10
|
+
markPostsSeen: (postIds: string[]) => Promise<void>;
|
|
11
|
+
hasAuthToken: boolean;
|
|
12
|
+
onPostQueued?: (postId: string, viewContext?: PostViewContext) => void;
|
|
13
|
+
onFlushFailed?: () => void;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
/** Attach the returned ref to a post container to batch-mark it seen after 1s in view. */
|
|
17
|
+
export declare const usePostViewRef: (postId: string | undefined, viewContext?: PostViewContext) => import("react").RefObject<HTMLDivElement | null>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useRef, } from 'react';
|
|
3
|
+
import { useOptionalPathname } from '../contexts/router/index.js';
|
|
4
|
+
const VIEW_DELAY_MS = 1_000;
|
|
5
|
+
const FLUSH_DEBOUNCE_MS = 2_500;
|
|
6
|
+
const FLUSH_MAX_INTERVAL_MS = 10_000;
|
|
7
|
+
const FLUSH_THRESHOLD = 5;
|
|
8
|
+
const VISIBILITY_THRESHOLD = 0;
|
|
9
|
+
const PostViewCounterContext = createContext(undefined);
|
|
10
|
+
const PostViewFlushOnNavigate = ({ flush }) => {
|
|
11
|
+
const pathname = useOptionalPathname();
|
|
12
|
+
const previousPathname = useRef(pathname);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (previousPathname.current === pathname)
|
|
15
|
+
return;
|
|
16
|
+
previousPathname.current = pathname;
|
|
17
|
+
void flush();
|
|
18
|
+
}, [flush, pathname]);
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
export const usePostViewFlush = () => {
|
|
22
|
+
const context = useContext(PostViewCounterContext);
|
|
23
|
+
return context?.flush ?? (async () => undefined);
|
|
24
|
+
};
|
|
25
|
+
export const useQueuePostView = () => {
|
|
26
|
+
const context = useContext(PostViewCounterContext);
|
|
27
|
+
return context?.queuePostView ?? (() => undefined);
|
|
28
|
+
};
|
|
29
|
+
export const PostViewCounterProvider = ({ markPostsSeen, hasAuthToken, onPostQueued, onFlushFailed, children, }) => {
|
|
30
|
+
const pendingPostIds = useRef(new Set());
|
|
31
|
+
const flushing = useRef(false);
|
|
32
|
+
const flushDebounceTimer = useRef(undefined);
|
|
33
|
+
const markPostsSeenRef = useRef(markPostsSeen);
|
|
34
|
+
const onFlushFailedRef = useRef(onFlushFailed);
|
|
35
|
+
markPostsSeenRef.current = markPostsSeen;
|
|
36
|
+
onFlushFailedRef.current = onFlushFailed;
|
|
37
|
+
const flush = useCallback(async () => {
|
|
38
|
+
if (flushDebounceTimer.current) {
|
|
39
|
+
clearTimeout(flushDebounceTimer.current);
|
|
40
|
+
flushDebounceTimer.current = undefined;
|
|
41
|
+
}
|
|
42
|
+
if (flushing.current || pendingPostIds.current.size === 0 || !hasAuthToken) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const postIds = [...pendingPostIds.current];
|
|
46
|
+
pendingPostIds.current.clear();
|
|
47
|
+
flushing.current = true;
|
|
48
|
+
try {
|
|
49
|
+
await markPostsSeenRef.current(postIds);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
postIds.forEach((postId) => pendingPostIds.current.add(postId));
|
|
53
|
+
onFlushFailedRef.current?.();
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
flushing.current = false;
|
|
57
|
+
}
|
|
58
|
+
}, [hasAuthToken]);
|
|
59
|
+
const scheduleFlush = useCallback(() => {
|
|
60
|
+
if (!hasAuthToken)
|
|
61
|
+
return;
|
|
62
|
+
if (pendingPostIds.current.size >= FLUSH_THRESHOLD) {
|
|
63
|
+
void flush();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (flushDebounceTimer.current) {
|
|
67
|
+
clearTimeout(flushDebounceTimer.current);
|
|
68
|
+
}
|
|
69
|
+
flushDebounceTimer.current = setTimeout(() => {
|
|
70
|
+
flushDebounceTimer.current = undefined;
|
|
71
|
+
void flush();
|
|
72
|
+
}, FLUSH_DEBOUNCE_MS);
|
|
73
|
+
}, [flush, hasAuthToken]);
|
|
74
|
+
const queuePostView = useCallback((postId, viewContext) => {
|
|
75
|
+
if (!postId || !hasAuthToken)
|
|
76
|
+
return;
|
|
77
|
+
pendingPostIds.current.add(postId);
|
|
78
|
+
if (viewContext?.adjustUnread) {
|
|
79
|
+
onPostQueued?.(postId, viewContext);
|
|
80
|
+
}
|
|
81
|
+
scheduleFlush();
|
|
82
|
+
}, [hasAuthToken, onPostQueued, scheduleFlush]);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!hasAuthToken)
|
|
85
|
+
return;
|
|
86
|
+
const interval = setInterval(() => {
|
|
87
|
+
void flush();
|
|
88
|
+
}, FLUSH_MAX_INTERVAL_MS);
|
|
89
|
+
const hasWindow = typeof window !== 'undefined' &&
|
|
90
|
+
typeof document !== 'undefined' &&
|
|
91
|
+
typeof window.addEventListener === 'function';
|
|
92
|
+
const flushOnPageHide = () => void flush();
|
|
93
|
+
const flushOnVisibilityHidden = () => {
|
|
94
|
+
if (document.visibilityState === 'hidden')
|
|
95
|
+
void flush();
|
|
96
|
+
};
|
|
97
|
+
if (hasWindow) {
|
|
98
|
+
window.addEventListener('pagehide', flushOnPageHide);
|
|
99
|
+
document.addEventListener('visibilitychange', flushOnVisibilityHidden);
|
|
100
|
+
}
|
|
101
|
+
return () => {
|
|
102
|
+
clearInterval(interval);
|
|
103
|
+
if (flushDebounceTimer.current) {
|
|
104
|
+
clearTimeout(flushDebounceTimer.current);
|
|
105
|
+
}
|
|
106
|
+
if (hasWindow) {
|
|
107
|
+
window.removeEventListener('pagehide', flushOnPageHide);
|
|
108
|
+
document.removeEventListener('visibilitychange', flushOnVisibilityHidden);
|
|
109
|
+
}
|
|
110
|
+
void flush();
|
|
111
|
+
};
|
|
112
|
+
}, [flush, hasAuthToken]);
|
|
113
|
+
return (_jsxs(PostViewCounterContext.Provider, { value: { queuePostView, flush }, children: [_jsx(PostViewFlushOnNavigate, { flush: flush }), children] }));
|
|
114
|
+
};
|
|
115
|
+
/** Attach the returned ref to a post container to batch-mark it seen after 1s in view. */
|
|
116
|
+
export const usePostViewRef = (postId, viewContext) => {
|
|
117
|
+
const context = useContext(PostViewCounterContext);
|
|
118
|
+
const ref = useRef(null);
|
|
119
|
+
const viewContextRef = useRef(viewContext);
|
|
120
|
+
viewContextRef.current = viewContext;
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
const node = ref.current;
|
|
123
|
+
if (!node ||
|
|
124
|
+
!postId ||
|
|
125
|
+
!context ||
|
|
126
|
+
typeof window === 'undefined' ||
|
|
127
|
+
!('IntersectionObserver' in window)) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
let viewTimer;
|
|
131
|
+
let counted = false;
|
|
132
|
+
const clearViewTimer = () => {
|
|
133
|
+
if (viewTimer) {
|
|
134
|
+
clearTimeout(viewTimer);
|
|
135
|
+
viewTimer = undefined;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const startViewTimer = () => {
|
|
139
|
+
if (counted || viewTimer)
|
|
140
|
+
return;
|
|
141
|
+
viewTimer = setTimeout(() => {
|
|
142
|
+
counted = true;
|
|
143
|
+
context.queuePostView(postId, viewContextRef.current);
|
|
144
|
+
viewTimer = undefined;
|
|
145
|
+
}, VIEW_DELAY_MS);
|
|
146
|
+
};
|
|
147
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
148
|
+
const visible = !!entry?.isIntersecting &&
|
|
149
|
+
entry.intersectionRatio > VISIBILITY_THRESHOLD;
|
|
150
|
+
if (visible)
|
|
151
|
+
startViewTimer();
|
|
152
|
+
else
|
|
153
|
+
clearViewTimer();
|
|
154
|
+
}, { threshold: VISIBILITY_THRESHOLD });
|
|
155
|
+
observer.observe(node);
|
|
156
|
+
return () => {
|
|
157
|
+
clearViewTimer();
|
|
158
|
+
observer.disconnect();
|
|
159
|
+
};
|
|
160
|
+
}, [context, postId]);
|
|
161
|
+
return ref;
|
|
162
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type PublicPost, type Thread } from '@openpeepshq/common';
|
|
2
|
+
export declare const lastLongestPathSelector: (thread: Thread) => Thread & {
|
|
3
|
+
depth: number;
|
|
4
|
+
};
|
|
5
|
+
export declare const collectPath: (thread: Thread | undefined, currentPath?: PublicPost[]) => PublicPost[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { dateSorter } from '@openpeepshq/common';
|
|
2
|
+
export const lastLongestPathSelector = (thread) => {
|
|
3
|
+
const candidates = thread.children.map((t) => lastLongestPathSelector(t));
|
|
4
|
+
const maxDepth = Math.max(0, ...candidates.map((c) => c.depth));
|
|
5
|
+
const selectedChild = candidates
|
|
6
|
+
.filter((c) => c.depth === maxDepth)
|
|
7
|
+
.sort(dateSorter())
|
|
8
|
+
.reverse()[0];
|
|
9
|
+
return {
|
|
10
|
+
...thread,
|
|
11
|
+
children: selectedChild ? [selectedChild] : [],
|
|
12
|
+
depth: maxDepth + 1,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export const collectPath = (thread, currentPath = []) => {
|
|
16
|
+
if (!thread)
|
|
17
|
+
return currentPath;
|
|
18
|
+
return [
|
|
19
|
+
...currentPath,
|
|
20
|
+
thread,
|
|
21
|
+
...collectPath(thread.children[0]),
|
|
22
|
+
];
|
|
23
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { openpeepsClient } from '@openpeepshq/client';
|
|
2
|
+
import type { UnseenPostCounts } from '@openpeepshq/common/types';
|
|
3
|
+
import type { QueryClient, QueryKey } from '@tanstack/react-query';
|
|
4
|
+
export type UnseenCountsAdjustment = {
|
|
5
|
+
groupId?: string;
|
|
6
|
+
conversationRootId?: string;
|
|
7
|
+
clearGroup?: string;
|
|
8
|
+
clearConversation?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const applyUnseenCountsAdjustment: (current: UnseenPostCounts | undefined, adjustment: UnseenCountsAdjustment) => UnseenPostCounts;
|
|
11
|
+
export declare const unseenCountsQueryKey: (client: ReturnType<typeof openpeepsClient>) => QueryKey;
|
|
12
|
+
export declare const isUnseenCountsQueryKey: (queryKey: readonly unknown[]) => boolean;
|
|
13
|
+
export declare const adjustUnseenCounts: (queryClient: QueryClient, client: ReturnType<typeof openpeepsClient>, adjustment: UnseenCountsAdjustment) => void;
|
|
14
|
+
export declare const invalidateUnseenCounts: (queryClient: QueryClient, client: ReturnType<typeof openpeepsClient>) => Promise<void>;
|
|
15
|
+
export declare const invalidatePostsExceptUnseenCounts: (queryClient: QueryClient) => Promise<void>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const applyUnseenCountsAdjustment = (current, adjustment) => {
|
|
2
|
+
const groups = { ...(current?.groups ?? {}) };
|
|
3
|
+
const direct = { ...(current?.direct ?? {}) };
|
|
4
|
+
if (adjustment.clearGroup) {
|
|
5
|
+
groups[adjustment.clearGroup] = 0;
|
|
6
|
+
}
|
|
7
|
+
else if (adjustment.groupId) {
|
|
8
|
+
const previous = groups[adjustment.groupId] ?? 0;
|
|
9
|
+
groups[adjustment.groupId] = Math.max(0, previous - 1);
|
|
10
|
+
}
|
|
11
|
+
if (adjustment.clearConversation) {
|
|
12
|
+
delete direct[adjustment.clearConversation];
|
|
13
|
+
}
|
|
14
|
+
else if (adjustment.conversationRootId) {
|
|
15
|
+
const previous = direct[adjustment.conversationRootId] ?? 0;
|
|
16
|
+
const next = Math.max(0, previous - 1);
|
|
17
|
+
if (next === 0) {
|
|
18
|
+
delete direct[adjustment.conversationRootId];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
direct[adjustment.conversationRootId] = next;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return { groups, direct };
|
|
25
|
+
};
|
|
26
|
+
export const unseenCountsQueryKey = (client) => client.posts.unseenCounts.queryKey({});
|
|
27
|
+
export const isUnseenCountsQueryKey = (queryKey) => queryKey[0] === 'posts' &&
|
|
28
|
+
queryKey[1] === 'unseen' &&
|
|
29
|
+
queryKey[2] === 'counts';
|
|
30
|
+
export const adjustUnseenCounts = (queryClient, client, adjustment) => {
|
|
31
|
+
queryClient.setQueryData(unseenCountsQueryKey(client), (current) => applyUnseenCountsAdjustment(current, adjustment));
|
|
32
|
+
};
|
|
33
|
+
export const invalidateUnseenCounts = async (queryClient, client) => {
|
|
34
|
+
await queryClient.invalidateQueries({
|
|
35
|
+
queryKey: unseenCountsQueryKey(client),
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
export const invalidatePostsExceptUnseenCounts = async (queryClient) => {
|
|
39
|
+
await queryClient.invalidateQueries({
|
|
40
|
+
queryKey: ['posts'],
|
|
41
|
+
predicate: (query) => !isUnseenCountsQueryKey(query.queryKey),
|
|
42
|
+
});
|
|
43
|
+
};
|