Linting and formatting.

pull/2000/head
warrickct 4 years ago
parent 23ca19b125
commit 2144a3980f

@ -181,11 +181,6 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
); );
} }
private handleMessageRequestsClick() {
console.warn('handle msg req clicked');
this.handleToggleOverlay(SessionClosableOverlayType.MessageRequests);
}
public updateSearch(searchTerm: string) { public updateSearch(searchTerm: string) {
if (!searchTerm) { if (!searchTerm) {
window.inboxStore?.dispatch(clearSearch()); window.inboxStore?.dispatch(clearSearch());
@ -224,6 +219,10 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
); );
} }
private handleMessageRequestsClick() {
this.handleToggleOverlay(SessionClosableOverlayType.MessageRequests);
}
private renderClosableOverlay() { private renderClosableOverlay() {
const { searchTerm, searchResults } = this.props; const { searchTerm, searchResults } = this.props;
const { loading, overlay } = this.state; const { loading, overlay } = this.state;
@ -282,9 +281,8 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
this.handleToggleOverlay(undefined); this.handleToggleOverlay(undefined);
}} }}
onButtonClick={async () => { onButtonClick={async () => {
// block all convo requests. Force sync if there were changes.
window?.log?.info('Blocking all conversations'); window?.log?.info('Blocking all conversations');
// TODO: msgrequest iterate all convos and block
// iterate all conversations and set all to approve then
const { conversationRequests } = this.props; const { conversationRequests } = this.props;
let syncRequired = false; let syncRequired = false;
@ -293,9 +291,9 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
return; return;
} }
_.forEach(conversationRequests, convo => { _.forEach(conversationRequests, async convo => {
if (convo.isApproved !== true) { if (convo.isApproved !== true) {
BlockedNumberController.block(convo.id); await BlockedNumberController.block(convo.id);
syncRequired = true; syncRequired = true;
} }
}); });

@ -199,7 +199,6 @@ export class SessionClosableOverlay extends React.Component<Props, State> {
{isMessageRequestView ? ( {isMessageRequestView ? (
<> <>
<SpacerLG /> <SpacerLG />
<div className="message-request-list__container"></div>
<MessageRequestList /> <MessageRequestList />
<SpacerLG /> <SpacerLG />
</> </>
@ -301,7 +300,7 @@ const MessageRequestList = () => {
return ( return (
<div className="message-request-list__container"> <div className="message-request-list__container">
{validConversationRequests.map(conversation => { {validConversationRequests.map(conversation => {
return <MessageRequestListItem conversation={conversation} />; return <MessageRequestListItem key={conversation.id} conversation={conversation} />;
})} })}
</div> </div>
); );
@ -309,10 +308,5 @@ const MessageRequestList = () => {
const MessageRequestListItem = (props: { conversation: ConversationListItemProps }) => { const MessageRequestListItem = (props: { conversation: ConversationListItemProps }) => {
const { conversation } = props; const { conversation } = props;
return ( return <MemoConversationListItemWithDetails isMessageRequest={true} {...conversation} />;
<MemoConversationListItemWithDetails
isMessageRequest={true}
{...conversation}
></MemoConversationListItemWithDetails>
);
}; };

@ -50,7 +50,7 @@ import { getDecryptedMediaUrl } from '../session/crypto/DecryptedAttachmentsMana
import { IMAGE_JPEG } from '../types/MIME'; import { IMAGE_JPEG } from '../types/MIME';
import { UnsendMessage } from '../session/messages/outgoing/controlMessage/UnsendMessage'; import { UnsendMessage } from '../session/messages/outgoing/controlMessage/UnsendMessage';
import { getLatestTimestampOffset, networkDeleteMessages } from '../session/snode_api/SNodeAPI'; import { getLatestTimestampOffset, networkDeleteMessages } from '../session/snode_api/SNodeAPI';
import { syncConfigurationIfNeeded } from '../session/utils/syncUtils'; import { forceSyncConfigurationNowIfNeeded } from '../session/utils/syncUtils';
export enum ConversationTypeEnum { export enum ConversationTypeEnum {
GROUP = 'group', GROUP = 'group',
@ -738,8 +738,8 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
const updateApprovalNeeded = const updateApprovalNeeded =
!this.isApproved() && (this.isPrivate() || this.isMediumGroup() || this.isClosedGroup()); !this.isApproved() && (this.isPrivate() || this.isMediumGroup() || this.isClosedGroup());
if (updateApprovalNeeded) { if (updateApprovalNeeded) {
this.setIsApproved(true); await this.setIsApproved(true);
await syncConfigurationIfNeeded(true); await forceSyncConfigurationNowIfNeeded();
} }
if (this.isOpenGroupV2()) { if (this.isOpenGroupV2()) {
@ -1397,13 +1397,15 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
public async setIsApproved(value: boolean) { public async setIsApproved(value: boolean) {
if (value !== this.get('isApproved')) { if (value !== this.get('isApproved')) {
console.warn(`Setting ${this.attributes.profileName} isApproved to:: ${value}`); window?.log?.info(`Setting ${this.attributes.profileName} isApproved to:: ${value}`);
this.set({ this.set({
isApproved: value, isApproved: value,
}); });
// to exclude the conversation from left pane messages list and message requests // to exclude the conversation from left pane messages list and message requests
if (value === false) this.set({ active_at: undefined }); if (value === false) {
this.set({ active_at: undefined });
}
await this.commit(); await this.commit();
} }

@ -130,7 +130,7 @@ const handleContactReceived = async (
window.inboxStore?.getState().userConfig.messageRequests && window.inboxStore?.getState().userConfig.messageRequests &&
contactReceived.isApproved === true contactReceived.isApproved === true
) { ) {
contactConvo.setIsApproved(Boolean(contactReceived.isApproved)); await contactConvo.setIsApproved(Boolean(contactReceived.isApproved));
if (contactReceived.isBlocked === true) { if (contactReceived.isBlocked === true) {
await BlockedNumberController.block(contactConvo.id); await BlockedNumberController.block(contactConvo.id);

@ -314,8 +314,8 @@ async function handleRegularMessage(
if (type === 'outgoing' && window.lokiFeatureFlags.useMessageRequests) { if (type === 'outgoing' && window.lokiFeatureFlags.useMessageRequests) {
handleSyncedReceipts(message, conversation); handleSyncedReceipts(message, conversation);
// assumes sync receipts are always from linked device outgoings? // assumes sync receipts are always from linked device outgoings
conversation.setIsApproved(true); await conversation.setIsApproved(true);
} }
const conversationActiveAt = conversation.get('active_at'); const conversationActiveAt = conversation.get('active_at');

@ -38,23 +38,20 @@ const writeLastSyncTimestampToDb = async (timestamp: number) =>
createOrUpdateItem({ id: ITEM_ID_LAST_SYNC_TIMESTAMP, value: timestamp }); createOrUpdateItem({ id: ITEM_ID_LAST_SYNC_TIMESTAMP, value: timestamp });
/** /**
* Syncs usre configuration with other devices linked to this user. * Conditionally Syncs user configuration with other devices linked.
* @param force Bypass duration time limit for sending sync messages
* @returns
*/ */
export const syncConfigurationIfNeeded = async (force: boolean = false) => { export const syncConfigurationIfNeeded = async () => {
const lastSyncedTimestamp = (await getLastSyncTimestampFromDb()) || 0; const lastSyncedTimestamp = (await getLastSyncTimestampFromDb()) || 0;
const now = Date.now(); const now = Date.now();
// if the last sync was less than 2 days before, return early. // if the last sync was less than 2 days before, return early.
if (!force && Math.abs(now - lastSyncedTimestamp) < DURATION.DAYS * 7) { if (Math.abs(now - lastSyncedTimestamp) < DURATION.DAYS * 7) {
return; return;
} }
const allConvos = await (await getAllConversations()).models; const allConvoCollection = await getAllConversations();
const allConvos = allConvoCollection.models;
console.warn({ test: allConvos[0].attributes.isApproved });
// const configMessage = await getCurrentConfigurationMessage(allConvos);
const configMessage = await getCurrentConfigurationMessage(allConvos); const configMessage = await getCurrentConfigurationMessage(allConvos);
try { try {
// window?.log?.info('syncConfigurationIfNeeded with', configMessage); // window?.log?.info('syncConfigurationIfNeeded with', configMessage);
@ -71,7 +68,6 @@ export const syncConfigurationIfNeeded = async (force: boolean = false) => {
export const forceSyncConfigurationNowIfNeeded = async (waitForMessageSent = false) => export const forceSyncConfigurationNowIfNeeded = async (waitForMessageSent = false) =>
new Promise(async resolve => { new Promise(async resolve => {
// const allConvos = getConversationController().getConversations();
const allConvos = (await getAllConversations()).models; const allConvos = (await getAllConversations()).models;
// if we hang for more than 10sec, force resolve this promise. // if we hang for more than 10sec, force resolve this promise.

Loading…
Cancel
Save