Enable click on draft quotes, fetch groups from contact modal
This commit is contained in:
@@ -36,6 +36,7 @@ const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
|
||||
removeMember: action('removeMember'),
|
||||
showSafetyNumber: action('showSafetyNumber'),
|
||||
toggleAdmin: action('toggleAdmin'),
|
||||
updateSharedGroups: action('updateSharedGroups'),
|
||||
});
|
||||
|
||||
story.add('As non-admin', () => {
|
||||
|
@@ -21,6 +21,7 @@ export type PropsType = {
|
||||
removeMember: (conversationId: string) => void;
|
||||
showSafetyNumber: (conversationId: string) => void;
|
||||
toggleAdmin: (conversationId: string) => void;
|
||||
updateSharedGroups: () => void;
|
||||
};
|
||||
|
||||
export const ContactModal = ({
|
||||
@@ -34,6 +35,7 @@ export const ContactModal = ({
|
||||
removeMember,
|
||||
showSafetyNumber,
|
||||
toggleAdmin,
|
||||
updateSharedGroups,
|
||||
}: PropsType): ReactPortal | null => {
|
||||
if (!contact) {
|
||||
throw new Error('Contact modal opened without a matching contact');
|
||||
@@ -54,6 +56,11 @@ export const ContactModal = ({
|
||||
};
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
// Kick off the expensive hydration of the current sharedGroupNames
|
||||
updateSharedGroups();
|
||||
}, [updateSharedGroups]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (root !== null && closeButtonRef.current) {
|
||||
closeButtonRef.current.focus();
|
||||
|
@@ -156,6 +156,8 @@ export class ConversationModel extends window.Backbone
|
||||
|
||||
lastSuccessfulGroupFetch?: number;
|
||||
|
||||
throttledUpdateSharedGroups?: () => Promise<void>;
|
||||
|
||||
private cachedLatestGroupCallEraId?: string;
|
||||
|
||||
private cachedIdenticon?: CachedIdenticon;
|
||||
@@ -229,6 +231,9 @@ export class ConversationModel extends window.Backbone
|
||||
this.updateLastMessage.bind(this),
|
||||
200
|
||||
);
|
||||
this.throttledUpdateSharedGroups =
|
||||
this.throttledUpdateSharedGroups ||
|
||||
window._.throttle(this.updateSharedGroups.bind(this), FIVE_MINUTES);
|
||||
|
||||
this.contactCollection = this.getContactCollection();
|
||||
this.contactCollection.on(
|
||||
|
@@ -20,6 +20,7 @@ export type SmartContactModalProps = {
|
||||
readonly removeMember: (conversationId: string) => void;
|
||||
readonly showSafetyNumber: (conversationId: string) => void;
|
||||
readonly toggleAdmin: (conversationId: string) => void;
|
||||
readonly updateSharedGroups: () => void;
|
||||
};
|
||||
|
||||
const mapStateToProps = (
|
||||
|
@@ -386,12 +386,6 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||
this.model.throttledGetProfiles =
|
||||
this.model.throttledGetProfiles ||
|
||||
window._.throttle(this.model.getProfiles.bind(this.model), FIVE_MINUTES);
|
||||
this.model.throttledUpdateSharedGroups =
|
||||
this.model.throttledUpdateSharedGroups ||
|
||||
window._.throttle(
|
||||
this.model.updateSharedGroups.bind(this.model),
|
||||
FIVE_MINUTES
|
||||
);
|
||||
this.model.throttledMaybeMigrateV1Group =
|
||||
this.model.throttledMaybeMigrateV1Group ||
|
||||
window._.throttle(
|
||||
@@ -3052,6 +3046,12 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||
resolve: () => this.model.toggleAdmin(conversationId),
|
||||
});
|
||||
},
|
||||
updateSharedGroups: () => {
|
||||
const conversation = window.ConversationController.get(contactId);
|
||||
if (conversation && conversation.throttledUpdateSharedGroups) {
|
||||
conversation.throttledUpdateSharedGroups();
|
||||
}
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -3625,10 +3625,6 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||
|
||||
const props = message.getPropsForQuote();
|
||||
|
||||
this.listenTo(message, 'scroll-to-message', () => {
|
||||
this.scrollToMessage(message.quotedMessage.id);
|
||||
});
|
||||
|
||||
const contact = this.quotedMessage.getContact();
|
||||
if (contact) {
|
||||
this.listenTo(contact, 'change', this.renderQuotedMessage);
|
||||
@@ -3642,6 +3638,7 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||
props: {
|
||||
...props,
|
||||
withContentAbove: true,
|
||||
onClick: () => this.scrollToMessage(message.quotedMessage.id),
|
||||
onClose: () => {
|
||||
// This can't be the normal 'onClose' because that is always run when this
|
||||
// view is removed from the DOM, and would clear the draft quote.
|
||||
|
Reference in New Issue
Block a user