Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

阅读设置切换失效 #1239

Open
4 of 5 tasks
FooIbar opened this issue Jul 10, 2023 · 1 comment
Open
4 of 5 tasks

阅读设置切换失效 #1239

FooIbar opened this issue Jul 10, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@FooIbar
Copy link
Contributor

FooIbar commented Jul 10, 2023

复现步骤 / Step to reproduce

  1. 打开画廊
  2. 切换阅读模式

预期行为 / Expected behaviour

成功切换

实际行为 / Actual Behaviour

ReaderPreferences.defaultReadingMode().set(newReadingMode.flagValue)

这里设置了阅读模式后
val viewerMode = ReadingModeType.fromPreference(ReaderPreferences.defaultReadingMode().get())

这里拿到的是过时数据

应用日志 / App logs

2023-07-10 14:07:56.602 12405-12405 ReaderActivity          moe.tarsin.ehviewer.debug            D  Get: DEFAULT
2023-07-10 14:07:56.644 12405-12405 L2RPagerViewer          moe.tarsin.ehviewer.debug            D  setChaptersInternal
2023-07-10 14:07:56.646 12405-12405 L2RPagerViewer          moe.tarsin.ehviewer.debug            D  Pager first layout
2023-07-10 14:07:56.646 12405-12405 L2RPagerViewer          moe.tarsin.ehviewer.debug            D  moveToPage 1
2023-07-10 14:08:06.447 12405-12405 MenuItemImpl            moe.tarsin.ehviewer.debug            D  Set: WEBTOON
2023-07-10 14:08:06.448 12405-12405 ReaderActivity          moe.tarsin.ehviewer.debug            D  Get: DEFAULT

备注 / Addition details

No response

EhViewer 版本号 / EhViewer version code

1.8.9.0-SNAPSHOT

EhViewer CI 版本 / EhViewer CI Version

740fff2

Android 系统版本 / Android version

PixelExperience 11

设备型号 / Device model

Moto Z2 Play

SoC 型号 / Soc model

Snapdragon 626

自查步骤 / Verify steps

  • 如果您有足够的时间和能力,并愿意为此提交 PR ,请勾上此复选框 / Pull request is welcome. Check this if you want to start a pull request
  • 您已仔细查看并知情 Q&A 中的内容 / You have checked Q&A carefully
  • 您已搜索过 Issue Tracker,没有找到类似内容 / I have searched on Issue Tracker, No duplicate or related open issue has been found
  • 您确保这个 Issue 只提及一个问题。如果您有多个问题报告,烦请发起多个 Issue / Ensure there is only one bug report in this issue. Please make mutiply issue for mutiply bugs
  • 您确保已使用最新 CI 版本测试,并且该问题在最新 CI 版本中并未解决 / This bug have not solved in latest CI version
@FooIbar
Copy link
Contributor Author

FooIbar commented Jul 12, 2023

原因是 SharedPreferencesEditor.apply() 是立即写入内存,然后异步写入持久性储存
而使用 DataStore 作为后端的 DataStorePreferences 的数据修改是完全异步的
https://github.com/LouisCAD/Splitties/blob/0e4fcbf67c8aea591068366f7736499fbd77f565/modules/preferences/src/androidMain/kotlin/splitties/preferences/DataStorePreferencesImpl.kt#L153

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

1 participant