Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

feat: implement embedded resource renderer

Steven196facfacdb0
diff --git a/api/v2/resource_service.go b/api/v2/resource_service.go
index 27dc79161..e80fcf4f6 100644
--- a/api/v2/resource_service.go
+++ b/api/v2/resource_service.go
@@ -66,6 +66,19 @@ func (s *APIV2Service) ListResources(ctx context.Context, _ *apiv2pb.ListResourc
return response, nil
}
+func (s *APIV2Service) GetResource(ctx context.Context, request *apiv2pb.GetResourceRequest) (*apiv2pb.GetResourceResponse, error) {
+ resource, err := s.Store.GetResource(ctx, &store.FindResource{
+ ID: &request.Id,
+ })
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to list resources: %v", err)
+ }
+
+ return &apiv2pb.GetResourceResponse{
+ Resource: s.convertResourceFromStore(ctx, resource),
+ }, nil
+}
+
func (s *APIV2Service) UpdateResource(ctx context.Context, request *apiv2pb.UpdateResourceRequest) (*apiv2pb.UpdateResourceResponse, error) {
if request.UpdateMask == nil || len(request.UpdateMask.Paths) == 0 {
return nil, status.Errorf(codes.InvalidArgument, "update mask is required")
diff --git a/proto/api/v2/resource_service.proto b/proto/api/v2/resource_service.proto
index 5a6bdfd14..8389838b3 100644
--- a/proto/api/v2/resource_service.proto
+++ b/proto/api/v2/resource_service.proto
@@ -16,6 +16,10 @@ service ResourceService {
rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse) {
option (google.api.http) = {get: "/api/v2/resources"};
}
+ rpc GetResource(GetResourceRequest) returns (GetResourceResponse) {
+ option (google.api.http) = {get: "/api/v2/resources/{id}"};
+ option (google.api.method_signature) = "id";
+ }
rpc UpdateResource(UpdateResourceRequest) returns (UpdateResourceResponse) {
option (google.api.http) = {
patch: "/api/v2/resources/{resource.id}",
@@ -24,7 +28,7 @@ service ResourceService {
option (google.api.method_signature) = "resource,update_mask";
}
rpc DeleteResource(DeleteResourceRequest) returns (DeleteResourceResponse) {
- option (google.api.http) = {get: "/api/v2/resources/{id}"};
+ option (google.api.http) = {delete: "/api/v2/resources/{id}"};
option (google.api.method_signature) = "id";
}
}
@@ -56,6 +60,14 @@ message ListResourcesResponse {
repeated Resource resources = 1;
}
+message GetResourceRequest {
+ int32 id = 1;
+}
+
+message GetResourceResponse {
+ Resource resource = 1;
+}
+
message UpdateResourceRequest {
Resource resource = 1;
diff --git a/proto/gen/api/v2/README.md b/proto/gen/api/v2/README.md
index 2269b3d7a..b2ae85065 100644
--- a/proto/gen/api/v2/README.md
+++ b/proto/gen/api/v2/README.md
@@ -112,6 +112,8 @@
- [CreateResourceResponse](#memos-api-v2-CreateResourceResponse)
- [DeleteResourceRequest](#memos-api-v2-DeleteResourceRequest)
- [DeleteResourceResponse](#memos-api-v2-DeleteResourceResponse)
+ - [GetResourceRequest](#memos-api-v2-GetResourceRequest)
+ - [GetResourceResponse](#memos-api-v2-GetResourceResponse)
- [ListResourcesRequest](#memos-api-v2-ListResourcesRequest)
- [ListResourcesResponse](#memos-api-v2-ListResourcesResponse)
- [Resource](#memos-api-v2-Resource)
@@ -1637,6 +1639,36 @@
+<a name="memos-api-v2-GetResourceRequest"></a>
+
+### GetResourceRequest
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| id | [int32](#int32) | | |
+
+
+
+
+
+
+<a name="memos-api-v2-GetResourceResponse"></a>
+
+### GetResourceResponse
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| resource | [Resource](#memos-api-v2-Resource) | | |
+
+
+
+
+
+
<a name="memos-api-v2-ListResourcesRequest"></a>
### ListResourcesRequest
@@ -1729,6 +1761,7 @@
| ----------- | ------------ | ------------- | ------------|
| CreateResource | [CreateResourceRequest](#memos-api-v2-CreateResourceRequest) | [CreateResourceResponse](#memos-api-v2-CreateResourceResponse) | |
| ListResources | [ListResourcesRequest](#memos-api-v2-ListResourcesRequest) | [ListResourcesResponse](#memos-api-v2-ListResourcesResponse) | |
+| GetResource | [GetResourceRequest](#memos-api-v2-GetResourceRequest) | [GetResourceResponse](#memos-api-v2-GetResourceResponse) | |
| UpdateResource | [UpdateResourceRequest](#memos-api-v2-UpdateResourceRequest) | [UpdateResourceResponse](#memos-api-v2-UpdateResourceResponse) | |
| DeleteResource | [DeleteResourceRequest](#memos-api-v2-DeleteResourceRequest) | [DeleteResourceResponse](#memos-api-v2-DeleteResourceResponse) | |
diff --git a/proto/gen/api/v2/resource_service.pb.go b/proto/gen/api/v2/resource_service.pb.go
index e207a602e..d9780b4c4 100644
--- a/proto/gen/api/v2/resource_service.pb.go
+++ b/proto/gen/api/v2/resource_service.pb.go
@@ -321,6 +321,100 @@ func (x *ListResourcesResponse) GetResources() []*Resource {
return nil
}
+type GetResourceRequest struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
+}
+
+func (x *GetResourceRequest) Reset() {
+ *x = GetResourceRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_api_v2_resource_service_proto_msgTypes[5]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *GetResourceRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GetResourceRequest) ProtoMessage() {}
+
+func (x *GetResourceRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_api_v2_resource_service_proto_msgTypes[5]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use GetResourceRequest.ProtoReflect.Descriptor instead.
+func (*GetResourceRequest) Descriptor() ([]byte, []int) {
+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{5}
+}
+
+func (x *GetResourceRequest) GetId() int32 {
+ if x != nil {
+ return x.Id
+ }
+ return 0
+}
+
+type GetResourceResponse struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"`
+}
+
+func (x *GetResourceResponse) Reset() {
+ *x = GetResourceResponse{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_api_v2_resource_service_proto_msgTypes[6]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *GetResourceResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GetResourceResponse) ProtoMessage() {}
+
+func (x *GetResourceResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_api_v2_resource_service_proto_msgTypes[6]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use GetResourceResponse.ProtoReflect.Descriptor instead.
+func (*GetResourceResponse) Descriptor() ([]byte, []int) {
+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{6}
+}
+
+func (x *GetResourceResponse) GetResource() *Resource {
+ if x != nil {
+ return x.Resource
+ }
+ return nil
+}
+
type UpdateResourceRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -333,7 +427,7 @@ type UpdateResourceRequest struct {
func (x *UpdateResourceRequest) Reset() {
*x = UpdateResourceRequest{}
if protoimpl.UnsafeEnabled {
- mi := &file_api_v2_resource_service_proto_msgTypes[5]
+ mi := &file_api_v2_resource_service_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -346,7 +440,7 @@ func (x *UpdateResourceRequest) String() string {
func (*UpdateResourceRequest) ProtoMessage() {}
func (x *UpdateResourceRequest) ProtoReflect() protoreflect.Message {
- mi := &file_api_v2_resource_service_proto_msgTypes[5]
+ mi := &file_api_v2_resource_service_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -359,7 +453,7 @@ func (x *UpdateResourceRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use UpdateResourceRequest.ProtoReflect.Descriptor instead.
func (*UpdateResourceRequest) Descriptor() ([]byte, []int) {
- return file_api_v2_resource_service_proto_rawDescGZIP(), []int{5}
+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{7}
}
func (x *UpdateResourceRequest) GetResource() *Resource {
@@ -387,7 +481,7 @@ type UpdateResourceResponse struct {
func (x *UpdateResourceResponse) Reset() {
*x = UpdateResourceResponse{}
if protoimpl.UnsafeEnabled {
- mi := &file_api_v2_resource_service_proto_msgTypes[6]
+ mi := &file_api_v2_resource_service_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -400,7 +494,7 @@ func (x *UpdateResourceResponse) String() string {
func (*UpdateResourceResponse) ProtoMessage() {}
func (x *UpdateResourceResponse) ProtoReflect() protoreflect.Message {
- mi := &file_api_v2_resource_service_proto_msgTypes[6]
+ mi := &file_api_v2_resource_service_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -413,7 +507,7 @@ func (x *UpdateResourceResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use UpdateResourceResponse.ProtoReflect.Descriptor instead.
func (*UpdateResourceResponse) Descriptor() ([]byte, []int) {
- return file_api_v2_resource_service_proto_rawDescGZIP(), []int{6}
+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{8}
}
func (x *UpdateResourceResponse) GetResource() *Resource {
@@ -434,7 +528,7 @@ type DeleteResourceRequest struct {
func (x *DeleteResourceRequest) Reset() {
*x = DeleteResourceRequest{}
if protoimpl.UnsafeEnabled {
- mi := &file_api_v2_resource_service_proto_msgTypes[7]
+ mi := &file_api_v2_resource_service_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -447,7 +541,7 @@ func (x *DeleteResourceRequest) String() string {
func (*DeleteResourceRequest) ProtoMessage() {}
func (x *DeleteResourceRequest) ProtoReflect() protoreflect.Message {
- mi := &file_api_v2_resource_service_proto_msgTypes[7]
+ mi := &file_api_v2_resource_service_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -460,7 +554,7 @@ func (x *DeleteResourceRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use DeleteResourceRequest.ProtoReflect.Descriptor instead.
func (*DeleteResourceRequest) Descriptor() ([]byte, []int) {
- return file_api_v2_resource_service_proto_rawDescGZIP(), []int{7}
+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{9}
}
func (x *DeleteResourceRequest) GetId() int32 {
@@ -479,7 +573,7 @@ type DeleteResourceResponse struct {
func (x *DeleteResourceResponse) Reset() {
*x = DeleteResourceResponse{}
if protoimpl.UnsafeEnabled {
- mi := &file_api_v2_resource_service_proto_msgTypes[8]
+ mi := &file_api_v2_resource_service_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -492,7 +586,7 @@ func (x *DeleteResourceResponse) String() string {
func (*DeleteResourceResponse) ProtoMessage() {}
func (x *DeleteResourceResponse) ProtoReflect() protoreflect.Message {
- mi := &file_api_v2_resource_service_proto_msgTypes[8]
+ mi := &file_api_v2_resource_service_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -505,7 +599,7 @@ func (x *DeleteResourceResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use DeleteResourceResponse.ProtoReflect.Descriptor instead.
func (*DeleteResourceResponse) Descriptor() ([]byte, []int) {
- return file_api_v2_resource_service_proto_rawDescGZIP(), []int{8}
+ return file_api_v2_resource_service_proto_rawDescGZIP(), []int{10}
}
var File_api_v2_resource_service_proto protoreflect.FileDescriptor
@@ -557,71 +651,85 @@ var file_api_v2_resource_service_proto_rawDesc = []byte{
0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52,
0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,
- 0x65, 0x73, 0x22, 0x88, 0x01, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73,
- 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x32, 0x0a, 0x08,
- 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16,
- 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65,
- 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
- 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18,
- 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73,
- 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22, 0x4c, 0x0a,
- 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52,
- 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75,
- 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f,
- 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,
- 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x27, 0x0a, 0x15, 0x44,
- 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71,
- 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
- 0x52, 0x02, 0x69, 0x64, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65,
- 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xa9,
- 0x04, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69,
- 0x63, 0x65, 0x12, 0x76, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f,
+ 0x65, 0x73, 0x22, 0x24, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,
+ 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
+ 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x22, 0x49, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x52,
+ 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
+ 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
+ 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32,
+ 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75,
+ 0x72, 0x63, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65,
+ 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x32, 0x0a,
+ 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
+ 0x16, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52,
+ 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,
+ 0x65, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b,
+ 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61,
+ 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22, 0x4c,
+ 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
+ 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f,
+ 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d,
+ 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72,
+ 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x27, 0x0a, 0x15,
+ 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65,
+ 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
+ 0x05, 0x52, 0x02, 0x69, 0x64, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52,
+ 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32,
+ 0xa2, 0x05, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76,
+ 0x69, 0x63, 0x65, 0x12, 0x76, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73,
+ 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70,
+ 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75,
+ 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, 0x6d,
+ 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
+ 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
+ 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76,
+ 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x73, 0x0a, 0x0d, 0x4c,
+ 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x22, 0x2e, 0x6d,
+ 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74,
+ 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
+ 0x1a, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e,
+ 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73,
+ 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f,
+ 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73,
+ 0x12, 0x77, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12,
+ 0x20, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47,
+ 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
+ 0x74, 0x1a, 0x21, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32,
+ 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70,
+ 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0xda, 0x41, 0x02, 0x69, 0x64, 0x82, 0xd3, 0xe4, 0x93, 0x02,
+ 0x18, 0x12, 0x16, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75,
+ 0x72, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0xa5, 0x01, 0x0a, 0x0e, 0x55, 0x70,
+ 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, 0x2e, 0x6d,
+ 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x64, 0x61,
+ 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
+ 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32,
+ 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52,
+ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x48, 0xda, 0x41, 0x14, 0x72, 0x65, 0x73, 0x6f,
+ 0x75, 0x72, 0x63, 0x65, 0x2c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b,
+ 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2b, 0x3a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
+ 0x32, 0x1f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72,
+ 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x69, 0x64,
+ 0x7d, 0x12, 0x80, 0x01, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f,
0x75, 0x72, 0x63, 0x65, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69,
- 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72,
+ 0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72,
0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f,
- 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52,
+ 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52,
0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
- 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x11, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32,
- 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x73, 0x0a, 0x0d, 0x4c, 0x69,
- 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x22, 0x2e, 0x6d, 0x65,
- 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52,
- 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
- 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c,
- 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70,
- 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x61,
- 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12,
- 0xa5, 0x01, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72,
- 0x63, 0x65, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76,
- 0x32, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
- 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e,
- 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73,
- 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x48, 0xda,
- 0x41, 0x14, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2c, 0x75, 0x70, 0x64, 0x61, 0x74,
- 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2b, 0x3a, 0x08, 0x72, 0x65,
- 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x32, 0x1f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f,
- 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x72, 0x65, 0x73, 0x6f, 0x75,
- 0x72, 0x63, 0x65, 0x2e, 0x69, 0x64, 0x7d, 0x12, 0x80, 0x01, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65,
- 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x23, 0x2e, 0x6d, 0x65, 0x6d,
- 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65,
- 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
- 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x44,
- 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73,
- 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0xda, 0x41, 0x02, 0x69, 0x64, 0x82, 0xd3, 0xe4, 0x93,
- 0x02, 0x18, 0x12, 0x16, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f,
- 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x42, 0xac, 0x01, 0x0a, 0x10, 0x63,
- 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x42,
- 0x14, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
- 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
- 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x65, 0x6d,
- 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69,
- 0x2f, 0x76, 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x4d, 0x41, 0x58, 0xaa,
- 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x32, 0xca, 0x02,
- 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x18,
- 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42,
- 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4d, 0x65, 0x6d, 0x6f, 0x73,
- 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
- 0x33,
+ 0x23, 0xda, 0x41, 0x02, 0x69, 0x64, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x2a, 0x16, 0x2f, 0x61,
+ 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f,
+ 0x7b, 0x69, 0x64, 0x7d, 0x42, 0xac, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d,
+ 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x42, 0x14, 0x52, 0x65, 0x73, 0x6f, 0x75,
+ 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50,
+ 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x73,
+ 0x65, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x72, 0x6f,
+ 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x3b, 0x61, 0x70,
+ 0x69, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x4d, 0x41, 0x58, 0xaa, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f,
+ 0x73, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73,
+ 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x18, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c,
+ 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61,
+ 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a,
+ 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -636,40 +744,45 @@ func file_api_v2_resource_service_proto_rawDescGZIP() []byte {
return file_api_v2_resource_service_proto_rawDescData
}
-var file_api_v2_resource_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
+var file_api_v2_resource_service_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_api_v2_resource_service_proto_goTypes = []interface{}{
(*Resource)(nil), // 0: memos.api.v2.Resource
(*CreateResourceRequest)(nil), // 1: memos.api.v2.CreateResourceRequest
(*CreateResourceResponse)(nil), // 2: memos.api.v2.CreateResourceResponse
(*ListResourcesRequest)(nil), // 3: memos.api.v2.ListResourcesRequest
(*ListResourcesResponse)(nil), // 4: memos.api.v2.ListResourcesResponse
- (*UpdateResourceRequest)(nil), // 5: memos.api.v2.UpdateResourceRequest
- (*UpdateResourceResponse)(nil), // 6: memos.api.v2.UpdateResourceResponse
- (*DeleteResourceRequest)(nil), // 7: memos.api.v2.DeleteResourceRequest
- (*DeleteResourceResponse)(nil), // 8: memos.api.v2.DeleteResourceResponse
- (*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp
- (*fieldmaskpb.FieldMask)(nil), // 10: google.protobuf.FieldMask
+ (*GetResourceRequest)(nil), // 5: memos.api.v2.GetResourceRequest
+ (*GetResourceResponse)(nil), // 6: memos.api.v2.GetResourceResponse
+ (*UpdateResourceRequest)(nil), // 7: memos.api.v2.UpdateResourceRequest
+ (*UpdateResourceResponse)(nil), // 8: memos.api.v2.UpdateResourceResponse
+ (*DeleteResourceRequest)(nil), // 9: memos.api.v2.DeleteResourceRequest
+ (*DeleteResourceResponse)(nil), // 10: memos.api.v2.DeleteResourceResponse
+ (*timestamppb.Timestamp)(nil), // 11: google.protobuf.Timestamp
+ (*fieldmaskpb.FieldMask)(nil), // 12: google.protobuf.FieldMask
}
var file_api_v2_resource_service_proto_depIdxs = []int32{
- 9, // 0: memos.api.v2.Resource.create_time:type_name -> google.protobuf.Timestamp
+ 11, // 0: memos.api.v2.Resource.create_time:type_name -> google.protobuf.Timestamp
0, // 1: memos.api.v2.CreateResourceResponse.resource:type_name -> memos.api.v2.Resource
0, // 2: memos.api.v2.ListResourcesResponse.resources:type_name -> memos.api.v2.Resource
- 0, // 3: memos.api.v2.UpdateResourceRequest.resource:type_name -> memos.api.v2.Resource
- 10, // 4: memos.api.v2.UpdateResourceRequest.update_mask:type_name -> google.protobuf.FieldMask
- 0, // 5: memos.api.v2.UpdateResourceResponse.resource:type_name -> memos.api.v2.Resource
- 1, // 6: memos.api.v2.ResourceService.CreateResource:input_type -> memos.api.v2.CreateResourceRequest
- 3, // 7: memos.api.v2.ResourceService.ListResources:input_type -> memos.api.v2.ListResourcesRequest
- 5, // 8: memos.api.v2.ResourceService.UpdateResource:input_type -> memos.api.v2.UpdateResourceRequest
- 7, // 9: memos.api.v2.ResourceService.DeleteResource:input_type -> memos.api.v2.DeleteResourceRequest
- 2, // 10: memos.api.v2.ResourceService.CreateResource:output_type -> memos.api.v2.CreateResourceResponse
- 4, // 11: memos.api.v2.ResourceService.ListResources:output_type -> memos.api.v2.ListResourcesResponse
- 6, // 12: memos.api.v2.ResourceService.UpdateResource:output_type -> memos.api.v2.UpdateResourceResponse
- 8, // 13: memos.api.v2.ResourceService.DeleteResource:output_type -> memos.api.v2.DeleteResourceResponse
- 10, // [10:14] is the sub-list for method output_type
- 6, // [6:10] is the sub-list for method input_type
- 6, // [6:6] is the sub-list for extension type_name
- 6, // [6:6] is the sub-list for extension extendee
- 0, // [0:6] is the sub-list for field type_name
+ 0, // 3: memos.api.v2.GetResourceResponse.resource:type_name -> memos.api.v2.Resource
+ 0, // 4: memos.api.v2.UpdateResourceRequest.resource:type_name -> memos.api.v2.Resource
+ 12, // 5: memos.api.v2.UpdateResourceRequest.update_mask:type_name -> google.protobuf.FieldMask
+ 0, // 6: memos.api.v2.UpdateResourceResponse.resource:type_name -> memos.api.v2.Resource
+ 1, // 7: memos.api.v2.ResourceService.CreateResource:input_type -> memos.api.v2.CreateResourceRequest
+ 3, // 8: memos.api.v2.ResourceService.ListResources:input_type -> memos.api.v2.ListResourcesRequest
+ 5, // 9: memos.api.v2.ResourceService.GetResource:input_type -> memos.api.v2.GetResourceRequest
+ 7, // 10: memos.api.v2.ResourceService.UpdateResource:input_type -> memos.api.v2.UpdateResourceRequest
+ 9, // 11: memos.api.v2.ResourceService.DeleteResource:input_type -> memos.api.v2.DeleteResourceRequest
+ 2, // 12: memos.api.v2.ResourceService.CreateResource:output_type -> memos.api.v2.CreateResourceResponse
+ 4, // 13: memos.api.v2.ResourceService.ListResources:output_type -> memos.api.v2.ListResourcesResponse
+ 6, // 14: memos.api.v2.ResourceService.GetResource:output_type -> memos.api.v2.GetResourceResponse
+ 8, // 15: memos.api.v2.ResourceService.UpdateResource:output_type -> memos.api.v2.UpdateResourceResponse
+ 10, // 16: memos.api.v2.ResourceService.DeleteResource:output_type -> memos.api.v2.DeleteResourceResponse
+ 12, // [12:17] is the sub-list for method output_type
+ 7, // [7:12] is the sub-list for method input_type
+ 7, // [7:7] is the sub-list for extension type_name
+ 7, // [7:7] is the sub-list for extension extendee
+ 0, // [0:7] is the sub-list for field type_name
}
func init() { file_api_v2_resource_service_proto_init() }
@@ -739,7 +852,7 @@ func file_api_v2_resource_service_proto_init() {
}
}
file_api_v2_resource_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*UpdateResourceRequest); i {
+ switch v := v.(*GetResourceRequest); i {
case 0:
return &v.state
case 1:
@@ -751,7 +864,7 @@ func file_api_v2_resource_service_proto_init() {
}
}
file_api_v2_resource_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*UpdateResourceResponse); i {
+ switch v := v.(*GetResourceResponse); i {
case 0:
return &v.state
case 1:
@@ -763,7 +876,7 @@ func file_api_v2_resource_service_proto_init() {
}
}
file_api_v2_resource_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*DeleteResourceRequest); i {
+ switch v := v.(*UpdateResourceRequest); i {
case 0:
return &v.state
case 1:
@@ -775,6 +888,30 @@ func file_api_v2_resource_service_proto_init() {
}
}
file_api_v2_resource_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*UpdateResourceResponse); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_api_v2_resource_service_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*DeleteResourceRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_api_v2_resource_service_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteResourceResponse); i {
case 0:
return &v.state
@@ -795,7 +932,7 @@ func file_api_v2_resource_service_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_api_v2_resource_service_proto_rawDesc,
NumEnums: 0,
- NumMessages: 9,
+ NumMessages: 11,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/proto/gen/api/v2/resource_service.pb.gw.go b/proto/gen/api/v2/resource_service.pb.gw.go
index 3ca23e2c2..4bfc84fb0 100644
--- a/proto/gen/api/v2/resource_service.pb.gw.go
+++ b/proto/gen/api/v2/resource_service.pb.gw.go
@@ -85,6 +85,58 @@ func local_request_ResourceService_ListResources_0(ctx context.Context, marshale
}
+func request_ResourceService_GetResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetResourceRequest
+ var metadata runtime.ServerMetadata
+
+ var (
+ val string
+ ok bool
+ err error
+ _ = err
+ )
+
+ val, ok = pathParams["id"]
+ if !ok {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
+ }
+
+ protoReq.Id, err = runtime.Int32(val)
+ if err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
+ }
+
+ msg, err := client.GetResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
+ return msg, metadata, err
+
+}
+
+func local_request_ResourceService_GetResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
+ var protoReq GetResourceRequest
+ var metadata runtime.ServerMetadata
+
+ var (
+ val string
+ ok bool
+ err error
+ _ = err
+ )
+
+ val, ok = pathParams["id"]
+ if !ok {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
+ }
+
+ protoReq.Id, err = runtime.Int32(val)
+ if err != nil {
+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
+ }
+
+ msg, err := server.GetResource(ctx, &protoReq)
+ return msg, metadata, err
+
+}
+
var (
filter_ResourceService_UpdateResource_0 = &utilities.DoubleArray{Encoding: map[string]int{"resource": 0, "id": 1}, Base: []int{1, 4, 5, 2, 0, 0, 0, 0}, Check: []int{0, 1, 1, 2, 4, 2, 2, 3}}
)
@@ -293,6 +345,31 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv
})
+ mux.Handle("GET", pattern_ResourceService_GetResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ var stream runtime.ServerTransportStream
+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ var err error
+ var annotatedContext context.Context
+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.ResourceService/GetResource", runtime.WithHTTPPathPattern("/api/v2/resources/{id}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := local_request_ResourceService_GetResource_0(annotatedContext, inboundMarshaler, server, req, pathParams)
+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_ResourceService_GetResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
mux.Handle("PATCH", pattern_ResourceService_UpdateResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -318,7 +395,7 @@ func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.Serv
})
- mux.Handle("GET", pattern_ResourceService_DeleteResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ mux.Handle("DELETE", pattern_ResourceService_DeleteResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
@@ -428,6 +505,28 @@ func RegisterResourceServiceHandlerClient(ctx context.Context, mux *runtime.Serv
})
+ mux.Handle("GET", pattern_ResourceService_GetResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ ctx, cancel := context.WithCancel(req.Context())
+ defer cancel()
+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+ var err error
+ var annotatedContext context.Context
+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.ResourceService/GetResource", runtime.WithHTTPPathPattern("/api/v2/resources/{id}"))
+ if err != nil {
+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
+ return
+ }
+ resp, md, err := request_ResourceService_GetResource_0(annotatedContext, inboundMarshaler, client, req, pathParams)
+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
+ if err != nil {
+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
+ return
+ }
+
+ forward_ResourceService_GetResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
+
+ })
+
mux.Handle("PATCH", pattern_ResourceService_UpdateResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -450,7 +549,7 @@ func RegisterResourceServiceHandlerClient(ctx context.Context, mux *runtime.Serv
})
- mux.Handle("GET", pattern_ResourceService_DeleteResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
+ mux.Handle("DELETE", pattern_ResourceService_DeleteResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
@@ -480,6 +579,8 @@ var (
pattern_ResourceService_ListResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v2", "resources"}, ""))
+ pattern_ResourceService_GetResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "resources", "id"}, ""))
+
pattern_ResourceService_UpdateResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "resources", "resource.id"}, ""))
pattern_ResourceService_DeleteResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v2", "resources", "id"}, ""))
@@ -490,6 +591,8 @@ var (
forward_ResourceService_ListResources_0 = runtime.ForwardResponseMessage
+ forward_ResourceService_GetResource_0 = runtime.ForwardResponseMessage
+
forward_ResourceService_UpdateResource_0 = runtime.ForwardResponseMessage
forward_ResourceService_DeleteResource_0 = runtime.ForwardResponseMessage
diff --git a/proto/gen/api/v2/resource_service_grpc.pb.go b/proto/gen/api/v2/resource_service_grpc.pb.go
index dbaf4a0a6..5f7f6a58e 100644
--- a/proto/gen/api/v2/resource_service_grpc.pb.go
+++ b/proto/gen/api/v2/resource_service_grpc.pb.go
@@ -21,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion7
const (
ResourceService_CreateResource_FullMethodName = "/memos.api.v2.ResourceService/CreateResource"
ResourceService_ListResources_FullMethodName = "/memos.api.v2.ResourceService/ListResources"
+ ResourceService_GetResource_FullMethodName = "/memos.api.v2.ResourceService/GetResource"
ResourceService_UpdateResource_FullMethodName = "/memos.api.v2.ResourceService/UpdateResource"
ResourceService_DeleteResource_FullMethodName = "/memos.api.v2.ResourceService/DeleteResource"
)
@@ -31,6 +32,7 @@ const (
type ResourceServiceClient interface {
CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...grpc.CallOption) (*CreateResourceResponse, error)
ListResources(ctx context.Context, in *ListResourcesRequest, opts ...grpc.CallOption) (*ListResourcesResponse, error)
+ GetResource(ctx context.Context, in *GetResourceRequest, opts ...grpc.CallOption) (*GetResourceResponse, error)
UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...grpc.CallOption) (*UpdateResourceResponse, error)
DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...grpc.CallOption) (*DeleteResourceResponse, error)
}
@@ -61,6 +63,15 @@ func (c *resourceServiceClient) ListResources(ctx context.Context, in *ListResou
return out, nil
}
+func (c *resourceServiceClient) GetResource(ctx context.Context, in *GetResourceRequest, opts ...grpc.CallOption) (*GetResourceResponse, error) {
+ out := new(GetResourceResponse)
+ err := c.cc.Invoke(ctx, ResourceService_GetResource_FullMethodName, in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
func (c *resourceServiceClient) UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...grpc.CallOption) (*UpdateResourceResponse, error) {
out := new(UpdateResourceResponse)
err := c.cc.Invoke(ctx, ResourceService_UpdateResource_FullMethodName, in, out, opts...)
@@ -85,6 +96,7 @@ func (c *resourceServiceClient) DeleteResource(ctx context.Context, in *DeleteRe
type ResourceServiceServer interface {
CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error)
ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error)
+ GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error)
UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error)
DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error)
mustEmbedUnimplementedResourceServiceServer()
@@ -100,6 +112,9 @@ func (UnimplementedResourceServiceServer) CreateResource(context.Context, *Creat
func (UnimplementedResourceServiceServer) ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListResources not implemented")
}
+func (UnimplementedResourceServiceServer) GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method GetResource not implemented")
+}
func (UnimplementedResourceServiceServer) UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateResource not implemented")
}
@@ -155,6 +170,24 @@ func _ResourceService_ListResources_Handler(srv interface{}, ctx context.Context
return interceptor(ctx, in, info, handler)
}
+func _ResourceService_GetResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(GetResourceRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(ResourceServiceServer).GetResource(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: ResourceService_GetResource_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(ResourceServiceServer).GetResource(ctx, req.(*GetResourceRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
func _ResourceService_UpdateResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateResourceRequest)
if err := dec(in); err != nil {
@@ -206,6 +239,10 @@ var ResourceService_ServiceDesc = grpc.ServiceDesc{
MethodName: "ListResources",
Handler: _ResourceService_ListResources_Handler,
},
+ {
+ MethodName: "GetResource",
+ Handler: _ResourceService_GetResource_Handler,
+ },
{
MethodName: "UpdateResource",
Handler: _ResourceService_UpdateResource_Handler,
diff --git a/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx b/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx
index 47a600e10..579d2cf41 100644
--- a/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx
+++ b/web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx
@@ -2,6 +2,7 @@ import { useContext, useEffect } from "react";
import { useMemoStore } from "@/store/v1";
import MemoContent from "..";
import { RendererContext } from "../types";
+import Error from "./Error";
interface Props {
memoId: number;
@@ -17,16 +18,16 @@ const EmbeddedMemo = ({ memoId }: Props) => {
memoStore.getOrFetchMemoById(memoId);
}, [memoId]);
+ if (!memo) {
+ return null;
+ }
if (memoId === context.memoId || context.embeddedMemos.has(resourceName)) {
- return <p>Nested Rendering Error: {`![[${resourceName}]]`}</p>;
+ return <Error message={`Nested Rendering Error: ![[${resourceName}]]`} />;
}
- context.embeddedMemos.add(resourceName);
- return (
- <div className="embedded-memo">
- <MemoContent nodes={memo.nodes} memoId={memoId} embeddedMemos={context.embeddedMemos} />
- </div>
- );
+ // Add the memo to the set of embedded memos. This is used to prevent infinite loops when a memo embeds itself.
+ context.embeddedMemos.add(resourceName);
+ return <MemoContent nodes={memo.nodes} memoId={memoId} embeddedMemos={context.embeddedMemos} />;
};
export default EmbeddedMemo;
diff --git a/web/src/components/MemoContent/EmbeddedContent/EmbeddedResource.tsx b/web/src/components/MemoContent/EmbeddedContent/EmbeddedResource.tsx
new file mode 100644
index 000000000..6e42f60c8
--- /dev/null
+++ b/web/src/components/MemoContent/EmbeddedContent/EmbeddedResource.tsx
@@ -0,0 +1,24 @@
+import { useEffect } from "react";
+import MemoResourceListView from "@/components/MemoResourceListView";
+import { useResourceStore } from "@/store/v1";
+
+interface Props {
+ resourceId: number;
+}
+
+const EmbeddedResource = ({ resourceId }: Props) => {
+ const resourceStore = useResourceStore();
+ const resource = resourceStore.getResourceById(resourceId);
+
+ useEffect(() => {
+ resourceStore.getOrFetchResourceById(resourceId);
+ }, [resourceId]);
+
+ if (!resource) {
+ return null;
+ }
+
+ return <MemoResourceListView resources={[resource]} />;
+};
+
+export default EmbeddedResource;
diff --git a/web/src/components/MemoContent/EmbeddedContent/Error.tsx b/web/src/components/MemoContent/EmbeddedContent/Error.tsx
new file mode 100644
index 000000000..844f3bae6
--- /dev/null
+++ b/web/src/components/MemoContent/EmbeddedContent/Error.tsx
@@ -0,0 +1,9 @@
+interface Props {
+ message: string;
+}
+
+const Error = ({ message }: Props) => {
+ return <p className="font-mono text-sm text-red-600 dark:text-red-700">{message}</p>;
+};
+
+export default Error;
diff --git a/web/src/components/MemoContent/EmbeddedContent/index.tsx b/web/src/components/MemoContent/EmbeddedContent/index.tsx
index bcaaa05c8..7cb2ce67b 100644
--- a/web/src/components/MemoContent/EmbeddedContent/index.tsx
+++ b/web/src/components/MemoContent/EmbeddedContent/index.tsx
@@ -1,4 +1,6 @@
import EmbeddedMemo from "./EmbeddedMemo";
+import EmbeddedResource from "./EmbeddedResource";
+import Error from "./Error";
interface Props {
resourceName: string;
@@ -13,8 +15,10 @@ const EmbeddedContent = ({ resourceName }: Props) => {
const { resourceType, resourceId } = extractResourceTypeAndId(resourceName);
if (resourceType === "memos") {
return <EmbeddedMemo memoId={Number(resourceId)} />;
+ } else if (resourceType === "resources") {
+ return <EmbeddedResource resourceId={Number(resourceId)} />;
}
- return <p>Unknown resource: {resourceName}</p>;
+ return <Error message={`Unknown resource: ${resourceName}`} />;
};
export default EmbeddedContent;
diff --git a/web/src/components/MemoContent/index.tsx b/web/src/components/MemoContent/index.tsx
index 30756d583..170ae1708 100644
--- a/web/src/components/MemoContent/index.tsx
+++ b/web/src/components/MemoContent/index.tsx
@@ -1,4 +1,4 @@
-import { useRef } from "react";
+import { memo, useRef } from "react";
import useCurrentUser from "@/hooks/useCurrentUser";
import { useMemoStore } from "@/store/v1";
import { Node, NodeType } from "@/types/proto/api/v2/markdown_service";
@@ -65,4 +65,4 @@ const MemoContent: React.FC<Props> = (props: Props) => {
);
};
-export default MemoContent;
+export default memo(MemoContent);
diff --git a/web/src/components/MemoRelationListView.tsx b/web/src/components/MemoRelationListView.tsx
index 242310681..64218afb1 100644
--- a/web/src/components/MemoRelationListView.tsx
+++ b/web/src/components/MemoRelationListView.tsx
@@ -1,5 +1,5 @@
import { Tooltip } from "@mui/joy";
-import { useEffect, useState } from "react";
+import { memo, useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { useMemoStore } from "@/store/v1";
import { MemoRelation } from "@/types/proto/api/v2/memo_relation_service";
@@ -82,4 +82,4 @@ const MemoRelationListView = (props: Props) => {
);
};
-export default MemoRelationListView;
+export default memo(MemoRelationListView);
diff --git a/web/src/components/MemoResourceListView.tsx b/web/src/components/MemoResourceListView.tsx
index c2791b510..e7c65fab7 100644
--- a/web/src/components/MemoResourceListView.tsx
+++ b/web/src/components/MemoResourceListView.tsx
@@ -6,11 +6,11 @@ import MemoResource from "./MemoResource";
import showPreviewImageDialog from "./PreviewImageDialog";
import SquareDiv from "./kit/SquareDiv";
-const MemoResourceListView = ({ resourceList = [] }: { resourceList: Resource[] }) => {
+const MemoResourceListView = ({ resources = [] }: { resources: Resource[] }) => {
const mediaResources: Resource[] = [];
const otherResources: Resource[] = [];
- resourceList.forEach((resource) => {
+ resources.forEach((resource) => {
const type = getResourceType(resource);
if (type === "image/*" || type === "video/*") {
mediaResources.push(resource);
diff --git a/web/src/components/MemoView.tsx b/web/src/components/MemoView.tsx
index c0500fd0e..d13797476 100644
--- a/web/src/components/MemoView.tsx
+++ b/web/src/components/MemoView.tsx
@@ -1,7 +1,7 @@
import { Divider, Tooltip } from "@mui/joy";
import classNames from "classnames";
import copy from "copy-to-clipboard";
-import { memo, useEffect, useRef, useState } from "react";
+import { memo, useCallback, useEffect, useRef, useState } from "react";
import { toast } from "react-hot-toast";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
@@ -153,7 +153,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
toast.success("Copied to clipboard!");
};
- const handleMemoContentClick = async (e: React.MouseEvent) => {
+ const handleMemoContentClick = useCallback(async (e: React.MouseEvent) => {
const targetEl = e.target as HTMLElement;
if (targetEl.tagName === "IMG") {
@@ -162,7 +162,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
showPreviewImageDialog([imgUrl], 0);
}
}
- };
+ }, []);
return (
<div
@@ -257,7 +257,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
</div>
</div>
<MemoContent memoId={memo.id} nodes={memo.nodes} readonly={readonly} onClick={handleMemoContentClick} />
- <MemoResourceListView resourceList={memo.resources} />
+ <MemoResourceListView resources={memo.resources} />
<MemoRelationListView memo={memo} relationList={referenceRelations} />
</div>
);
diff --git a/web/src/components/ShareMemoDialog.tsx b/web/src/components/ShareMemoDialog.tsx
index 55c249ae5..3c21d7976 100644
--- a/web/src/components/ShareMemoDialog.tsx
+++ b/web/src/components/ShareMemoDialog.tsx
@@ -113,7 +113,7 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
<span className="w-full px-6 pt-5 pb-2 text-sm text-gray-500">{getDateTimeString(memo.displayTime)}</span>
<div className="w-full px-6 text-base pb-4">
<MemoContent memoId={memo.id} nodes={memo.nodes} readonly={true} disableFilter />
- <MemoResourceListView resourceList={memo.resources} />
+ <MemoResourceListView resources={memo.resources} />
</div>
<div className="flex flex-row justify-between items-center w-full bg-gray-100 dark:bg-zinc-900 py-4 px-6">
<div className="flex flex-row justify-start items-center">
diff --git a/web/src/pages/MemoDetail.tsx b/web/src/pages/MemoDetail.tsx
index b38ee6e74..a7a0d1fb7 100644
--- a/web/src/pages/MemoDetail.tsx
+++ b/web/src/pages/MemoDetail.tsx
@@ -137,7 +137,7 @@ const MemoDetail = () => {
</div>
)}
<MemoContent memoId={memo.id} nodes={memo.nodes} readonly={readonly} />
- <MemoResourceListView resourceList={memo.resources} />
+ <MemoResourceListView resources={memo.resources} />
<MemoRelationListView memo={memo} relationList={referenceRelations} />
<div className="w-full mt-3 flex flex-row justify-between items-center gap-2">
<div className="flex flex-row justify-start items-center">
diff --git a/web/src/store/v1/index.ts b/web/src/store/v1/index.ts
index 276ba9765..d03e06b31 100644
--- a/web/src/store/v1/index.ts
+++ b/web/src/store/v1/index.ts
@@ -2,3 +2,4 @@ export * from "./user";
export * from "./memo";
export * from "./inbox";
export * from "./resourceName";
+export * from "./resource";
diff --git a/web/src/store/v1/resource.ts b/web/src/store/v1/resource.ts
new file mode 100644
index 000000000..257e93232
--- /dev/null
+++ b/web/src/store/v1/resource.ts
@@ -0,0 +1,42 @@
+import { create } from "zustand";
+import { combine } from "zustand/middleware";
+import { resourceServiceClient } from "@/grpcweb";
+import { Resource } from "@/types/proto/api/v2/resource_service";
+
+interface State {
+ resourceMapById: Record<number, Resource>;
+}
+
+const getDefaultState = (): State => ({
+ resourceMapById: {},
+});
+
+export const useResourceStore = create(
+ combine(getDefaultState(), (set, get) => ({
+ setState: (state: State) => set(state),
+ getState: () => get(),
+ getOrFetchResourceById: async (id: number, options?: { skipCache?: boolean; skipStore?: boolean }) => {
+ const resourceMap = get().resourceMapById;
+ const resource = resourceMap[id];
+ if (resource && !options?.skipCache) {
+ return resource;
+ }
+
+ const res = await resourceServiceClient.getResource({
+ id,
+ });
+ if (!res.resource) {
+ throw new Error("Resource not found");
+ }
+
+ if (!options?.skipStore) {
+ resourceMap[id] = res.resource;
+ set({ resourceMapById: resourceMap });
+ }
+ return res.resource;
+ },
+ getResourceById: (id: number) => {
+ return get().resourceMapById[id];
+ },
+ }))
+);