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