Skip to content

Commit f4d6f66

Browse files
fix(note): return last edit info to the right side
1 parent 77cbde7 commit f4d6f66

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

src/presentation/pages/Note.vue

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
/>
1010
</template>
1111
<template #right>
12+
<div class="last_edit">
13+
{{
14+
note && 'updatedAt' in note && note.updatedAt
15+
? t('note.lastEdit') + ' ' + getTimeFromNow(note.updatedAt)
16+
: t('note.lastEdit') + ' ' + 'a few seconds ago'
17+
}}
18+
</div>
1219
<Button
1320
v-if="canEdit"
1421
secondary
@@ -57,7 +64,7 @@
5764

5865
<script lang="ts" setup>
5966
import { computed, ref, toRef, watch } from 'vue';
60-
import { Button, Editor, type VerticalMenuItem, VerticalMenu, PageBlock } from '@codexteam/ui/vue';
67+
import { Button, Editor, PageBlock, VerticalMenu, type VerticalMenuItem } from '@codexteam/ui/vue';
6168
import useNote from '@/application/services/useNote';
6269
import { useRoute, useRouter } from 'vue-router';
6370
import { NoteContent } from '@/domain/entities/Note';
@@ -70,6 +77,7 @@ import NoteHeader from '@/presentation/components/note-header/NoteHeader.vue';
7077
import BreadCrumbs from '@/presentation/components/breadcrumbs/BreadCrumbs.vue';
7178
import { NoteHierarchy } from '@/domain/entities/NoteHierarchy';
7279
import { getTitle } from '@/infrastructure/utils/note';
80+
import { getTimeFromNow } from '@/infrastructure/utils/date.ts';
7381
7482
const { t } = useI18n();
7583
@@ -162,7 +170,7 @@ async function noteChanged(data: NoteContent): Promise<void> {
162170
});
163171
}
164172
if (updatedNoteCover !== null && props.id !== null) {
165-
updateCover(props.id, updatedNoteCover);
173+
await updateCover(props.id, updatedNoteCover);
166174
}
167175
}
168176
}
@@ -171,6 +179,7 @@ async function noteChanged(data: NoteContent): Promise<void> {
171179
* Recursively transform the note hierarchy into a VerticalMenuItem
172180
*
173181
* @param noteHierarchyObj - note hierarchy data
182+
* @param currentNoteTitle - actual title of note
174183
* @returns menuItem - VerticalMenuItem
175184
*/
176185
@@ -184,17 +193,16 @@ function transformNoteHierarchy(noteHierarchyObj: NoteHierarchy | null, currentN
184193
}
185194
186195
const title = noteHierarchyObj.content ? getTitle(noteHierarchyObj.content) : 'Untitled';
196+
187197
// Transform the current note into a VerticalMenuItem
188-
const menuItem: VerticalMenuItem = {
198+
return {
189199
title: title,
190200
isActive: route.path === `/note/${noteHierarchyObj.id}`,
191201
items: noteHierarchyObj.childNotes ? noteHierarchyObj.childNotes.map(child => transformNoteHierarchy(child, currentNoteTitle)) : undefined,
192202
onActivate: () => {
193203
void router.push(`/note/${noteHierarchyObj.id}`);
194204
},
195205
};
196-
197-
return menuItem;
198206
}
199207
200208
const verticalMenuItems = computed<VerticalMenuItem>(() => {
@@ -230,4 +238,9 @@ watch(noteTitle, () => {
230238
height: fit-content;
231239
width: auto;
232240
}
241+
242+
.last_edit {
243+
color: var(--base--text-secondary);
244+
padding-right: var(--h-padding);
245+
}
233246
</style>

0 commit comments

Comments
 (0)