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

show device message only once as unread #4057

Merged
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 @@ -25,6 +25,7 @@
- Case-insensitive search for non-ASCII messages
- make ImageCropper use CSS-transforms for UI and canvas API to cut the result #3893
- update stock translations #4051
- show device message only once as unread #4057

### Fixed
- Fix crash on "Settings" click when not on main screen (e.g. no account selected): hide the "settings" button
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/ScreenController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getLogger } from '../shared/logger'
import AccountSetupScreen from './components/screens/AccountSetupScreen'
import WelcomeScreen from './components/screens/WelcomeScreen'
import { BackendRemote, EffectfulBackendActions } from './backend-com'
import { updateDeviceChats } from './deviceMessages'
import { updateDeviceChat, updateDeviceChats } from './deviceMessages'
import { runtime } from './runtime'
import { updateTimestamps } from './components/conversations/Timestamp'
import { ScreenContext } from './contexts/ScreenContext'
Expand Down Expand Up @@ -95,6 +95,7 @@ export default class ScreenController extends Component {
await this.addAndSelectAccount()
}
}
updateDeviceChats()
}

private async _getLastUsedAccount(): Promise<number | undefined> {
Expand Down Expand Up @@ -130,7 +131,6 @@ export default class ScreenController extends Component {
)
if (account.kind === 'Configured') {
this.changeScreen(Screens.Main)
updateDeviceChats(this.selectedAccountId)
} else {
this.changeScreen(Screens.Welcome)
}
Expand Down Expand Up @@ -167,7 +167,7 @@ export default class ScreenController extends Component {
this.lastAccountBeforeAddingNewAccount = this.selectedAccountId
}
const accountId = await BackendRemote.rpc.addAccount()
updateDeviceChats(accountId, true) // skip changelog
updateDeviceChat(accountId, true) // skip changelog
await this.selectAccount(accountId)
return accountId
}
Expand Down
14 changes: 13 additions & 1 deletion src/renderer/deviceMessages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BackendRemote } from './backend-com'
import { getDeviceChatId, markChatAsSeen } from './backend/chat'

export async function updateDeviceChats(
export async function updateDeviceChat(
accountId: number,
skipCurrentChangelog: boolean = false
) {
Expand Down Expand Up @@ -39,3 +40,14 @@ export async function updateDeviceChats(
[Full Changelog](https://github.com/deltachat/deltachat-desktop/blob/main/CHANGELOG.md#1_46_0)`,
})
}

export async function updateDeviceChats() {
const selectedAccount = await BackendRemote.rpc.getSelectedAccountId()
for (const accountId of await BackendRemote.rpc.getAllAccountIds()) {
await updateDeviceChat(accountId, false)
if (accountId !== selectedAccount) {
const devChatId = await getDeviceChatId(accountId)
if (devChatId) markChatAsSeen(accountId, devChatId)
}
}
}
Loading