Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
improve seeking of comments (#1094)
Ameer Al Ashhab5c4d36b1604b
diff --git a/apps/web/actions/videos/new-comment.ts b/apps/web/actions/videos/new-comment.tsindex 82d6cc568..85a4466f7 100644--- a/apps/web/actions/videos/new-comment.ts+++ b/apps/web/actions/videos/new-comment.ts@@ -43,7 +43,7 @@ export async function newComment(data: {type: type,content: content,videoId: videoId,- timestamp: timestamp || null,+ timestamp: timestamp ?? null,parentCommentId: parentCommentId,createdAt: new Date(),updatedAt: new Date(),diff --git a/apps/web/app/s/[videoId]/Share.tsx b/apps/web/app/s/[videoId]/Share.tsxindex 1b675b878..9ee7cac6c 100644--- a/apps/web/app/s/[videoId]/Share.tsx+++ b/apps/web/app/s/[videoId]/Share.tsx@@ -214,55 +214,39 @@ export const Share = ({const aiLoading = shouldShowLoading();const handleSeek = useCallback((time: number) => {- let video = playerRef.current;-- // Fallback to DOM query if ref is not available- if (!video) {- video = document.querySelector("video") as HTMLVideoElement;- if (!video) {- console.warn("Video player not ready");- return;- }+ const v =+ playerRef.current ??+ (document.querySelector("video") as HTMLVideoElement | null);+ if (!v) {+ console.warn("Video player not ready");+ return;}-- // Try to seek immediately if video has metadata- if (video.readyState >= 1) {- // HAVE_METADATA+ const seekOnce = (t: number) => {+ const dur =+ Number.isFinite(v.duration) && v.duration > 0 ? v.duration : null;+ const clamped = dur ? Math.max(0, Math.min(dur - 0.001, t)) : t;try {- video.currentTime = time;- return;- } catch (error) {- console.error("Failed to seek video:", error);+ v.currentTime = clamped;+ } catch (e) {+ console.error("Failed to seek video:", e);}- }-- // If video isn't ready, wait for it to be ready- const handleCanPlay = () => {- try {- video.currentTime = time;- } catch (error) {- console.error("Failed to seek video after canplay:", error);- }- video.removeEventListener("canplay", handleCanPlay);};-- const handleLoadedMetadata = () => {- try {- video.currentTime = time;- } catch (error) {- console.error("Failed to seek video after loadedmetadata:", error);- }- video.removeEventListener("loadedmetadata", handleLoadedMetadata);+ if (v.readyState >= 1) {+ seekOnce(time);+ return;+ }+ let timeoutId: ReturnType<typeof setTimeout> | null = null;+ const handleReady = () => {+ seekOnce(time);+ v.removeEventListener("canplay", handleReady);+ v.removeEventListener("loadedmetadata", handleReady);+ if (timeoutId) clearTimeout(timeoutId);};-- // Listen for multiple events to ensure we catch when the video is ready- video.addEventListener("canplay", handleCanPlay);- video.addEventListener("loadedmetadata", handleLoadedMetadata);-- // Cleanup after 3 seconds if events don't fire- setTimeout(() => {- video.removeEventListener("canplay", handleCanPlay);- video.removeEventListener("loadedmetadata", handleLoadedMetadata);+ v.addEventListener("canplay", handleReady, { once: true });+ v.addEventListener("loadedmetadata", handleReady, { once: true });+ timeoutId = setTimeout(() => {+ v.removeEventListener("canplay", handleReady);+ v.removeEventListener("loadedmetadata", handleReady);}, 3000);}, []);diff --git a/apps/web/app/s/[videoId]/page.tsx b/apps/web/app/s/[videoId]/page.tsxindex 3810fdc2c..aa26626fc 100644--- a/apps/web/app/s/[videoId]/page.tsx+++ b/apps/web/app/s/[videoId]/page.tsx@@ -372,7 +372,6 @@ async function AuthorizedContent({});} catch (error) {console.warn("Failed to create view notification:", error);- // Don't throw the error, just log it since this is not critical for the page to function}}diff --git a/apps/web/lib/Notification.ts b/apps/web/lib/Notification.tsindex 62a141572..503574a2a 100644--- a/apps/web/lib/Notification.ts+++ b/apps/web/lib/Notification.ts@@ -32,7 +32,6 @@ export async function createNotification(notification: CreateNotificationInput,) {try {- // First, check if the video existsconst [videoExists] = await db().select({ id: videos.id, ownerId: videos.ownerId }).from(videos)@@ -44,7 +43,6 @@ export async function createNotification(throw new Error(`Video not found for videoId: ${notification.videoId}`);}- // Then get the owner dataconst [ownerResult] = await db().select({id: users.id,@@ -63,8 +61,6 @@ export async function createNotification(videoExists.ownerId,"- skipping notification creation",);- // Don't throw an error, just skip notification creation- // This handles cases where the video exists but the owner was deletedreturn;}