Skip to content

Commit

Permalink
Merge pull request #21 from nekoplanet/fix-note-edit-2
Browse files Browse the repository at this point in the history
노트 수정 기능 관련
  • Loading branch information
HotoRas authored Aug 3, 2024
2 parents 76252a0 + d9133ab commit 161f15d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
9 changes: 5 additions & 4 deletions packages/backend/src/core/NoteUpdateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class NoteUpdateService implements OnApplicationShutdown {
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 @@ -124,6 +124,7 @@ export class NoteUpdateService implements OnApplicationShutdown {
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 @@ export class NoteUpdateService implements OnApplicationShutdown {
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 Down Expand Up @@ -181,7 +182,7 @@ export class NoteUpdateService implements OnApplicationShutdown {
});

await transactionalEntitymanager.insert(MiPoll, poll);
}
}
});
} else if (note.hasPoll && !values.hasPoll) {
// start transaction
Expand Down Expand Up @@ -289,4 +290,4 @@ export class NoteUpdateService implements OnApplicationShutdown {
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 @@ -218,20 +218,7 @@ export function getNoteMenu(props: {
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 ','
})

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
}

Expand Down

0 comments on commit 161f15d

Please sign in to comment.