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
834b58fb
Commit
834b58fb
authored
Nov 06, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add version update inbox message
parent
342d1aee
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
350 additions
and
129 deletions
+350
-129
activity_service .go
api/v2/activity_service .go
+5
-0
activity_service.proto
proto/api/v2/activity_service.proto
+5
-0
inbox_service.proto
proto/api/v2/inbox_service.proto
+1
-0
README.md
proto/gen/api/v2/README.md
+18
-0
activity_service.pb.go
proto/gen/api/v2/activity_service.pb.go
+140
-62
inbox_service.pb.go
proto/gen/api/v2/inbox_service.pb.go
+71
-66
VersionUpdateMessage.tsx
web/src/components/Inbox/VersionUpdateMessage.tsx
+105
-0
en.json
web/src/locales/en.json
+2
-1
Inboxes.tsx
web/src/pages/Inboxes.tsx
+3
-0
No files found.
api/v2/activity_service .go
View file @
834b58fb
...
@@ -49,5 +49,10 @@ func convertActivityPayloadFromStore(payload *storepb.ActivityPayload) *apiv2pb.
...
@@ -49,5 +49,10 @@ func convertActivityPayloadFromStore(payload *storepb.ActivityPayload) *apiv2pb.
RelatedMemoId
:
payload
.
MemoComment
.
RelatedMemoId
,
RelatedMemoId
:
payload
.
MemoComment
.
RelatedMemoId
,
}
}
}
}
if
payload
.
VersionUpdate
!=
nil
{
v2Payload
.
VersionUpdate
=
&
apiv2pb
.
ActivityVersionUpdatePayload
{
Version
:
payload
.
VersionUpdate
.
Version
,
}
}
return
v2Payload
return
v2Payload
}
}
proto/api/v2/activity_service.proto
View file @
834b58fb
...
@@ -32,8 +32,13 @@ message ActivityMemoCommentPayload {
...
@@ -32,8 +32,13 @@ message ActivityMemoCommentPayload {
int32
related_memo_id
=
2
;
int32
related_memo_id
=
2
;
}
}
message
ActivityVersionUpdatePayload
{
string
version
=
1
;
}
message
ActivityPayload
{
message
ActivityPayload
{
ActivityMemoCommentPayload
memo_comment
=
1
;
ActivityMemoCommentPayload
memo_comment
=
1
;
ActivityVersionUpdatePayload
version_update
=
2
;
}
}
message
GetActivityRequest
{
message
GetActivityRequest
{
...
...
proto/api/v2/inbox_service.proto
View file @
834b58fb
...
@@ -49,6 +49,7 @@ message Inbox {
...
@@ -49,6 +49,7 @@ message Inbox {
enum
Type
{
enum
Type
{
TYPE_UNSPECIFIED
=
0
;
TYPE_UNSPECIFIED
=
0
;
TYPE_MEMO_COMMENT
=
1
;
TYPE_MEMO_COMMENT
=
1
;
TYPE_VERSION_UPDATE
=
2
;
}
}
Type
type
=
6
;
Type
type
=
6
;
...
...
proto/gen/api/v2/README.md
View file @
834b58fb
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
-
[
Activity
](
#memos-api-v2-Activity
)
-
[
Activity
](
#memos-api-v2-Activity
)
-
[
ActivityMemoCommentPayload
](
#memos-api-v2-ActivityMemoCommentPayload
)
-
[
ActivityMemoCommentPayload
](
#memos-api-v2-ActivityMemoCommentPayload
)
-
[
ActivityPayload
](
#memos-api-v2-ActivityPayload
)
-
[
ActivityPayload
](
#memos-api-v2-ActivityPayload
)
-
[
ActivityVersionUpdatePayload
](
#memos-api-v2-ActivityVersionUpdatePayload
)
-
[
GetActivityRequest
](
#memos-api-v2-GetActivityRequest
)
-
[
GetActivityRequest
](
#memos-api-v2-GetActivityRequest
)
-
[
GetActivityResponse
](
#memos-api-v2-GetActivityResponse
)
-
[
GetActivityResponse
](
#memos-api-v2-GetActivityResponse
)
...
@@ -155,6 +156,22 @@
...
@@ -155,6 +156,22 @@
| Field | Type | Label | Description |
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| ----- | ---- | ----- | ----------- |
| memo_comment |
[
ActivityMemoCommentPayload
](
#memos-api-v2-ActivityMemoCommentPayload
)
| | |
| memo_comment |
[
ActivityMemoCommentPayload
](
#memos-api-v2-ActivityMemoCommentPayload
)
| | |
| version_update |
[
ActivityVersionUpdatePayload
](
#memos-api-v2-ActivityVersionUpdatePayload
)
| | |
<a
name=
"memos-api-v2-ActivityVersionUpdatePayload"
></a>
### ActivityVersionUpdatePayload
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| version |
[
string
](
#string
)
| | |
...
@@ -377,6 +394,7 @@
...
@@ -377,6 +394,7 @@
| ---- | ------ | ----------- |
| ---- | ------ | ----------- |
| TYPE_UNSPECIFIED | 0 | |
| TYPE_UNSPECIFIED | 0 | |
| TYPE_MEMO_COMMENT | 1 | |
| TYPE_MEMO_COMMENT | 1 | |
| TYPE_VERSION_UPDATE | 2 | |
...
...
proto/gen/api/v2/activity_service.pb.go
View file @
834b58fb
This diff is collapsed.
Click to expand it.
proto/gen/api/v2/inbox_service.pb.go
View file @
834b58fb
This diff is collapsed.
Click to expand it.
web/src/components/Inbox/VersionUpdateMessage.tsx
0 → 100644
View file @
834b58fb
import
{
Tooltip
}
from
"@mui/joy"
;
import
classNames
from
"classnames"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
toast
from
"react-hot-toast"
;
import
{
activityServiceClient
}
from
"@/grpcweb"
;
import
{
useInboxStore
}
from
"@/store/v1"
;
import
{
Activity
}
from
"@/types/proto/api/v2/activity_service"
;
import
{
Inbox
,
Inbox_Status
}
from
"@/types/proto/api/v2/inbox_service"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
Icon
from
"../Icon"
;
interface
Props
{
inbox
:
Inbox
;
}
const
VersionUpdateMessage
=
({
inbox
}:
Props
)
=>
{
const
t
=
useTranslate
();
const
inboxStore
=
useInboxStore
();
const
[
activity
,
setActivity
]
=
useState
<
Activity
|
undefined
>
(
undefined
);
useEffect
(()
=>
{
if
(
!
inbox
.
activityId
)
{
return
;
}
activityServiceClient
.
getActivity
({
id
:
inbox
.
activityId
,
})
.
then
(({
activity
})
=>
{
console
.
log
(
"activity"
,
activity
);
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 inboxStore.updateInbox(
{
name: inbox.name,
status: Inbox_Status.ARCHIVED,
},
["status"]
);
if (!silence) {
toast.success("Archived");
}
};
return (
<div className="w-full flex flex-row justify-start items-start gap-3">
<div
className={classNames(
"shrink-0 mt-2 p-2 rounded-full border",
inbox.status === Inbox_Status.UNREAD
? "border-green-600 text-green-600 bg-blue-50 dark:bg-zinc-800"
: "border-gray-400 text-gray-400 bg-gray-50 dark:bg-zinc-800"
)}
>
<Tooltip title={"Comment"} placement="bottom">
<Icon.ArrowUp className="w-4 sm:w-5 h-auto" />
</Tooltip>
</div>
<div
className={classNames(
"border w-full p-3 px-4 rounded-lg flex flex-col justify-start items-start gap-2 dark:border-zinc-800 hover:bg-gray-100 dark:hover:bg-zinc-800",
inbox.status !== Inbox_Status.UNREAD && "opacity-60"
)}
>
<div className="w-full flex flex-row justify-between items-center">
<span className="text-xs text-gray-500">{inbox.createTime?.toLocaleString()}</span>
<div>
{inbox.status === Inbox_Status.UNREAD && (
<Tooltip title={t("common.archive")} placement="top">
<Icon.Inbox
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/locales/en.json
View file @
834b58fb
...
@@ -370,6 +370,7 @@
...
@@ -370,6 +370,7 @@
"password-login-disabled"
:
"Can't remove last identity provider when password login is disabled"
"password-login-disabled"
:
"Can't remove last identity provider when password login is disabled"
},
},
"inbox"
:
{
"inbox"
:
{
"memo-comment"
:
"{{user}} has a comment on your {{memo}}."
"memo-comment"
:
"{{user}} has a comment on your {{memo}}."
,
"version-update"
:
"New version {{version}} is available now!"
}
}
}
}
web/src/pages/Inboxes.tsx
View file @
834b58fb
...
@@ -2,6 +2,7 @@ import { useEffect } from "react";
...
@@ -2,6 +2,7 @@ import { useEffect } from "react";
import
Empty
from
"@/components/Empty"
;
import
Empty
from
"@/components/Empty"
;
import
Icon
from
"@/components/Icon"
;
import
Icon
from
"@/components/Icon"
;
import
MemoCommentMessage
from
"@/components/Inbox/MemoCommentMessage"
;
import
MemoCommentMessage
from
"@/components/Inbox/MemoCommentMessage"
;
import
VersionUpdateMessage
from
"@/components/Inbox/VersionUpdateMessage"
;
import
MobileHeader
from
"@/components/MobileHeader"
;
import
MobileHeader
from
"@/components/MobileHeader"
;
import
{
useInboxStore
}
from
"@/store/v1"
;
import
{
useInboxStore
}
from
"@/store/v1"
;
import
{
Inbox_Type
}
from
"@/types/proto/api/v2/inbox_service"
;
import
{
Inbox_Type
}
from
"@/types/proto/api/v2/inbox_service"
;
...
@@ -38,6 +39,8 @@ const Inboxes = () => {
...
@@ -38,6 +39,8 @@ const Inboxes = () => {
{
inboxes
.
map
((
inbox
)
=>
{
{
inboxes
.
map
((
inbox
)
=>
{
if
(
inbox
.
type
===
Inbox_Type
.
TYPE_MEMO_COMMENT
)
{
if
(
inbox
.
type
===
Inbox_Type
.
TYPE_MEMO_COMMENT
)
{
return
<
MemoCommentMessage
key=
{
`${inbox.name}-${inbox.status}`
}
inbox=
{
inbox
}
/>;
return
<
MemoCommentMessage
key=
{
`${inbox.name}-${inbox.status}`
}
inbox=
{
inbox
}
/>;
}
else
if
(
inbox
.
type
===
Inbox_Type
.
TYPE_VERSION_UPDATE
)
{
return
<
VersionUpdateMessage
key=
{
`${inbox.name}-${inbox.status}`
}
inbox=
{
inbox
}
/>;
}
}
return
undefined
;
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