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
6d2d3221
Unverified
Commit
6d2d3221
authored
Feb 23, 2023
by
boojack
Committed by
GitHub
Feb 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: show pinned memos in explore (#1141)
parent
15176880
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
25 deletions
+20
-25
memo.go
server/memo.go
+1
-16
memo.go
store/memo.go
+1
-1
explore.less
web/src/less/explore.less
+15
-1
Explore.tsx
web/src/pages/Explore.tsx
+3
-7
No files found.
server/memo.go
View file @
6d2d3221
...
@@ -209,22 +209,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
...
@@ -209,22 +209,7 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to fetch memo list"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to fetch memo list"
)
.
SetInternal
(
err
)
}
}
return
c
.
JSON
(
http
.
StatusOK
,
composeResponse
(
list
))
var
pinnedMemoList
[]
*
api
.
Memo
var
unpinnedMemoList
[]
*
api
.
Memo
for
_
,
memo
:=
range
list
{
if
memo
.
Pinned
{
pinnedMemoList
=
append
(
pinnedMemoList
,
memo
)
}
else
{
unpinnedMemoList
=
append
(
unpinnedMemoList
,
memo
)
}
}
memoList
:=
[]
*
api
.
Memo
{}
memoList
=
append
(
memoList
,
pinnedMemoList
...
)
memoList
=
append
(
memoList
,
unpinnedMemoList
...
)
return
c
.
JSON
(
http
.
StatusOK
,
composeResponse
(
memoList
))
})
})
g
.
GET
(
"/memo/:memoId"
,
func
(
c
echo
.
Context
)
error
{
g
.
GET
(
"/memo/:memoId"
,
func
(
c
echo
.
Context
)
error
{
...
...
store/memo.go
View file @
6d2d3221
...
@@ -306,7 +306,7 @@ func findMemoRawList(ctx context.Context, tx *sql.Tx, find *api.MemoFind) ([]*me
...
@@ -306,7 +306,7 @@ func findMemoRawList(ctx context.Context, tx *sql.Tx, find *api.MemoFind) ([]*me
FROM memo
FROM memo
LEFT JOIN memo_organizer ON memo_organizer.memo_id = memo.id
LEFT JOIN memo_organizer ON memo_organizer.memo_id = memo.id
WHERE `
+
strings
.
Join
(
where
,
" AND "
)
+
`
WHERE `
+
strings
.
Join
(
where
,
" AND "
)
+
`
ORDER BY memo.created_ts DESC
ORDER BY memo
_organizer.pinned DESC, memo
.created_ts DESC
`
`
if
find
.
Limit
!=
nil
{
if
find
.
Limit
!=
nil
{
query
=
fmt
.
Sprintf
(
"%s LIMIT %d"
,
query
,
*
find
.
Limit
)
query
=
fmt
.
Sprintf
(
"%s LIMIT %d"
,
query
,
*
find
.
Limit
)
...
...
web/src/less/explore.less
View file @
6d2d3221
...
@@ -24,7 +24,21 @@
...
@@ -24,7 +24,21 @@
@apply relative flex-grow max-w-2xl w-full h-auto flex flex-col justify-start items-start px-4 sm:pr-6 ml-calc;
@apply relative flex-grow max-w-2xl w-full h-auto flex flex-col justify-start items-start px-4 sm:pr-6 ml-calc;
> .memo-container {
> .memo-container {
@apply flex flex-col justify-start items-start w-full p-4 mt-2 bg-white dark:bg-zinc-700 rounded-lg border border-white dark:border-zinc-800 hover:border-gray-200 dark:hover:border-zinc-600;
@apply relative flex flex-col justify-start items-start w-full p-4 mt-2 bg-white dark:bg-zinc-700 rounded-lg border border-white dark:border-zinc-800 hover:border-gray-200 dark:hover:border-zinc-600;
&.pinned {
@apply border-gray-200 border-2 dark:border-zinc-600;
}
> .corner-container {
@apply absolute top-0 right-0 z-1;
&::after {
@apply rounded-tr-md absolute top-0 right-0 border-transparent border-t-green-600 border-r-green-600;
content: "";
border-width: 6px;
}
}
> .memo-header {
> .memo-header {
@apply mb-2 w-full flex flex-row justify-start items-center text-sm text-gray-400;
@apply mb-2 w-full flex flex-row justify-start items-center text-sm text-gray-400;
...
...
web/src/pages/Explore.tsx
View file @
6d2d3221
...
@@ -73,12 +73,7 @@ const Explore = () => {
...
@@ -73,12 +73,7 @@ const Explore = () => {
})
})
:
state
.
memos
;
:
state
.
memos
;
const
sortedMemos
=
shownMemos
const
sortedMemos
=
shownMemos
.
filter
((
m
)
=>
m
.
rowStatus
===
"NORMAL"
);
.
filter
((
m
)
=>
m
.
rowStatus
===
"NORMAL"
)
.
sort
((
mi
:
Memo
,
mj
:
Memo
)
=>
{
return
mj
.
createdTs
-
mi
.
createdTs
;
});
const
handleFetchMoreClick
=
async
()
=>
{
const
handleFetchMoreClick
=
async
()
=>
{
try
{
try
{
const
fetchedMemos
=
await
memoStore
.
fetchAllMemos
(
DEFAULT_MEMO_LIMIT
,
state
.
memos
.
length
);
const
fetchedMemos
=
await
memoStore
.
fetchAllMemos
(
DEFAULT_MEMO_LIMIT
,
state
.
memos
.
length
);
...
@@ -143,7 +138,8 @@ const Explore = () => {
...
@@ -143,7 +138,8 @@ const Explore = () => {
{
sortedMemos
.
map
((
memo
)
=>
{
{
sortedMemos
.
map
((
memo
)
=>
{
const
createdAtStr
=
dayjs
(
memo
.
createdTs
).
locale
(
i18n
.
language
).
format
(
"YYYY/MM/DD HH:mm:ss"
);
const
createdAtStr
=
dayjs
(
memo
.
createdTs
).
locale
(
i18n
.
language
).
format
(
"YYYY/MM/DD HH:mm:ss"
);
return
(
return
(
<
div
className=
"memo-container"
key=
{
memo
.
id
}
>
<
div
className=
{
`memo-container ${memo.pinned ? "pinned" : ""}`
}
key=
{
memo
.
id
}
>
{
memo
.
pinned
&&
<
div
className=
"corner-container"
></
div
>
}
<
div
className=
"memo-header"
>
<
div
className=
"memo-header"
>
<
span
className=
"time-text"
>
{
createdAtStr
}
</
span
>
<
span
className=
"time-text"
>
{
createdAtStr
}
</
span
>
<
a
className=
"name-text"
href=
{
`/u/${memo.creator.id}`
}
>
<
a
className=
"name-text"
href=
{
`/u/${memo.creator.id}`
}
>
...
...
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