Skip to content

Commit

Permalink
chore: tweak user setting service response
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyjoygh committed Aug 17, 2024
1 parent 8eac931 commit 06b8f32
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 295 deletions.
20 changes: 8 additions & 12 deletions frontend/web/src/stores/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,21 @@ const useUserStore = create<UserState>()((set, get) => ({
});
},
fetchUserSetting: async (userId: number) => {
const userSetting = (
await userSettingServiceClient.getUserSetting({
id: userId,
})
).userSetting as UserSetting;
const userSetting = await userSettingServiceClient.getUserSetting({
id: userId,
});
const userSettingMap = get().userSettingMapById;
userSettingMap[userId] = userSetting;
set(userSettingMap);
return userSetting;
},
updateUserSetting: async (userSetting: UserSetting, updateMask: string[]) => {
const userId = userSetting.userId;
const updatedUserSetting = (
await userSettingServiceClient.updateUserSetting({
id: userId,
userSetting,
updateMask,
})
).userSetting as UserSetting;
const updatedUserSetting = await userSettingServiceClient.updateUserSetting({
id: userId,
userSetting,
updateMask,
});
const userSettingMap = get().userSettingMapById;
userSettingMap[userId] = updatedUserSetting;
set(userSettingMap);
Expand Down
12 changes: 2 additions & 10 deletions proto/api/v1/user_setting_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ option go_package = "gen/api/v1";

service UserSettingService {
// GetUserSetting returns the user setting.
rpc GetUserSetting(GetUserSettingRequest) returns (GetUserSettingResponse) {
rpc GetUserSetting(GetUserSettingRequest) returns (UserSetting) {
option (google.api.http) = {get: "/api/v1/users/{id}/settings"};
option (google.api.method_signature) = "id";
}
// UpdateUserSetting updates the user setting.
rpc UpdateUserSetting(UpdateUserSettingRequest) returns (UpdateUserSettingResponse) {
rpc UpdateUserSetting(UpdateUserSettingRequest) returns (UserSetting) {
option (google.api.http) = {
patch: "/api/v1/users/{id}/settings"
body: "user_setting"
Expand Down Expand Up @@ -52,10 +52,6 @@ message GetUserSettingRequest {
int32 id = 1;
}

message GetUserSettingResponse {
UserSetting user_setting = 1;
}

message UpdateUserSettingRequest {
// id is the user id.
int32 id = 1;
Expand All @@ -66,7 +62,3 @@ message UpdateUserSettingRequest {
// update_mask is the field mask to update.
google.protobuf.FieldMask update_mask = 3;
}

message UpdateUserSettingResponse {
UserSetting user_setting = 1;
}
36 changes: 2 additions & 34 deletions proto/gen/api/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@

- [api/v1/user_setting_service.proto](#api_v1_user_setting_service-proto)
- [GetUserSettingRequest](#slash-api-v1-GetUserSettingRequest)
- [GetUserSettingResponse](#slash-api-v1-GetUserSettingResponse)
- [UpdateUserSettingRequest](#slash-api-v1-UpdateUserSettingRequest)
- [UpdateUserSettingResponse](#slash-api-v1-UpdateUserSettingResponse)
- [UserSetting](#slash-api-v1-UserSetting)
- [UserSetting.AccessTokensSetting](#slash-api-v1-UserSetting-AccessTokensSetting)
- [UserSetting.AccessTokensSetting.AccessToken](#slash-api-v1-UserSetting-AccessTokensSetting-AccessToken)
Expand Down Expand Up @@ -1056,21 +1054,6 @@



<a name="slash-api-v1-GetUserSettingResponse"></a>

### GetUserSettingResponse



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| user_setting | [UserSetting](#slash-api-v1-UserSetting) | | |






<a name="slash-api-v1-UpdateUserSettingRequest"></a>

### UpdateUserSettingRequest
Expand All @@ -1088,21 +1071,6 @@



<a name="slash-api-v1-UpdateUserSettingResponse"></a>

### UpdateUserSettingResponse



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| user_setting | [UserSetting](#slash-api-v1-UserSetting) | | |






<a name="slash-api-v1-UserSetting"></a>

### UserSetting
Expand Down Expand Up @@ -1180,8 +1148,8 @@

| Method Name | Request Type | Response Type | Description |
| ----------- | ------------ | ------------- | ------------|
| GetUserSetting | [GetUserSettingRequest](#slash-api-v1-GetUserSettingRequest) | [GetUserSettingResponse](#slash-api-v1-GetUserSettingResponse) | GetUserSetting returns the user setting. |
| UpdateUserSetting | [UpdateUserSettingRequest](#slash-api-v1-UpdateUserSettingRequest) | [UpdateUserSettingResponse](#slash-api-v1-UpdateUserSettingResponse) | UpdateUserSetting updates the user setting. |
| GetUserSetting | [GetUserSettingRequest](#slash-api-v1-GetUserSettingRequest) | [UserSetting](#slash-api-v1-UserSetting) | GetUserSetting returns the user setting. |
| UpdateUserSetting | [UpdateUserSettingRequest](#slash-api-v1-UpdateUserSettingRequest) | [UserSetting](#slash-api-v1-UserSetting) | UpdateUserSetting updates the user setting. |



Expand Down
Loading

0 comments on commit 06b8f32

Please sign in to comment.