mirror of
https://github.com/usememos/memos.git
synced 2025-02-12 01:10:38 +01:00
fix: find memo list order (#1149)
This commit is contained in:
parent
c24b7097fa
commit
904a6bd97f
@ -42,7 +42,7 @@ type Memo struct {
|
|||||||
Pinned bool `json:"pinned"`
|
Pinned bool `json:"pinned"`
|
||||||
|
|
||||||
// Related fields
|
// Related fields
|
||||||
Creator *User `json:"creator"`
|
CreatorName string `json:"creatorName"`
|
||||||
ResourceList []*Resource `json:"resourceList"`
|
ResourceList []*Resource `json:"resourceList"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,11 +302,11 @@ func findMemoRawList(ctx context.Context, tx *sql.Tx, find *api.MemoFind) ([]*me
|
|||||||
memo.row_status,
|
memo.row_status,
|
||||||
memo.content,
|
memo.content,
|
||||||
memo.visibility,
|
memo.visibility,
|
||||||
memo_organizer.pinned
|
IFNULL(memo_organizer.pinned, 0) AS pinned
|
||||||
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 AND memo_organizer.user_id = memo.creator_id
|
||||||
WHERE ` + strings.Join(where, " AND ") + `
|
WHERE ` + strings.Join(where, " AND ") + `
|
||||||
ORDER BY memo_organizer.pinned DESC, memo.created_ts DESC
|
ORDER BY 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)
|
||||||
|
@ -56,10 +56,11 @@ func (s *Store) ComposeMemoCreator(ctx context.Context, memo *api.Memo) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
user.Email = ""
|
if user.Nickname != "" {
|
||||||
user.OpenID = ""
|
memo.CreatorName = user.Nickname
|
||||||
user.UserSettingList = nil
|
} else {
|
||||||
memo.Creator = user
|
memo.CreatorName = user.Username
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (s *Store) CreateUser(ctx context.Context, create *api.UserCreate) (*api.User, error) {
|
func (s *Store) CreateUser(ctx context.Context, create *api.UserCreate) (*api.User, error) {
|
||||||
|
@ -17,6 +17,6 @@ export const VISIBILITY_SELECTOR_ITEMS = [
|
|||||||
export const TAB_SPACE_WIDTH = 2;
|
export const TAB_SPACE_WIDTH = 2;
|
||||||
|
|
||||||
// default fetch memo amount
|
// default fetch memo amount
|
||||||
export const DEFAULT_MEMO_LIMIT = 30;
|
export const DEFAULT_MEMO_LIMIT = 20;
|
||||||
|
|
||||||
export const MEMOS_LOGO_URL = "https://usememos.com/logo.png";
|
export const MEMOS_LOGO_URL = "https://usememos.com/logo.png";
|
||||||
|
@ -49,8 +49,8 @@ const EmbedMemo = () => {
|
|||||||
<div className="w-full flex flex-col justify-start items-start">
|
<div className="w-full flex flex-col justify-start items-start">
|
||||||
<div className="w-full mb-2 flex flex-row justify-start items-center text-sm text-gray-400 dark:text-gray-300">
|
<div className="w-full mb-2 flex flex-row justify-start items-center text-sm text-gray-400 dark:text-gray-300">
|
||||||
<span>{dayjs(state.memo.createdTs).locale(i18n.language).format("YYYY/MM/DD HH:mm:ss")}</span>
|
<span>{dayjs(state.memo.createdTs).locale(i18n.language).format("YYYY/MM/DD HH:mm:ss")}</span>
|
||||||
<a className="ml-2 hover:underline hover:text-green-600" href={`/u/${state.memo.creator.id}`}>
|
<a className="ml-2 hover:underline hover:text-green-600" href={`/u/${state.memo.creatorId}`}>
|
||||||
@{state.memo.creator.nickname || state.memo.creator.username}
|
@{state.memo.creatorName}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<MemoContent className="memo-content" content={state.memo.content} onMemoContentClick={() => undefined} />
|
<MemoContent className="memo-content" content={state.memo.content} onMemoContentClick={() => undefined} />
|
||||||
|
@ -142,8 +142,8 @@ const Explore = () => {
|
|||||||
{memo.pinned && <div className="corner-container"></div>}
|
{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.creatorId}`}>
|
||||||
@{memo.creator.nickname || memo.creator.username}
|
@{memo.creatorName}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<MemoContent className="memo-content" content={memo.content} onMemoContentClick={handleMemoContentClick} />
|
<MemoContent className="memo-content" content={memo.content} onMemoContentClick={handleMemoContentClick} />
|
||||||
|
@ -79,8 +79,8 @@ const MemoDetail = () => {
|
|||||||
<div className="memo-header">
|
<div className="memo-header">
|
||||||
<div className="status-container">
|
<div className="status-container">
|
||||||
<span className="time-text">{dayjs(state.memo.createdTs).locale(i18n.language).format("YYYY/MM/DD HH:mm:ss")}</span>
|
<span className="time-text">{dayjs(state.memo.createdTs).locale(i18n.language).format("YYYY/MM/DD HH:mm:ss")}</span>
|
||||||
<a className="name-text" href={`/u/${state.memo.creator.id}`}>
|
<a className="name-text" href={`/u/${state.memo.creatorId}`}>
|
||||||
@{state.memo.creator.nickname || state.memo.creator.username}
|
@{state.memo.creatorName}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
2
web/src/types/modules/memo.d.ts
vendored
2
web/src/types/modules/memo.d.ts
vendored
@ -14,7 +14,7 @@ interface Memo {
|
|||||||
visibility: Visibility;
|
visibility: Visibility;
|
||||||
pinned: boolean;
|
pinned: boolean;
|
||||||
|
|
||||||
creator: User;
|
creatorName: string;
|
||||||
resourceList: Resource[];
|
resourceList: Resource[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user