Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update options for disappearing messages #3530

Merged
merged 8 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- update `@deltachat/message_parser_wasm` to `0.9.0`, which fixes a bug with BotCommandSuggestion parsing
- update `electron` from `v26.4.2` to version `v26.6.0`
- update deltachat-node and deltachat/jsonrpc-client to `v1.131.3`
- Update options for disappearing messages #3530
- Do not show redundant read-only message when in device messages chat #3532

### Fixed
Expand Down
28 changes: 17 additions & 11 deletions src/renderer/components/dialogs/DisappearingMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import { selectedAccountId } from '../../ScreenController'

enum DisappearingMessageDuration {
OFF = Timespans.ZERO_SECONDS,
THIRTY_SECONDS = Timespans.THIRTY_SECONDS,
ONE_MINUTE = Timespans.ONE_MINUTE_IN_SECONDS,
FIVE_MINUTES = Timespans.ONE_MINUTE_IN_SECONDS * 5,
THIRTY_MINUTES = Timespans.ONE_MINUTE_IN_SECONDS * 30,
ONE_HOUR = Timespans.ONE_HOUR_IN_SECONDS,
ONE_DAY = Timespans.ONE_DAY_IN_SECONDS,
ONE_WEEK = Timespans.ONE_WEEK_IN_SECONDS,
FOUR_WEEKS = Timespans.FOUR_WEEKS_IN_SECONDS,
FIVE_WEEKS = Timespans.ONE_WEEK_IN_SECONDS * 5,
}

function SelectDisappearingMessageDuration({
Expand Down Expand Up @@ -51,33 +52,38 @@ function SelectDisappearingMessageDuration({
/>
<Radio
key={'eph-1'}
label={tx('after_30_seconds')}
value={String(DisappearingMessageDuration.THIRTY_SECONDS)}
label={tx('after_1_minute')}
value={String(DisappearingMessageDuration.ONE_MINUTE)}
/>
<Radio
key={'eph-2'}
label={tx('after_1_minute')}
value={String(DisappearingMessageDuration.ONE_MINUTE)}
label={tx('after_5_minutes')}
value={String(DisappearingMessageDuration.FIVE_MINUTES)}
/>
<Radio
key={'eph-3'}
label={tx('after_30_minutes')}
value={String(DisappearingMessageDuration.THIRTY_MINUTES)}
/>
<Radio
key={'eph-4'}
label={tx('autodel_after_1_hour')}
value={String(DisappearingMessageDuration.ONE_HOUR)}
/>
<Radio
key={'eph-4'}
key={'eph-5'}
label={tx('autodel_after_1_day')}
value={String(DisappearingMessageDuration.ONE_DAY)}
/>
<Radio
key={'eph-5'}
key={'eph-6'}
label={tx('autodel_after_1_week')}
value={String(DisappearingMessageDuration.ONE_WEEK)}
/>
<Radio
key={'eph-6'}
label={tx('autodel_after_4_weeks')}
value={String(DisappearingMessageDuration.FOUR_WEEKS)}
key={'eph-7'}
label={tx('after_5_weeks')}
value={String(DisappearingMessageDuration.FIVE_WEEKS)}
/>
</RadioGroup>
)
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/dialogs/MuteChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function MuteChat({
tx('mute_for_one_hour'),
],
[
{ kind: 'Until', duration: Timespans.TWO_HOURS_IN_SECONDS },
{ kind: 'Until', duration: Timespans.ONE_HOUR_IN_SECONDS * 2 },
tx('mute_for_two_hours'),
],
[
Expand Down
30 changes: 13 additions & 17 deletions src/renderer/components/dialogs/Settings-Autodelete.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useContext, useState } from 'react'
import { H5 } from '@blueprintjs/core'
import classNames from 'classnames'

import { ScreenContext, useTranslationFunction } from '../../contexts'
import {
DeltaDialogBody,
Expand All @@ -14,7 +16,6 @@ import { DialogProps } from './DialogController'
import { SettingsSelector } from './Settings'
import { AutodeleteDuration } from '../../../shared/constants'
import { DeltaCheckbox } from '../contact/ContactListItem'
import classNames from 'classnames'
import SettingsStoreInstance, {
SettingsStoreState,
} from '../../stores/settings'
Expand All @@ -29,8 +30,6 @@ function durationToString(configValue: number | string) {
return tx('never')
case AutodeleteDuration.AT_ONCE:
return tx('autodel_at_once')
case AutodeleteDuration.THIRTY_SECONDS:
return tx('after_30_seconds')
case AutodeleteDuration.ONE_MINUTE:
return tx('after_1_minute')
case AutodeleteDuration.ONE_HOUR:
Expand All @@ -39,8 +38,8 @@ function durationToString(configValue: number | string) {
return tx('autodel_after_1_day')
case AutodeleteDuration.ONE_WEEK:
return tx('autodel_after_1_week')
case AutodeleteDuration.FOUR_WEEKS:
return tx('autodel_after_4_weeks')
case AutodeleteDuration.FIVE_WEEKS:
return tx('after_5_weeks')
case AutodeleteDuration.ONE_YEAR:
return tx('autodel_after_1_year')
default:
Expand Down Expand Up @@ -128,32 +127,29 @@ export default function SettingsAutodelete({
}: {
settingsStore: SettingsStoreState
}) {
const { openDialog } = useContext(ScreenContext)
const accountId = selectedAccountId()

const tx = useTranslationFunction()

const AUTODELETE_DURATION_OPTIONS_SERVER = [
const AUTODELETE_DURATION_OPTIONS_DEVICE = [
AutodeleteDuration.NEVER,
AutodeleteDuration.AT_ONCE,
AutodeleteDuration.THIRTY_SECONDS,
AutodeleteDuration.ONE_MINUTE,
AutodeleteDuration.ONE_HOUR,
AutodeleteDuration.ONE_DAY,
AutodeleteDuration.ONE_WEEK,
AutodeleteDuration.FOUR_WEEKS,
AutodeleteDuration.FIVE_WEEKS,
AutodeleteDuration.ONE_YEAR,
].map(value => [String(value), durationToString(value)] as SelectDialogOption)

const AUTODELETE_DURATION_OPTIONS_DEVICE = [
const AUTODELETE_DURATION_OPTIONS_SERVER = [
AutodeleteDuration.NEVER,
AutodeleteDuration.AT_ONCE,
AutodeleteDuration.ONE_HOUR,
AutodeleteDuration.ONE_DAY,
AutodeleteDuration.ONE_WEEK,
AutodeleteDuration.FOUR_WEEKS,
AutodeleteDuration.FIVE_WEEKS,
AutodeleteDuration.ONE_YEAR,
].map(value => [String(value), durationToString(value)] as SelectDialogOption)

const { openDialog } = useContext(ScreenContext)
const accountId = selectedAccountId()
const tx = useTranslationFunction()

const onOpenDialog = async (fromServer: boolean) => {
openDialog(SmallSelectDialog, {
values: fromServer
Expand Down
6 changes: 1 addition & 5 deletions src/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,21 @@ export const appWindowTitle = appName
export const enum Timespans {
ZERO_SECONDS = 0,
ONE_SECOND = 1,
THIRTY_SECONDS = 30,
ONE_MINUTE_IN_SECONDS = 60,
ONE_HOUR_IN_SECONDS = 60 * 60,
TWO_HOURS_IN_SECONDS = 60 * 60 * 2,
ONE_DAY_IN_SECONDS = 60 * 60 * 24,
ONE_WEEK_IN_SECONDS = 60 * 60 * 24 * 7,
FOUR_WEEKS_IN_SECONDS = 60 * 60 * 24 * 7 * 4,
ONE_YEAR_IN_SECONDS = 60 * 60 * 24 * 365,
}

export const enum AutodeleteDuration {
NEVER = Timespans.ZERO_SECONDS,
AT_ONCE = Timespans.ONE_SECOND,
THIRTY_SECONDS = Timespans.THIRTY_SECONDS,
ONE_MINUTE = Timespans.ONE_MINUTE_IN_SECONDS,
ONE_HOUR = Timespans.ONE_HOUR_IN_SECONDS,
ONE_DAY = Timespans.ONE_DAY_IN_SECONDS,
ONE_WEEK = Timespans.ONE_WEEK_IN_SECONDS,
FOUR_WEEKS = Timespans.FOUR_WEEKS_IN_SECONDS,
FIVE_WEEKS = Timespans.ONE_WEEK_IN_SECONDS * 5,
ONE_YEAR = Timespans.ONE_YEAR_IN_SECONDS,
}

Expand Down
Loading