Lets users send stories to groups
This commit is contained in:
parent
d4b74db05c
commit
ccc89545c5
21 changed files with 1177 additions and 400 deletions
|
@ -195,6 +195,7 @@ export type ConversationType = {
|
|||
groupVersion?: 1 | 2;
|
||||
groupId?: string;
|
||||
groupLink?: string;
|
||||
isGroupStorySendReady?: boolean;
|
||||
messageRequestsEnabled?: boolean;
|
||||
acceptedMessageRequest: boolean;
|
||||
secretParams?: string;
|
||||
|
@ -852,6 +853,7 @@ export const actions = {
|
|||
showConversation,
|
||||
startComposing,
|
||||
startSettingGroupMetadata,
|
||||
tagGroupsAsNewGroupStory,
|
||||
toggleAdmin,
|
||||
toggleConversationInChooseMembers,
|
||||
toggleComposeEditingAvatar,
|
||||
|
@ -1953,6 +1955,29 @@ function removeMemberFromGroup(
|
|||
};
|
||||
}
|
||||
|
||||
function tagGroupsAsNewGroupStory(
|
||||
conversationIds: Array<string>
|
||||
): ThunkAction<void, RootStateType, unknown, NoopActionType> {
|
||||
return async dispatch => {
|
||||
await Promise.all(
|
||||
conversationIds.map(async conversationId => {
|
||||
const conversation = window.ConversationController.get(conversationId);
|
||||
if (!conversation) {
|
||||
return;
|
||||
}
|
||||
|
||||
conversation.set({ isGroupStorySendReady: true });
|
||||
await window.Signal.Data.updateConversation(conversation.attributes);
|
||||
})
|
||||
);
|
||||
|
||||
dispatch({
|
||||
type: 'NOOP',
|
||||
payload: null,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function toggleAdmin(
|
||||
conversationId: string,
|
||||
contactId: string
|
||||
|
|
|
@ -517,6 +517,20 @@ export const getComposableGroups = createSelector(
|
|||
)
|
||||
);
|
||||
|
||||
export const getNonGroupStories = createSelector(
|
||||
getComposableGroups,
|
||||
(groups: Array<ConversationType>): Array<ConversationType> =>
|
||||
groups.filter(group => !group.isGroupStorySendReady)
|
||||
);
|
||||
|
||||
export const getGroupStories = createSelector(
|
||||
getConversationLookup,
|
||||
(conversationLookup: ConversationLookupType): Array<ConversationType> =>
|
||||
Object.values(conversationLookup).filter(
|
||||
conversation => conversation.isGroupStorySendReady
|
||||
)
|
||||
);
|
||||
|
||||
const getNormalizedComposerConversationSearchTerm = createSelector(
|
||||
getComposerConversationSearchTerm,
|
||||
(searchTerm: string): string => searchTerm.trim()
|
||||
|
|
|
@ -7,13 +7,14 @@ import type { StateType } from '../reducer';
|
|||
import type { StoryDistributionListDataType } from '../ducks/storyDistributionLists';
|
||||
import type { StoryDistributionListWithMembersDataType } from '../../types/Stories';
|
||||
import { getConversationSelector } from './conversations';
|
||||
import { MY_STORIES_ID } from '../../types/Stories';
|
||||
|
||||
export const getDistributionLists = (
|
||||
state: StateType
|
||||
): Array<StoryDistributionListDataType> =>
|
||||
state.storyDistributionLists.distributionLists.filter(
|
||||
list => !list.deletedAtTimestamp
|
||||
);
|
||||
state.storyDistributionLists.distributionLists
|
||||
.filter(list => !list.deletedAtTimestamp)
|
||||
.sort(list => (list.id === MY_STORIES_ID ? -1 : 1));
|
||||
|
||||
export const getDistributionListSelector = createSelector(
|
||||
getDistributionLists,
|
||||
|
|
|
@ -8,7 +8,13 @@ import type { LocalizerType } from '../../types/Util';
|
|||
import type { StateType } from '../reducer';
|
||||
import { LinkPreviewSourceType } from '../../types/LinkPreview';
|
||||
import { StoryCreator } from '../../components/StoryCreator';
|
||||
import { getAllSignalConnections, getMe } from '../selectors/conversations';
|
||||
import {
|
||||
getAllSignalConnections,
|
||||
getCandidateContactsForNewGroup,
|
||||
getGroupStories,
|
||||
getMe,
|
||||
getNonGroupStories,
|
||||
} from '../selectors/conversations';
|
||||
import { getDistributionLists } from '../selectors/storyDistributionLists';
|
||||
import { getIntl } from '../selectors/user';
|
||||
import {
|
||||
|
@ -16,9 +22,12 @@ import {
|
|||
getRecentStickers,
|
||||
} from '../selectors/stickers';
|
||||
import { getLinkPreview } from '../selectors/linkPreviews';
|
||||
import { getPreferredBadgeSelector } from '../selectors/badges';
|
||||
import { processAttachment } from '../../util/processAttachment';
|
||||
import { useConversationsActions } from '../ducks/conversations';
|
||||
import { useLinkPreviewActions } from '../ducks/linkPreviews';
|
||||
import { useStoriesActions } from '../ducks/stories';
|
||||
import { useStoryDistributionListsActions } from '../ducks/storyDistributionLists';
|
||||
|
||||
export type PropsType = {
|
||||
file?: File;
|
||||
|
@ -31,9 +40,15 @@ export function SmartStoryCreator({
|
|||
}: PropsType): JSX.Element | null {
|
||||
const { debouncedMaybeGrabLinkPreview } = useLinkPreviewActions();
|
||||
const { sendStoryMessage } = useStoriesActions();
|
||||
const { tagGroupsAsNewGroupStory } = useConversationsActions();
|
||||
const { createDistributionList } = useStoryDistributionListsActions();
|
||||
|
||||
const i18n = useSelector<StateType, LocalizerType>(getIntl);
|
||||
const candidateConversations = useSelector(getCandidateContactsForNewGroup);
|
||||
const distributionLists = useSelector(getDistributionLists);
|
||||
const getPreferredBadge = useSelector(getPreferredBadgeSelector);
|
||||
const groupConversations = useSelector(getNonGroupStories);
|
||||
const groupStories = useSelector(getGroupStories);
|
||||
const i18n = useSelector<StateType, LocalizerType>(getIntl);
|
||||
const installedPacks = useSelector(getInstalledStickerPacks);
|
||||
const linkPreviewForSource = useSelector(getLinkPreview);
|
||||
const me = useSelector(getMe);
|
||||
|
@ -42,18 +57,24 @@ export function SmartStoryCreator({
|
|||
|
||||
return (
|
||||
<StoryCreator
|
||||
candidateConversations={candidateConversations}
|
||||
debouncedMaybeGrabLinkPreview={debouncedMaybeGrabLinkPreview}
|
||||
distributionLists={distributionLists}
|
||||
file={file}
|
||||
getPreferredBadge={getPreferredBadge}
|
||||
groupConversations={groupConversations}
|
||||
groupStories={groupStories}
|
||||
i18n={i18n}
|
||||
installedPacks={installedPacks}
|
||||
file={file}
|
||||
linkPreview={linkPreviewForSource(LinkPreviewSourceType.StoryCreator)}
|
||||
me={me}
|
||||
onClose={onClose}
|
||||
onDistributionListCreated={createDistributionList}
|
||||
onSend={sendStoryMessage}
|
||||
processAttachment={processAttachment}
|
||||
recentStickers={recentStickers}
|
||||
signalConnections={signalConnections}
|
||||
tagGroupsAsNewGroupStory={tagGroupsAsNewGroupStory}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue