Skip to content

Commit

Permalink
Fix Settings/AllMedia in Account List context menu
Browse files Browse the repository at this point in the history
- combine all settings-gathering when changing account since some
  functions await for SelectAccount
- give additional 50ms to switching to Gallery since there's a conflict
  of setState and async media query in Gallery.tsx
- resolves #4190
- resolves #4191
  • Loading branch information
maxphilippov committed Oct 10, 2024
1 parent fb05580 commit 2d55c5b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
- fix: exit search when clicking on profile when the selected profile is already the selected account #4166
- "Encryption Info" dialog showing all info in one line #4162
- losing scrolling "momentum" while scrolling the messages list fast #4122
- fix crash when you chose Settings from a context menu on account you haven't selected #4190
- fix All Media not opening from a context menu on account you haven't selected #4191

<a id="1_46_8"></a>

Expand Down
13 changes: 9 additions & 4 deletions packages/frontend/src/ScreenController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ export default class ScreenController extends Component {
await this.unSelectAccount()
this.selectedAccountId = accountId
;(window.__selectedAccountId as number) = accountId
// forcing to load settings here so when we for example switch to Settings
// from context menu they're already present and we avoid crashing
SettingsStoreInstance.effect.load()
} else {
log.info('account is already selected')
// do not return here as this can be the state transition between unconfigured to configured
Expand All @@ -138,13 +141,15 @@ export default class ScreenController extends Component {
if (!dontStartIo) {
await BackendRemote.rpc.startIo(accountId)
}
runtime.setDesktopSetting('lastAccount', accountId)
BackendRemote.rpc.getSystemInfo().then(info => {
log.info('system_info', info)
})

BackendRemote.rpc.getInfo(accountId).then(info => {
log.info('account_info', info)
})
BackendRemote.rpc.getSystemInfo().then(info => {
log.info('system_info', info)
})

await runtime.setDesktopSetting('lastAccount', accountId)
}

async unSelectAccount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ export default function AccountItem({
// set Timeout forces it to be run after react update
setTimeout(() => {
ActionEmitter.emitAction(KeybindAction.GlobalGallery_Open)
}, 0)
// NOTE(maxph): Gallery.tsx gets unmounted before receiving media data
// and breaks markdown, so here 50ms is a temprorary workaround for that
}, 50)
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class SettingsStore extends Store<SettingsStoreState | null> {
)
const desktopSettings = await runtime.getDesktopSettings()

const rc = await runtime.getRC_Config()
const rc = runtime.getRC_Config()
this.reducer.setState({
settings,
selfContact,
Expand Down

0 comments on commit 2d55c5b

Please sign in to comment.