Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

노트 수정 기능 관련 #21

Merged
merged 2 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/backend/src/core/NoteUpdateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

if (data.text) {
if (data.text.length > DB_MAX_NOTE_TEXT_LENGTH)
data.text = data.text.slice(0, DB_MAX_NOTE_TEXT_LENGTH);

Check failure on line 84 in packages/backend/src/core/NoteUpdateService.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Expected no linebreak before this statement
data.text = data.text.trim();
} else {
data.text = null;
Expand All @@ -97,7 +97,7 @@
const choiceTokens = data.poll && data.poll.choices
? concat(data.poll.choices.map((choice: string) => mfm.parse(choice)))
: [];

const combinedTokens = tokens.concat(cwTokens).concat(choiceTokens);

tags = data.apHashtags ?? extractHashtags(combinedTokens);
Expand All @@ -122,8 +122,9 @@
host: MiUser['host'],
}, note: MiNote, data: Option, tags: string[], emojis: string[]): Promise<MiNote | null> {
if (data.updatedAt === null || data.updatedAt === undefined)
data.updatedAt = new Date();

Check failure on line 125 in packages/backend/src/core/NoteUpdateService.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Expected no linebreak before this statement
const updatedAtHistory = note.updatedAtHistory ?? [];
const noteEditHistory = note.noteEditHistory ?? [];

const values = new MiNote({
updatedAt: data.updatedAt,
Expand All @@ -135,7 +136,7 @@
emojis: emojis,
attachedFileTypes: data.files ? data.files.map(file => file.type) : [],
updatedAtHistory: [...updatedAtHistory, data.updatedAt],
noteEditHistory: [...note.noteEditHistory, ((note.cw ? note.cw + '\n' : '') + note.text as string)],
noteEditHistory: [...noteEditHistory, ((note.cw ? note.cw + '\n' : '') + note.text as string)],
});

try {
Expand All @@ -149,7 +150,7 @@
if ((old_poll && old_poll.choices.toString() !== data.poll?.choices.toString())
|| (old_poll && old_poll.multiple !== data.poll?.multiple)) {
await transactionalEntityManager.delete(MiPoll, { noteId: note.id });
const poll = new MiPoll ({

Check failure on line 153 in packages/backend/src/core/NoteUpdateService.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Unexpected whitespace between function name and paren
noteId: note.id,
choices: data.poll!.choices,
expiresAt: data.poll!.expiresAt,
Expand All @@ -169,7 +170,7 @@
await transactionalEntitymanager.update(MiNote, { id: note.id }, values);

if (values.hasPoll) {
const poll = new MiPoll ({

Check failure on line 173 in packages/backend/src/core/NoteUpdateService.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Unexpected whitespace between function name and paren
noteId: note.id,
choices: data.poll!.choices,
expiresAt: data.poll!.expiresAt,
Expand All @@ -181,15 +182,15 @@
});

await transactionalEntitymanager.insert(MiPoll, poll);
}
}
});
} else if (note.hasPoll && !values.hasPoll) {
// start transaction
await this.db.transaction(async transactionalEntityManager => {
await transactionalEntityManager.update(MiNote, { id: note.id }, values);

if(!values.hasPoll)

Check failure on line 192 in packages/backend/src/core/NoteUpdateService.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Expected space(s) after "if"
await transactionalEntityManager.delete(MiPoll, { noteId: note.id });

Check failure on line 193 in packages/backend/src/core/NoteUpdateService.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Expected no linebreak before this statement
});
} else {
await this.notesRepository.update({ id: note.id }, values);
Expand Down Expand Up @@ -289,4 +290,4 @@
public onApplicationShutdown(signal?: string | undefined): void {
this.dispose();
}
}
}
5 changes: 4 additions & 1 deletion packages/frontend/src/components/MkPostForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const props = withDefaults(defineProps<{
autofocus?: boolean;
freezeAfterPosted?: boolean;
mock?: boolean;
editMode?: boolean;
}>(), {
initialVisibleUsers: () => [],
autofocus: true,
Expand Down Expand Up @@ -773,6 +774,7 @@ async function post(ev?: MouseEvent) {
visibility: visibility.value,
visibleUserIds: visibility.value === 'specified' ? visibleUsers.value.map(u => u.id) : undefined,
reactionAcceptance: reactionAcceptance.value,
noteId: props.editMode ? props.initialNote?.id : undefined,
};

if (withHashtags.value && hashtags.value && hashtags.value.trim() !== '') {
Expand Down Expand Up @@ -809,7 +811,8 @@ async function post(ev?: MouseEvent) {
}

posting.value = true;
misskeyApi('notes/create', postData, token).then(() => {
const endpoint = props.editMode ? 'notes/update' : 'notes/create';
misskeyApi(endpoint, postData, token).then(() => {
if (props.freezeAfterPosted) {
posted.value = true;
} else {
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/components/MkPostFormDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const props = withDefaults(defineProps<{
instant?: boolean;
fixed?: boolean;
autofocus?: boolean;
editMode?: boolean;
}>(), {
initialLocalOnly: undefined,
});
Expand Down
15 changes: 1 addition & 14 deletions packages/frontend/src/scripts/get-note-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import MkRippleEffect from '@/components/MkRippleEffect.vue';
import { isSupportShare } from '@/scripts/navigator.js';


Check failure on line 24 in packages/frontend/src/scripts/get-note-menu.ts

View workflow job for this annotation

GitHub Actions / lint (frontend)

More than 1 blank line not allowed
export async function getNoteClipMenu(props: {
note: Misskey.entities.Note;
isDeleted: Ref<boolean>;
Expand Down Expand Up @@ -216,23 +216,10 @@
os.confirm({
type: 'warning',
text: i18n.ts.editConfirm,
}).then(({canceled}) => {

Check failure on line 219 in packages/frontend/src/scripts/get-note-menu.ts

View workflow job for this annotation

GitHub Actions / lint (frontend)

A space is required after '{'

Check failure on line 219 in packages/frontend/src/scripts/get-note-menu.ts

View workflow job for this annotation

GitHub Actions / lint (frontend)

A space is required before '}'
if (canceled) return;

misskeyApi('notes/update', {
noteId: appearNote.id,
text: (appearNote.text as string),
fileIds: appearNote.fileIds,
//mediaIds: appearNote.mediaIds,
poll: (appearNote.poll ? {
expiresAt: (appearNote.poll.expiresAt ? parseInt(appearNote.poll.expiresAt) : undefined),
expiredAfter: undefined,
multiple: appearNote.poll.multiple,
choices: appearNote.poll.choices.map((choice) => { return choice.text }),
} : undefined),//(appearNote.poll),
cw: (appearNote.cw ?? null),
});
os.post({ initialNote: appearNote, renote: appearNote.renote, reply: appearNote.reply, channel: appearNote.channel , editMode: true });

Check failure on line 221 in packages/frontend/src/scripts/get-note-menu.ts

View workflow job for this annotation

GitHub Actions / lint (frontend)

There should be no space before ','
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기 이후에 노트나 UI를 새로고침하는 명령이 있으면 걜 추가(await os.post(...); return os.refresh(); 얘처럼)하는 것도 좋아보이긴 하네요... 음

})

Check failure on line 222 in packages/frontend/src/scripts/get-note-menu.ts

View workflow job for this annotation

GitHub Actions / lint (frontend)

Missing semicolon
}

function toggleFavorite(favorite: boolean): void {
Expand Down
Loading