Compare commits

...

5 Commits

Author SHA1 Message Date
laozhoubuluo 321cf5b978 Merge branch 'fix/post_import_if' into 'develop'
Draft: fix: questionable if statements in note import

Co-authored-by: naskya <m@naskya.net>

See merge request firefish/firefish!10771
2024-05-08 08:42:55 +00:00
Hosted Weblate 347851d6bb
Merge branch 'origin/develop' into Weblate 2024-05-08 10:21:46 +02:00
jolupa abec71074b
locale: update translations (Catalan)
Currently translated at 100.0% (1930 of 1930 strings)

Translation: Firefish/locales
Translate-URL: https://hosted.weblate.org/projects/firefish/locales/ca/
2024-05-08 10:21:45 +02:00
naskya 2c6466b0dc
meta: update gitignore 2024-05-08 03:51:58 +09:00
老周部落 1852324054
fix: questionable if statements in note import 2024-05-06 22:38:35 +08:00
4 changed files with 30 additions and 13 deletions

6
.gitignore vendored
View File

@ -50,16 +50,12 @@ api-docs.json
*.log
*.code-workspace
.DS_Store
files/
/files
ormconfig.json
packages/backend/assets/instance.css
packages/backend/assets/sounds/None.mp3
packages/backend/assets/LICENSE
!/packages/backend/queue/processors/db
!/packages/backend/src/db
!/packages/backend/src/server/api/endpoints/drive/files
packages/megalodon/lib
packages/megalodon/.idea

View File

@ -2301,3 +2301,6 @@ getQrCode: Mostrar el codi QR
copyRemoteFollowUrl: Còpia la adreça URL del seguidor remot
foldNotification: Agrupar les notificacions similars
slashQuote: Cita encadenada
i18nServerInfo: Els nous clients els trobares en {language} per defecte.
i18nServerChange: Fes servir {language} en comptes.
i18nServerSet: Fes servir {language} per els nous clients.

View File

@ -59,18 +59,27 @@ export async function importCkPost(
userId: user.id,
});
// FIXME: What is this condition?
if (note != null && (note.fileIds?.length || 0) < files.length) {
// If an import is completely successful at once, the order should not be out of order.
// If it takes multiple imports to complete, the order is not guaranteed to be consistent.
if (note != null && files.length > 0) {
const addFiles: DriveFile[] = [];
for (const file of files) {
if (!note.fileIds.includes(file.id)) {
addFiles.push(file);
}
}
const update: Partial<Note> = {};
update.fileIds = files.map((x) => x.id);
update.fileIds = addFiles.map((x) => x.id);
if (update.fileIds != null) {
await NoteFiles.delete({ noteId: note.id });
await NoteFiles.insert(
update.fileIds.map((fileId) => ({ noteId: note?.id, fileId })),
);
}
update.fileIds = note.fileIds.concat(update.fileIds);
await Notes.update(note.id, update);
await NoteEdits.insert({
id: genId(),

View File

@ -85,18 +85,27 @@ export async function importMastoPost(
userId: user.id,
});
// FIXME: What is this condition?
if (note != null && (note.fileIds?.length || 0) < files.length) {
// If an import is completely successful at once, the order should not be out of order.
// If it takes multiple imports to complete, the order is not guaranteed to be consistent.
if (note != null && files.length > 0) {
const addFiles: DriveFile[] = [];
for (const file of files) {
if (!note.fileIds.includes(file.id)) {
addFiles.push(file);
}
}
const update: Partial<Note> = {};
update.fileIds = files.map((x) => x.id);
update.fileIds = addFiles.map((x) => x.id);
if (update.fileIds != null) {
await NoteFiles.delete({ noteId: note.id });
await NoteFiles.insert(
update.fileIds.map((fileId) => ({ noteId: note?.id, fileId })),
);
}
update.fileIds = note.fileIds.concat(update.fileIds);
await Notes.update(note.id, update);
await NoteEdits.insert({
id: genId(),