Fix PR 3 review findings [skip ci]
This commit is contained in:
1 parent
590178e41a
commit
454620f21e
21 files changed
+522
-160
No files matched your search
@@ -88,9 +88,11 @@
|
||||
}
|
||||
|
||||
async function handleLikePost(post: UserPost) {
|
||||
if (post.liked_by_me) return;
|
||||
try {
|
||||
await invoke('like_user_post', { postId: post.id });
|
||||
post.likes_count += 1;
|
||||
const liked = await invoke<boolean>('like_user_post', { postId: post.id });
|
||||
if (liked) post.likes_count += 1;
|
||||
post.liked_by_me = true;
|
||||
} catch (e: any) {
|
||||
toast(e?.message ?? 'Failed to update like', 'error');
|
||||
}
|
||||
|
||||
@@ -106,9 +106,9 @@
|
||||
return `${hours}h ${mins}m`;
|
||||
} else {
|
||||
const day = now.getUTCDay();
|
||||
const daysUntilSunday = (7 - day) % 7 || 7;
|
||||
const nextSunday = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + daysUntilSunday));
|
||||
const diffMs = nextSunday.getTime() - now.getTime();
|
||||
const daysUntilMonday = (8 - day) % 7 || 7;
|
||||
const nextMonday = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + daysUntilMonday));
|
||||
const diffMs = nextMonday.getTime() - now.getTime();
|
||||
const days = Math.floor(diffMs / (1000 * 60 * 60 * 24));
|
||||
const hours = Math.floor((diffMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||||
return `${days}d ${hours}h`;
|
||||
|
||||
Reference in new issue
Block a user