Linting and formatting.

This commit is contained in:
warrickct 2021-11-22 16:48:30 +11:00
parent 23ca19b125
commit 2144a3980f
6 changed files with 24 additions and 34 deletions

View file

@ -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) {
if (!searchTerm) {
window.inboxStore?.dispatch(clearSearch());
@ -224,6 +219,10 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
);
}
private handleMessageRequestsClick() {
this.handleToggleOverlay(SessionClosableOverlayType.MessageRequests);
}
private renderClosableOverlay() {
const { searchTerm, searchResults } = this.props;
const { loading, overlay } = this.state;
@ -282,9 +281,8 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
this.handleToggleOverlay(undefined);
}}
onButtonClick={async () => {
// block all convo requests. Force sync if there were changes.
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;
let syncRequired = false;
@ -293,9 +291,9 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
return;
}
_.forEach(conversationRequests, convo => {
_.forEach(conversationRequests, async convo => {
if (convo.isApproved !== true) {
BlockedNumberController.block(convo.id);
await BlockedNumberController.block(convo.id);
syncRequired = true;
}
});

View file

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

View file

@ -50,7 +50,7 @@ import { getDecryptedMediaUrl } from '../session/crypto/DecryptedAttachmentsMana
import { IMAGE_JPEG } from '../types/MIME';
import { UnsendMessage } from '../session/messages/outgoing/controlMessage/UnsendMessage';
import { getLatestTimestampOffset, networkDeleteMessages } from '../session/snode_api/SNodeAPI';
import { syncConfigurationIfNeeded } from '../session/utils/syncUtils';
import { forceSyncConfigurationNowIfNeeded } from '../session/utils/syncUtils';
export enum ConversationTypeEnum {
GROUP = 'group',
@ -738,8 +738,8 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
const updateApprovalNeeded =
!this.isApproved() && (this.isPrivate() || this.isMediumGroup() || this.isClosedGroup());
if (updateApprovalNeeded) {
this.setIsApproved(true);
await syncConfigurationIfNeeded(true);
await this.setIsApproved(true);
await forceSyncConfigurationNowIfNeeded();
}
if (this.isOpenGroupV2()) {
@ -1397,13 +1397,15 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
public async setIsApproved(value: boolean) {
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({
isApproved: value,
});
// 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();
}

View file

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

View file

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

View file

@ -38,23 +38,20 @@ const writeLastSyncTimestampToDb = async (timestamp: number) =>
createOrUpdateItem({ id: ITEM_ID_LAST_SYNC_TIMESTAMP, value: timestamp });
/**
* Syncs usre configuration with other devices linked to this user.
* @param force Bypass duration time limit for sending sync messages
* @returns
* Conditionally Syncs user configuration with other devices linked.
*/
export const syncConfigurationIfNeeded = async (force: boolean = false) => {
export const syncConfigurationIfNeeded = async () => {
const lastSyncedTimestamp = (await getLastSyncTimestampFromDb()) || 0;
const now = Date.now();
// 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;
}
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);
try {
// window?.log?.info('syncConfigurationIfNeeded with', configMessage);
@ -71,7 +68,6 @@ export const syncConfigurationIfNeeded = async (force: boolean = false) => {
export const forceSyncConfigurationNowIfNeeded = async (waitForMessageSent = false) =>
new Promise(async resolve => {
// const allConvos = getConversationController().getConversations();
const allConvos = (await getAllConversations()).models;
// if we hang for more than 10sec, force resolve this promise.