fix: sync Android default theme installs

This commit is contained in:
iamxvbaba 2026-07-30 20:13:22 +08:00
parent 80c36a8ab4
commit 0d917ef87e
8 changed files with 263 additions and 7 deletions

View file

@ -220,6 +220,12 @@ func (r *Router) onAccountSaveTheme(ctx context.Context, req *tg.AccountSaveThem
if userID == 0 {
return false, authKeyUnregisteredErr()
}
if _, ok := tdesktop.LookupDefaultTheme(req.Theme); ok {
// Default catalog themes are always present in account.getThemes. Saving
// or unsaving one is therefore an idempotent signal and must not create a
// synthetic custom-theme row or user install.
return true, nil
}
if r.deps.Themes == nil {
return false, notImplementedErr()
}
@ -252,14 +258,20 @@ func (r *Router) onAccountInstallTheme(ctx context.Context, req *tg.AccountInsta
if userID == 0 {
return false, authKeyUnregisteredErr()
}
if r.deps.Themes == nil {
return false, notImplementedErr()
}
dark := req.GetDark()
theme, ok := req.GetTheme()
if !ok {
return true, nil // 无 theme 引用:基础主题 no-op 安装
}
if _, ok := tdesktop.LookupDefaultTheme(theme); ok {
// The immutable defaults were issued by account.getThemes but do not
// live in the custom theme store. Applying one is a successful signal;
// the Android client owns the active day/night choice locally.
return true, nil
}
if r.deps.Themes == nil {
return false, notImplementedErr()
}
ref, ok := themeRefFromInput(theme)
if !ok {
return false, themeInvalidErr()
@ -280,6 +292,9 @@ func (r *Router) onAccountGetTheme(ctx context.Context, req *tg.AccountGetThemeR
if err != nil {
return nil, internalErr()
}
if t, ok := tdesktop.LookupDefaultTheme(req.Theme); ok {
return projectThemeForClient(ctx, &t), nil
}
if r.deps.Themes == nil {
return nil, notImplementedErr()
}