Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
0a429a89
Commit
0a429a89
authored
Feb 09, 2025
by
Johnny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: remove version update activity
parent
983323ce
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
87 additions
and
488 deletions
+87
-488
activity_service.proto
proto/api/v1/activity_service.proto
+0
-6
activity_service.pb.go
proto/gen/api/v1/activity_service.pb.go
+55
-119
apidocs.swagger.yaml
proto/gen/apidocs.swagger.yaml
+0
-8
activity.pb.go
proto/gen/store/activity.pb.go
+31
-94
activity.proto
proto/store/activity.proto
+0
-5
activity_service.go
server/router/api/v1/activity_service.go
+0
-5
runner.go
server/runner/version/runner.go
+0
-140
runner_test.go
server/runner/version/runner_test.go
+0
-1
server.go
server/server.go
+0
-4
activity.go
store/activity.go
+1
-2
VersionUpdateMessage.tsx
web/src/components/Inbox/VersionUpdateMessage.tsx
+0
-101
Inboxes.tsx
web/src/pages/Inboxes.tsx
+0
-3
No files found.
proto/api/v1/activity_service.proto
View file @
0a429a89
...
...
@@ -36,7 +36,6 @@ message Activity {
message
ActivityPayload
{
ActivityMemoCommentPayload
memo_comment
=
1
;
ActivityVersionUpdatePayload
version_update
=
2
;
}
// ActivityMemoCommentPayload represents the payload of a memo comment activity.
...
...
@@ -48,11 +47,6 @@ message ActivityMemoCommentPayload {
string
related_memo
=
2
;
}
message
ActivityVersionUpdatePayload
{
// The updated version of memos.
string
version
=
1
;
}
message
GetActivityRequest
{
// The name of the activity.
// Format: activities/{id}, id is the system generated auto-incremented id.
...
...
proto/gen/api/v1/activity_service.pb.go
View file @
0a429a89
This diff is collapsed.
Click to expand it.
proto/gen/apidocs.swagger.yaml
View file @
0a429a89
...
...
@@ -2092,14 +2092,6 @@ definitions:
properties
:
memoComment
:
$ref
:
'
#/definitions/apiv1ActivityMemoCommentPayload'
versionUpdate
:
$ref
:
'
#/definitions/apiv1ActivityVersionUpdatePayload'
apiv1ActivityVersionUpdatePayload
:
type
:
object
properties
:
version
:
type
:
string
description
:
The updated version of memos.
apiv1FieldMapping
:
type
:
object
properties
:
...
...
proto/gen/store/activity.pb.go
View file @
0a429a89
...
...
@@ -73,61 +73,16 @@ func (x *ActivityMemoCommentPayload) GetRelatedMemoId() int32 {
return
0
}
type
ActivityVersionUpdatePayload
struct
{
state
protoimpl
.
MessageState
`protogen:"open.v1"`
Version
string
`protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
unknownFields
protoimpl
.
UnknownFields
sizeCache
protoimpl
.
SizeCache
}
func
(
x
*
ActivityVersionUpdatePayload
)
Reset
()
{
*
x
=
ActivityVersionUpdatePayload
{}
mi
:=
&
file_store_activity_proto_msgTypes
[
1
]
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
ms
.
StoreMessageInfo
(
mi
)
}
func
(
x
*
ActivityVersionUpdatePayload
)
String
()
string
{
return
protoimpl
.
X
.
MessageStringOf
(
x
)
}
func
(
*
ActivityVersionUpdatePayload
)
ProtoMessage
()
{}
func
(
x
*
ActivityVersionUpdatePayload
)
ProtoReflect
()
protoreflect
.
Message
{
mi
:=
&
file_store_activity_proto_msgTypes
[
1
]
if
x
!=
nil
{
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
if
ms
.
LoadMessageInfo
()
==
nil
{
ms
.
StoreMessageInfo
(
mi
)
}
return
ms
}
return
mi
.
MessageOf
(
x
)
}
// Deprecated: Use ActivityVersionUpdatePayload.ProtoReflect.Descriptor instead.
func
(
*
ActivityVersionUpdatePayload
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
file_store_activity_proto_rawDescGZIP
(),
[]
int
{
1
}
}
func
(
x
*
ActivityVersionUpdatePayload
)
GetVersion
()
string
{
if
x
!=
nil
{
return
x
.
Version
}
return
""
}
type
ActivityPayload
struct
{
state
protoimpl
.
MessageState
`protogen:"open.v1"`
MemoComment
*
ActivityMemoCommentPayload
`protobuf:"bytes,1,opt,name=memo_comment,json=memoComment,proto3" json:"memo_comment,omitempty"`
VersionUpdate
*
ActivityVersionUpdatePayload
`protobuf:"bytes,2,opt,name=version_update,json=versionUpdate,proto3" json:"version_update,omitempty"`
unknownFields
protoimpl
.
UnknownFields
sizeCache
protoimpl
.
SizeCache
}
func
(
x
*
ActivityPayload
)
Reset
()
{
*
x
=
ActivityPayload
{}
mi
:=
&
file_store_activity_proto_msgTypes
[
2
]
mi
:=
&
file_store_activity_proto_msgTypes
[
1
]
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
ms
.
StoreMessageInfo
(
mi
)
}
...
...
@@ -139,7 +94,7 @@ func (x *ActivityPayload) String() string {
func
(
*
ActivityPayload
)
ProtoMessage
()
{}
func
(
x
*
ActivityPayload
)
ProtoReflect
()
protoreflect
.
Message
{
mi
:=
&
file_store_activity_proto_msgTypes
[
2
]
mi
:=
&
file_store_activity_proto_msgTypes
[
1
]
if
x
!=
nil
{
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
if
ms
.
LoadMessageInfo
()
==
nil
{
...
...
@@ -152,7 +107,7 @@ func (x *ActivityPayload) ProtoReflect() protoreflect.Message {
// Deprecated: Use ActivityPayload.ProtoReflect.Descriptor instead.
func
(
*
ActivityPayload
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
file_store_activity_proto_rawDescGZIP
(),
[]
int
{
2
}
return
file_store_activity_proto_rawDescGZIP
(),
[]
int
{
1
}
}
func
(
x
*
ActivityPayload
)
GetMemoComment
()
*
ActivityMemoCommentPayload
{
...
...
@@ -162,13 +117,6 @@ func (x *ActivityPayload) GetMemoComment() *ActivityMemoCommentPayload {
return
nil
}
func
(
x
*
ActivityPayload
)
GetVersionUpdate
()
*
ActivityVersionUpdatePayload
{
if
x
!=
nil
{
return
x
.
VersionUpdate
}
return
nil
}
var
File_store_activity_proto
protoreflect
.
FileDescriptor
var
file_store_activity_proto_rawDesc
=
string
([]
byte
{
...
...
@@ -180,32 +128,23 @@ var file_store_activity_proto_rawDesc = string([]byte{
0x28
,
0x05
,
0x52
,
0x06
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x49
,
0x64
,
0x12
,
0x26
,
0x0a
,
0x0f
,
0x72
,
0x65
,
0x6c
,
0x61
,
0x74
,
0x65
,
0x64
,
0x5f
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x5f
,
0x69
,
0x64
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x05
,
0x52
,
0x0d
,
0x72
,
0x65
,
0x6c
,
0x61
,
0x74
,
0x65
,
0x64
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x49
,
0x64
,
0x22
,
0x38
,
0x0a
,
0x1c
,
0x41
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x56
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x55
,
0x70
,
0x64
,
0x61
,
0x74
,
0x65
,
0x50
,
0x61
,
0x79
,
0x6c
,
0x6f
,
0x61
,
0x64
,
0x12
,
0x18
,
0x0a
,
0x07
,
0x76
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x07
,
0x76
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x22
,
0xaf
,
0x01
,
0x0a
,
0x0f
,
0x41
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x50
,
0x61
,
0x79
,
0x6c
,
0x6f
,
0x61
,
0x64
,
0x12
,
0x4a
,
0x0a
,
0x0c
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x5f
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x65
,
0x6e
,
0x74
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x0b
,
0x32
,
0x27
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x2e
,
0x41
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x43
,
0x6f
,
0x6d
,
0x6d
,
0x65
,
0x6e
,
0x74
,
0x50
,
0x61
,
0x79
,
0x6c
,
0x6f
,
0x61
,
0x64
,
0x52
,
0x0b
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x43
,
0x6f
,
0x6d
,
0x6d
,
0x65
,
0x6e
,
0x74
,
0x12
,
0x50
,
0x0a
,
0x0e
,
0x76
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x5f
,
0x75
,
0x70
,
0x64
,
0x61
,
0x74
,
0x65
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x0b
,
0x32
,
0x29
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x2e
,
0x41
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x56
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x55
,
0x70
,
0x64
,
0x61
,
0x74
,
0x65
,
0x50
,
0x61
,
0x79
,
0x6c
,
0x6f
,
0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x62
,
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
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xa2
,
0x02
,
0x03
,
0x4d
,
0x53
,
0x58
,
0xaa
,
0x02
,
0x0b
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xca
,
0x02
,
0x0b
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xe2
,
0x02
,
0x17
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x5c
,
0x47
,
0x50
,
0x42
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0xea
,
0x02
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x3a
,
0x3a
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
})
var
(
...
...
@@ -220,20 +159,18 @@ func file_store_activity_proto_rawDescGZIP() []byte {
return
file_store_activity_proto_rawDescData
}
var
file_store_activity_proto_msgTypes
=
make
([]
protoimpl
.
MessageInfo
,
3
)
var
file_store_activity_proto_msgTypes
=
make
([]
protoimpl
.
MessageInfo
,
2
)
var
file_store_activity_proto_goTypes
=
[]
any
{
(
*
ActivityMemoCommentPayload
)(
nil
),
// 0: memos.store.ActivityMemoCommentPayload
(
*
ActivityVersionUpdatePayload
)(
nil
),
// 1: memos.store.ActivityVersionUpdatePayload
(
*
ActivityPayload
)(
nil
),
// 2: memos.store.ActivityPayload
(
*
ActivityPayload
)(
nil
),
// 1: memos.store.ActivityPayload
}
var
file_store_activity_proto_depIdxs
=
[]
int32
{
0
,
// 0: memos.store.ActivityPayload.memo_comment:type_name -> memos.store.ActivityMemoCommentPayload
1
,
// 1: memos.store.ActivityPayload.version_update:type_name -> memos.store.ActivityVersionUpdatePayload
2
,
// [2:2] is the sub-list for method output_type
2
,
// [2:2] is the sub-list for method input_type
2
,
// [2:2] is the sub-list for extension type_name
2
,
// [2:2] is the sub-list for extension extendee
0
,
// [0:2] is the sub-list for field type_name
1
,
// [1:1] is the sub-list for method output_type
1
,
// [1:1] is the sub-list for method input_type
1
,
// [1:1] is the sub-list for extension type_name
1
,
// [1:1] is the sub-list for extension extendee
0
,
// [0:1] is the sub-list for field type_name
}
func
init
()
{
file_store_activity_proto_init
()
}
...
...
@@ -247,7 +184,7 @@ func file_store_activity_proto_init() {
GoPackagePath
:
reflect
.
TypeOf
(
x
{})
.
PkgPath
(),
RawDescriptor
:
unsafe
.
Slice
(
unsafe
.
StringData
(
file_store_activity_proto_rawDesc
),
len
(
file_store_activity_proto_rawDesc
)),
NumEnums
:
0
,
NumMessages
:
3
,
NumMessages
:
2
,
NumExtensions
:
0
,
NumServices
:
0
,
},
...
...
proto/store/activity.proto
View file @
0a429a89
...
...
@@ -9,11 +9,6 @@ message ActivityMemoCommentPayload {
int32
related_memo_id
=
2
;
}
message
ActivityVersionUpdatePayload
{
string
version
=
1
;
}
message
ActivityPayload
{
ActivityMemoCommentPayload
memo_comment
=
1
;
ActivityVersionUpdatePayload
version_update
=
2
;
}
server/router/api/v1/activity_service.go
View file @
0a429a89
...
...
@@ -70,10 +70,5 @@ func (s *APIV1Service) convertActivityPayloadFromStore(ctx context.Context, payl
RelatedMemo
:
fmt
.
Sprintf
(
"%s%s"
,
MemoNamePrefix
,
relatedMemo
.
UID
),
}
}
if
payload
.
VersionUpdate
!=
nil
{
v2Payload
.
VersionUpdate
=
&
v1pb
.
ActivityVersionUpdatePayload
{
Version
:
payload
.
VersionUpdate
.
Version
,
}
}
return
v2Payload
,
nil
}
server/runner/version/runner.go
deleted
100644 → 0
View file @
983323ce
// Package version provides a runner to check the latest version of the application.
package
version
import
(
"bytes"
"context"
"encoding/json"
"net/http"
"time"
"github.com/pkg/errors"
"golang.org/x/exp/slog"
storepb
"github.com/usememos/memos/proto/gen/store"
"github.com/usememos/memos/server/profile"
"github.com/usememos/memos/server/version"
"github.com/usememos/memos/store"
)
type
Runner
struct
{
Store
*
store
.
Store
Profile
*
profile
.
Profile
}
func
NewRunner
(
store
*
store
.
Store
,
profile
*
profile
.
Profile
)
*
Runner
{
return
&
Runner
{
Store
:
store
,
Profile
:
profile
,
}
}
// Schedule checker every 8 hours.
const
runnerInterval
=
time
.
Hour
*
8
func
(
r
*
Runner
)
Run
(
ctx
context
.
Context
)
{
ticker
:=
time
.
NewTicker
(
runnerInterval
)
defer
ticker
.
Stop
()
for
{
select
{
case
<-
ticker
.
C
:
r
.
RunOnce
(
ctx
)
case
<-
ctx
.
Done
()
:
return
}
}
}
func
(
r
*
Runner
)
RunOnce
(
ctx
context
.
Context
)
{
r
.
Check
(
ctx
)
}
func
(
r
*
Runner
)
Check
(
ctx
context
.
Context
)
{
latestVersion
,
err
:=
r
.
GetLatestVersion
()
if
err
!=
nil
{
return
}
if
!
version
.
IsVersionGreaterThan
(
latestVersion
,
version
.
GetCurrentVersion
(
r
.
Profile
.
Mode
))
{
return
}
versionUpdateActivityType
:=
store
.
ActivityTypeVersionUpdate
list
,
err
:=
r
.
Store
.
ListActivities
(
ctx
,
&
store
.
FindActivity
{
Type
:
&
versionUpdateActivityType
,
})
if
err
!=
nil
{
return
}
shouldNotify
:=
true
if
len
(
list
)
>
0
{
latestVersionUpdateActivity
:=
list
[
0
]
if
latestVersionUpdateActivity
.
Payload
!=
nil
&&
version
.
IsVersionGreaterOrEqualThan
(
latestVersionUpdateActivity
.
Payload
.
VersionUpdate
.
Version
,
latestVersion
)
{
shouldNotify
=
false
}
}
if
!
shouldNotify
{
return
}
// Create version update activity and inbox message.
activity
:=
&
store
.
Activity
{
CreatorID
:
store
.
SystemBotID
,
Type
:
store
.
ActivityTypeVersionUpdate
,
Level
:
store
.
ActivityLevelInfo
,
Payload
:
&
storepb
.
ActivityPayload
{
VersionUpdate
:
&
storepb
.
ActivityVersionUpdatePayload
{
Version
:
latestVersion
,
},
},
}
if
_
,
err
:=
r
.
Store
.
CreateActivity
(
ctx
,
activity
);
err
!=
nil
{
return
}
hostUserRole
:=
store
.
RoleHost
users
,
err
:=
r
.
Store
.
ListUsers
(
ctx
,
&
store
.
FindUser
{
Role
:
&
hostUserRole
,
})
if
err
!=
nil
{
return
}
if
len
(
users
)
==
0
{
return
}
hostUser
:=
users
[
0
]
if
_
,
err
:=
r
.
Store
.
CreateInbox
(
ctx
,
&
store
.
Inbox
{
SenderID
:
store
.
SystemBotID
,
ReceiverID
:
hostUser
.
ID
,
Status
:
store
.
UNREAD
,
Message
:
&
storepb
.
InboxMessage
{
Type
:
storepb
.
InboxMessage_VERSION_UPDATE
,
ActivityId
:
&
activity
.
ID
,
},
});
err
!=
nil
{
slog
.
Error
(
"failed to create inbox"
,
slog
.
String
(
"error"
,
err
.
Error
()))
}
}
func
(
*
Runner
)
GetLatestVersion
()
(
string
,
error
)
{
response
,
err
:=
http
.
Get
(
"https://www.usememos.com/api/version"
)
if
err
!=
nil
{
return
""
,
errors
.
Wrap
(
err
,
"failed to make http request"
)
}
defer
response
.
Body
.
Close
()
buf
:=
&
bytes
.
Buffer
{}
_
,
err
=
buf
.
ReadFrom
(
response
.
Body
)
if
err
!=
nil
{
return
""
,
errors
.
Wrap
(
err
,
"fail to read response body"
)
}
version
:=
""
if
err
=
json
.
Unmarshal
(
buf
.
Bytes
(),
&
version
);
err
!=
nil
{
return
""
,
errors
.
Wrap
(
err
,
"fail to unmarshal get version response"
)
}
return
version
,
nil
}
server/runner/version/runner_test.go
deleted
100644 → 0
View file @
983323ce
package
version
server/server.go
View file @
0a429a89
...
...
@@ -24,7 +24,6 @@ import (
"github.com/usememos/memos/server/router/rss"
"github.com/usememos/memos/server/runner/memopayload"
"github.com/usememos/memos/server/runner/s3presign"
"github.com/usememos/memos/server/runner/version"
"github.com/usememos/memos/store"
)
...
...
@@ -144,14 +143,11 @@ func (s *Server) Shutdown(ctx context.Context) {
func
(
s
*
Server
)
StartBackgroundRunners
(
ctx
context
.
Context
)
{
s3presignRunner
:=
s3presign
.
NewRunner
(
s
.
Store
)
s3presignRunner
.
RunOnce
(
ctx
)
versionRunner
:=
version
.
NewRunner
(
s
.
Store
,
s
.
Profile
)
versionRunner
.
RunOnce
(
ctx
)
memopayloadRunner
:=
memopayload
.
NewRunner
(
s
.
Store
)
// Rebuild all memos' payload after server starts.
memopayloadRunner
.
RunOnce
(
ctx
)
go
s3presignRunner
.
Run
(
ctx
)
go
versionRunner
.
Run
(
ctx
)
}
func
(
s
*
Server
)
getOrUpsertWorkspaceBasicSetting
(
ctx
context
.
Context
)
(
*
storepb
.
WorkspaceBasicSetting
,
error
)
{
...
...
store/activity.go
View file @
0a429a89
...
...
@@ -10,7 +10,6 @@ type ActivityType string
const
(
ActivityTypeMemoComment
ActivityType
=
"MEMO_COMMENT"
ActivityTypeVersionUpdate
ActivityType
=
"VERSION_UPDATE"
)
func
(
t
ActivityType
)
String
()
string
{
...
...
web/src/components/Inbox/VersionUpdateMessage.tsx
deleted
100644 → 0
View file @
983323ce
import
{
Tooltip
}
from
"@mui/joy"
;
import
{
ArrowUpIcon
,
InboxIcon
}
from
"lucide-react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
toast
from
"react-hot-toast"
;
import
{
activityServiceClient
}
from
"@/grpcweb"
;
import
{
activityNamePrefix
}
from
"@/store/v1"
;
import
{
userStore
}
from
"@/store/v2"
;
import
{
Activity
}
from
"@/types/proto/api/v1/activity_service"
;
import
{
Inbox
,
Inbox_Status
}
from
"@/types/proto/api/v1/inbox_service"
;
import
{
cn
}
from
"@/utils"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
interface
Props
{
inbox
:
Inbox
;
}
const
VersionUpdateMessage
=
({
inbox
}:
Props
)
=>
{
const
t
=
useTranslate
();
const
[
activity
,
setActivity
]
=
useState
<
Activity
|
undefined
>
(
undefined
);
useEffect
(()
=>
{
if
(
!
inbox
.
activityId
)
{
return
;
}
(
async
()
=>
{
const
activity
=
await
activityServiceClient
.
getActivity
({
name
:
`
${
activityNamePrefix
}${
inbox
.
activityId
}
`
,
});
setActivity
(
activity
);
})();
},
[
inbox
.
activityId
]);
const
handleNavigate
=
()
=>
{
if
(
!
activity
?.
payload
?.
versionUpdate
?.
version
)
{
return
;
}
window
.
open
(
`https://github.com/usememos/memos/releases/tag/v
${
activity
?.
payload
?.
versionUpdate
?.
version
}
`);
if (inbox.status === Inbox_Status.UNREAD) {
handleArchiveMessage(true);
}
};
const handleArchiveMessage = async (silence = false) => {
await userStore.updateInbox(
{
name: inbox.name,
status: Inbox_Status.ARCHIVED,
},
["status"],
);
if (!silence) {
toast.success(t("message.archived-successfully"));
}
};
return (
<div className="w-full flex flex-row justify-start items-start gap-3">
<div
className={cn(
"shrink-0 mt-2 p-2 rounded-full border",
inbox.status === Inbox_Status.UNREAD
? "border-blue-600 text-blue-600 bg-blue-50 dark:bg-zinc-800"
: "border-gray-500 text-gray-500 bg-gray-50 dark:bg-zinc-800",
)}
>
<Tooltip title={"Update"} placement="bottom">
<ArrowUpIcon className="w-4 sm:w-5 h-auto" />
</Tooltip>
</div>
<div
className={cn(
"border w-full p-2 px-3 rounded-lg flex flex-col justify-start items-start gap-1 dark:border-zinc-700 hover:bg-gray-100 dark:hover:bg-zinc-700",
inbox.status !== Inbox_Status.UNREAD && "opacity-60",
)}
>
<div className="w-full flex flex-row justify-between items-center">
<span className="text-sm text-gray-500">{inbox.createTime?.toLocaleString()}</span>
<div>
{inbox.status === Inbox_Status.UNREAD && (
<Tooltip title={t("common.archive")} placement="top">
<InboxIcon className="w-4 h-auto cursor-pointer text-gray-400 hover:text-blue-600" onClick={() => handleArchiveMessage()} />
</Tooltip>
)}
</div>
</div>
<p
className="text-base leading-tight cursor-pointer text-gray-500 dark:text-gray-400 hover:underline hover:text-blue-600"
onClick={handleNavigate}
>
{t("inbox.version-update", {
version: activity?.payload?.versionUpdate?.version,
})}
</p>
</div>
</div>
);
};
export default VersionUpdateMessage;
web/src/pages/Inboxes.tsx
View file @
0a429a89
...
...
@@ -3,7 +3,6 @@ import { observer } from "mobx-react-lite";
import
{
useEffect
}
from
"react"
;
import
Empty
from
"@/components/Empty"
;
import
MemoCommentMessage
from
"@/components/Inbox/MemoCommentMessage"
;
import
VersionUpdateMessage
from
"@/components/Inbox/VersionUpdateMessage"
;
import
MobileHeader
from
"@/components/MobileHeader"
;
import
{
userStore
}
from
"@/store/v2"
;
import
{
Inbox_Status
,
Inbox_Type
}
from
"@/types/proto/api/v1/inbox_service"
;
...
...
@@ -44,8 +43,6 @@ const Inboxes = observer(() => {
{
inboxes
.
map
((
inbox
)
=>
{
if
(
inbox
.
type
===
Inbox_Type
.
MEMO_COMMENT
)
{
return
<
MemoCommentMessage
key=
{
`${inbox.name}-${inbox.status}`
}
inbox=
{
inbox
}
/>;
}
else
if
(
inbox
.
type
===
Inbox_Type
.
VERSION_UPDATE
)
{
return
<
VersionUpdateMessage
key=
{
`${inbox.name}-${inbox.status}`
}
inbox=
{
inbox
}
/>;
}
return
undefined
;
})
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment