Unverified Commit 06fb2174 authored by Mehad Nadeem's avatar Mehad Nadeem Committed by GitHub

feat: add compact mode setting (Proto) (#2934)

* chore: proto related files for compact view setting.

* fix: pasing lint errors
parent 5ac17fc0
This diff is collapsed.
......@@ -219,6 +219,7 @@ func getDefaultUserSetting() *apiv2pb.UserSetting {
Locale: "en",
Appearance: "system",
MemoVisibility: "PRIVATE",
CompactView: false,
}
}
......@@ -244,6 +245,8 @@ func (s *APIV2Service) GetUserSetting(ctx context.Context, _ *apiv2pb.GetUserSet
userSettingMessage.MemoVisibility = setting.GetMemoVisibility()
} else if setting.Key == storepb.UserSettingKey_USER_SETTING_TELEGRAM_USER_ID {
userSettingMessage.TelegramUserId = setting.GetTelegramUserId()
} else if setting.Key == storepb.UserSettingKey_USER_SETTING_COMPACT_VIEW {
userSettingMessage.CompactView = setting.GetCompactView()
}
}
return &apiv2pb.GetUserSettingResponse{
......@@ -302,6 +305,16 @@ func (s *APIV2Service) UpdateUserSetting(ctx context.Context, request *apiv2pb.U
}); err != nil {
return nil, status.Errorf(codes.Internal, "failed to upsert user setting: %v", err)
}
} else if field == "compact_view" {
if _, err := s.Store.UpsertUserSetting(ctx, &storepb.UserSetting{
UserId: user.ID,
Key: storepb.UserSettingKey_USER_SETTING_COMPACT_VIEW,
Value: &storepb.UserSetting_CompactView{
CompactView: request.Setting.CompactView,
},
}); err != nil {
return nil, status.Errorf(codes.Internal, "failed to upsert user setting: %v", err)
}
} else {
return nil, status.Errorf(codes.InvalidArgument, "invalid update path: %s", field)
}
......
......@@ -161,6 +161,8 @@ message UserSetting {
string memo_visibility = 4;
// The telegram user id of the user.
string telegram_user_id = 5;
// The compact view for a memo.
bool compact_view = 6;
}
message GetUserSettingRequest {
......
......@@ -699,6 +699,7 @@ Used internally for obfuscating the page token.
| appearance | [string](#string) | | The preferred appearance of the user. |
| memo_visibility | [string](#string) | | The default visibility of the memo. |
| telegram_user_id | [string](#string) | | The telegram user id of the user. |
| compact_view | [bool](#bool) | | The compact view for a memo. |
......
This diff is collapsed.
......@@ -225,6 +225,7 @@
| appearance | [string](#string) | | |
| memo_visibility | [string](#string) | | |
| telegram_user_id | [string](#string) | | |
| compact_view | [bool](#bool) | | |
......@@ -246,6 +247,7 @@
| USER_SETTING_APPEARANCE | 3 | The appearance of the user. |
| USER_SETTING_MEMO_VISIBILITY | 4 | The visibility of the memo. |
| USER_SETTING_TELEGRAM_USER_ID | 5 | The telegram user id of the user. |
| USER_SETTING_COMPACT_VIEW | 6 | The compact view for a memo. |
......
This diff is collapsed.
......@@ -15,6 +15,7 @@ message UserSetting {
string appearance = 5;
string memo_visibility = 6;
string telegram_user_id = 7;
bool compact_view = 8;
}
}
......@@ -35,6 +36,9 @@ enum UserSettingKey {
// The telegram user id of the user.
USER_SETTING_TELEGRAM_USER_ID = 5;
// The compact view for a memo.
USER_SETTING_COMPACT_VIEW = 6;
}
message AccessTokensUserSetting {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment