use variables for common settings key
also turn off typing message by default
This commit is contained in:
parent
1424e13a68
commit
dd52ad336f
|
@ -8,7 +8,6 @@ const MESSAGE_COUNT_KEY = 'sqlMigration_messageCount';
|
|||
const UNPROCESSED_LAST_INDEX_KEY = 'sqlMigration_unprocessedLastIndex';
|
||||
|
||||
// Public API
|
||||
exports.READ_RECEIPT_CONFIGURATION_SYNC = 'read-receipt-configuration-sync';
|
||||
|
||||
exports.getAttachmentMigrationLastProcessedIndex = connection =>
|
||||
exports._getItem(connection, LAST_PROCESSED_INDEX_KEY);
|
||||
|
|
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||
import { useDispatch, useSelector } from 'react-redux';
|
||||
// tslint:disable-next-line: no-submodule-imports
|
||||
import useUpdate from 'react-use/lib/useUpdate';
|
||||
import { SettingsKey } from '../../../data/settings-key';
|
||||
import { CallManager } from '../../../session/utils';
|
||||
import { sessionPassword, updateConfirmModal } from '../../../state/ducks/modalDialog';
|
||||
import { toggleMessageRequests } from '../../../state/ducks/userConfig';
|
||||
|
@ -11,10 +12,6 @@ import { PasswordAction } from '../../dialog/SessionPasswordDialog';
|
|||
|
||||
import { SessionSettingButtonItem, SessionToggleWithDescription } from '../SessionSettingListItem';
|
||||
|
||||
const settingsReadReceipt = 'read-receipt-setting';
|
||||
const settingsTypingIndicator = 'typing-indicators-setting';
|
||||
const settingsAutoUpdate = 'auto-update';
|
||||
|
||||
const toggleCallMediaPermissions = async (triggerUIUpdate: () => void) => {
|
||||
const currentValue = window.getCallMediaPermissions();
|
||||
if (!currentValue) {
|
||||
|
@ -87,33 +84,33 @@ export const SettingsCategoryPrivacy = (props: {
|
|||
)}
|
||||
<SessionToggleWithDescription
|
||||
onClickToggle={() => {
|
||||
const old = Boolean(window.getSettingValue(settingsReadReceipt));
|
||||
window.setSettingValue(settingsReadReceipt, !old);
|
||||
const old = Boolean(window.getSettingValue(SettingsKey.settingsReadReceipt));
|
||||
window.setSettingValue(SettingsKey.settingsReadReceipt, !old);
|
||||
forceUpdate();
|
||||
}}
|
||||
title={window.i18n('readReceiptSettingTitle')}
|
||||
description={window.i18n('readReceiptSettingDescription')}
|
||||
active={window.getSettingValue(settingsReadReceipt)}
|
||||
active={window.getSettingValue(SettingsKey.settingsReadReceipt)}
|
||||
/>
|
||||
<SessionToggleWithDescription
|
||||
onClickToggle={() => {
|
||||
const old = Boolean(window.getSettingValue(settingsTypingIndicator));
|
||||
window.setSettingValue(settingsTypingIndicator, !old);
|
||||
const old = Boolean(window.getSettingValue(SettingsKey.settingsTypingIndicator));
|
||||
window.setSettingValue(SettingsKey.settingsTypingIndicator, !old);
|
||||
forceUpdate();
|
||||
}}
|
||||
title={window.i18n('typingIndicatorsSettingTitle')}
|
||||
description={window.i18n('typingIndicatorsSettingDescription')}
|
||||
active={Boolean(window.getSettingValue(settingsTypingIndicator))}
|
||||
active={Boolean(window.getSettingValue(SettingsKey.settingsTypingIndicator))}
|
||||
/>
|
||||
<SessionToggleWithDescription
|
||||
onClickToggle={() => {
|
||||
const old = Boolean(window.getSettingValue(settingsAutoUpdate));
|
||||
window.setSettingValue(settingsAutoUpdate, !old);
|
||||
const old = Boolean(window.getSettingValue(SettingsKey.settingsAutoUpdate));
|
||||
window.setSettingValue(SettingsKey.settingsAutoUpdate, !old);
|
||||
forceUpdate();
|
||||
}}
|
||||
title={window.i18n('autoUpdateSettingTitle')}
|
||||
description={window.i18n('autoUpdateSettingDescription')}
|
||||
active={Boolean(window.getSettingValue(settingsAutoUpdate))}
|
||||
active={Boolean(window.getSettingValue(SettingsKey.settingsAutoUpdate))}
|
||||
/>
|
||||
{hasMessageRequestFlag && (
|
||||
<SessionToggleWithDescription
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
const settingsReadReceipt = 'read-receipt-setting';
|
||||
const settingsTypingIndicator = 'typing-indicators-setting';
|
||||
const settingsAutoUpdate = 'auto-update';
|
||||
|
||||
export const SettingsKey = { settingsReadReceipt, settingsTypingIndicator, settingsAutoUpdate };
|
|
@ -52,6 +52,7 @@ import {
|
|||
ReplyingToMessageProps,
|
||||
SendMessageType,
|
||||
} from '../components/conversation/composition/CompositionBox';
|
||||
import { SettingsKey } from '../data/settings-key';
|
||||
|
||||
export enum ConversationTypeEnum {
|
||||
GROUP = 'group',
|
||||
|
@ -1069,7 +1070,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
|
|||
}
|
||||
if (this.isPrivate() && read.length && options.sendReadReceipts) {
|
||||
window?.log?.info(`Sending ${read.length} read receipts`);
|
||||
if (window.storage.get('read-receipt-setting')) {
|
||||
if (window.storage.get(SettingsKey.settingsReadReceipt)) {
|
||||
await Promise.all(
|
||||
_.map(_.groupBy(read, 'sender'), async (receipts, sender) => {
|
||||
const timestamps = _.map(receipts, 'timestamp').filter(t => !!t) as Array<number>;
|
||||
|
@ -1558,7 +1559,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
|
|||
// for typing to happen, this must be a private unblocked active convo, and the settings to be on
|
||||
if (
|
||||
!this.isActive() ||
|
||||
!window.storage.get('typing-indicators-setting') ||
|
||||
!window.storage.get(SettingsKey.settingsTypingIndicator) ||
|
||||
this.isBlocked() ||
|
||||
!this.isPrivate()
|
||||
) {
|
||||
|
|
|
@ -51,6 +51,7 @@ import { isUsFromCache } from '../session/utils/User';
|
|||
import { perfEnd, perfStart } from '../session/utils/Performance';
|
||||
import { AttachmentTypeWithPath } from '../types/Attachment';
|
||||
import _ from 'lodash';
|
||||
import { SettingsKey } from '../data/settings-key';
|
||||
// tslint:disable: cyclomatic-complexity
|
||||
|
||||
/**
|
||||
|
@ -393,7 +394,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
|
|||
}
|
||||
|
||||
const readBy = this.get('read_by') || [];
|
||||
if (window.storage.get('read-receipt-setting') && readBy.length > 0) {
|
||||
if (window.storage.get(SettingsKey.settingsReadReceipt) && readBy.length > 0) {
|
||||
return 'read';
|
||||
}
|
||||
const sent = this.get('sent');
|
||||
|
|
|
@ -23,6 +23,7 @@ import {
|
|||
deleteMessagesFromSwarmAndCompletelyLocally,
|
||||
deleteMessagesFromSwarmAndMarkAsDeletedLocally,
|
||||
} from '../interactions/conversations/unsendingInteractions';
|
||||
import { SettingsKey } from '../data/settings-key';
|
||||
|
||||
export async function handleContentMessage(envelope: EnvelopePlus, messageHash?: string) {
|
||||
try {
|
||||
|
@ -415,7 +416,7 @@ function onReadReceipt(readAt: any, timestamp: any, reader: any) {
|
|||
|
||||
window?.log?.info('read receipt', reader, timestamp);
|
||||
|
||||
if (!storage.get('read-receipt-setting')) {
|
||||
if (!storage.get(SettingsKey.settingsReadReceipt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -463,7 +464,7 @@ async function handleTypingMessage(
|
|||
await removeFromCache(envelope);
|
||||
|
||||
// We don't do anything with incoming typing messages if the setting is disabled
|
||||
if (!window.storage.get('typing-indicators-setting')) {
|
||||
if (!window.storage.get(SettingsKey.settingsTypingIndicator)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import { trigger } from '../shims/events';
|
|||
import { actions as userActions } from '../state/ducks/user';
|
||||
import { mn_decode, mn_encode } from '../session/crypto/mnemonic';
|
||||
import { ConversationTypeEnum } from '../models/conversation';
|
||||
import { SettingsKey } from '../data/settings-key';
|
||||
|
||||
/**
|
||||
* Might throw
|
||||
|
@ -137,8 +138,8 @@ async function createAccount(identityKeyPair: any) {
|
|||
window.textsecure.storage.remove('number_id'),
|
||||
window.textsecure.storage.remove('device_name'),
|
||||
window.textsecure.storage.remove('userAgent'),
|
||||
window.textsecure.storage.remove('read-receipt-setting'),
|
||||
window.textsecure.storage.remove('typing-indicators-setting'),
|
||||
window.textsecure.storage.remove(SettingsKey.settingsReadReceipt),
|
||||
window.textsecure.storage.remove(SettingsKey.settingsTypingIndicator),
|
||||
window.textsecure.storage.remove('regionCode'),
|
||||
window.textsecure.storage.remove('local_attachment_encrypted_key'),
|
||||
]);
|
||||
|
@ -151,10 +152,10 @@ async function createAccount(identityKeyPair: any) {
|
|||
await window.textsecure.storage.put('password', password);
|
||||
|
||||
// disable read-receipt by default
|
||||
await window.textsecure.storage.put('read-receipt-setting', false);
|
||||
await window.textsecure.storage.put(SettingsKey.settingsReadReceipt, false);
|
||||
|
||||
// Enable typing indicators by default
|
||||
await window.textsecure.storage.put('typing-indicators-setting', true);
|
||||
await window.textsecure.storage.put(SettingsKey.settingsTypingIndicator, false);
|
||||
|
||||
await window.textsecure.storage.user.setNumberAndDeviceId(pubKeyString, 1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue