Compare commits
6 Commits
321cf5b978
...
421ec6c8d0
Author | SHA1 | Date |
---|---|---|
laozhoubuluo | 421ec6c8d0 | |
naskya | af14bee31f | |
naskya | b3d1be457b | |
Lhcfl | 272e30be0c | |
naskya | 2c6466b0dc | |
老周部落 | 1852324054 |
|
@ -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
|
||||
|
||||
|
|
|
@ -5,6 +5,11 @@ Critical security updates are indicated by the :warning: icon.
|
|||
- Server administrators should check [notice-for-admins.md](./notice-for-admins.md) as well.
|
||||
- Third-party client/bot developers may want to check [api-change.md](./api-change.md) as well.
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Improve timeline UX
|
||||
- Fix bugs
|
||||
|
||||
## [v20240504](https://firefish.dev/firefish/firefish/-/merge_requests/10790/commits)
|
||||
|
||||
- Fix bugs
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -25,15 +25,21 @@ const props = withDefaults(
|
|||
},
|
||||
);
|
||||
|
||||
function getDateSafe(n: Date | string | number) {
|
||||
try {
|
||||
if (n instanceof Date) {
|
||||
return n;
|
||||
}
|
||||
return new Date(n);
|
||||
} catch (err) {
|
||||
return {
|
||||
getTime: () => Number.NaN,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const _time = computed(() =>
|
||||
props.time == null
|
||||
? Number.NaN
|
||||
: typeof props.time === "number"
|
||||
? props.time
|
||||
: (props.time instanceof Date
|
||||
? props.time
|
||||
: new Date(props.time)
|
||||
).getTime(),
|
||||
props.time == null ? Number.NaN : getDateSafe(props.time).getTime(),
|
||||
);
|
||||
const invalid = computed(() => Number.isNaN(_time.value));
|
||||
const absolute = computed(() =>
|
||||
|
@ -41,45 +47,57 @@ const absolute = computed(() =>
|
|||
);
|
||||
|
||||
const now = ref(props.origin?.getTime() ?? Date.now());
|
||||
|
||||
const relative = computed<string>(() => {
|
||||
if (props.mode === "absolute") return ""; // absoluteではrelativeを使わないので計算しない
|
||||
if (invalid.value) return i18n.ts._ago.invalid;
|
||||
|
||||
const ago = (now.value - _time.value) / 1000; /* ms */
|
||||
return ago >= 31536000
|
||||
? i18n.t("_ago.yearsAgo", { n: Math.floor(ago / 31536000).toString() })
|
||||
: ago >= 2592000
|
||||
? i18n.t("_ago.monthsAgo", {
|
||||
n: Math.floor(ago / 2592000).toString(),
|
||||
})
|
||||
: ago >= 604800
|
||||
? i18n.t("_ago.weeksAgo", {
|
||||
n: Math.floor(ago / 604800).toString(),
|
||||
})
|
||||
: ago >= 86400
|
||||
? i18n.t("_ago.daysAgo", {
|
||||
n: Math.floor(ago / 86400).toString(),
|
||||
})
|
||||
: ago >= 3600
|
||||
? i18n.t("_ago.hoursAgo", {
|
||||
n: Math.floor(ago / 3600).toString(),
|
||||
})
|
||||
: ago >= 60
|
||||
? i18n.t("_ago.minutesAgo", {
|
||||
n: (~~(ago / 60)).toString(),
|
||||
})
|
||||
: ago >= 10
|
||||
? i18n.t("_ago.secondsAgo", {
|
||||
n: (~~(ago % 60)).toString(),
|
||||
})
|
||||
: ago >= -1
|
||||
? i18n.ts._ago.justNow
|
||||
: i18n.ts._ago.future;
|
||||
|
||||
if (ago >= 31536000) {
|
||||
return i18n.t("_ago.yearsAgo", {
|
||||
n: Math.floor(ago / 31536000).toString(),
|
||||
});
|
||||
}
|
||||
if (ago >= 2592000) {
|
||||
return i18n.t("_ago.monthsAgo", {
|
||||
n: Math.floor(ago / 2592000).toString(),
|
||||
});
|
||||
}
|
||||
if (ago >= 604800) {
|
||||
return i18n.t("_ago.weeksAgo", {
|
||||
n: Math.floor(ago / 604800).toString(),
|
||||
});
|
||||
}
|
||||
if (ago >= 86400) {
|
||||
return i18n.t("_ago.daysAgo", {
|
||||
n: Math.floor(ago / 86400).toString(),
|
||||
});
|
||||
}
|
||||
if (ago >= 3600) {
|
||||
return i18n.t("_ago.hoursAgo", {
|
||||
n: Math.floor(ago / 3600).toString(),
|
||||
});
|
||||
}
|
||||
if (ago >= 60) {
|
||||
return i18n.t("_ago.minutesAgo", {
|
||||
n: (~~(ago / 60)).toString(),
|
||||
});
|
||||
}
|
||||
if (ago >= 10) {
|
||||
return i18n.t("_ago.secondsAgo", {
|
||||
n: (~~(ago % 60)).toString(),
|
||||
});
|
||||
}
|
||||
if (ago >= -1) {
|
||||
return i18n.ts._ago.justNow;
|
||||
}
|
||||
return i18n.ts._ago.future;
|
||||
});
|
||||
|
||||
let tickId: number | undefined;
|
||||
|
||||
function tick() {
|
||||
function tick(forceUpdateTicker = false) {
|
||||
if (
|
||||
invalid.value ||
|
||||
props.origin ||
|
||||
|
@ -101,13 +119,16 @@ function tick() {
|
|||
|
||||
if (!tickId) {
|
||||
tickId = window.setInterval(tick, next);
|
||||
} else if (prev < next) {
|
||||
} else if (prev < next || forceUpdateTicker) {
|
||||
window.clearInterval(tickId);
|
||||
tickId = window.setInterval(tick, next);
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.time, tick);
|
||||
watch(
|
||||
() => props.time,
|
||||
() => tick(true),
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
tick();
|
||||
|
|
Loading…
Reference in New Issue