Skip to content

Commit 45d8b9d

Browse files
Fix for mouse, next config, albums blob size limitation, cache to 10min
Co-Authored-By: Srikant Sahoo <srikantsahoo3601@gmail.com>
1 parent 1cedf30 commit 45d8b9d

File tree

5 files changed

+79
-13
lines changed

5 files changed

+79
-13
lines changed

app/gallery/apps/albumsApp.jsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const IDENTIFY_USER = 'userLogIn';
1616
export const GET_CURRENT_TIME = () => new Date().toISOString();
1717
const DRAFT_NEW_ALBUM_TAG = 'new-album-draft';
1818
const ALBUMS_BLOB = 'albumsBlob';
19+
const UNIQUE_LOGIN_USER = uniqueName();
1920

2021
export const MUTATIONS = {
2122
CREATE_ALBUM: 'CREATE_ALBUM',
@@ -111,7 +112,7 @@ export const updateAlbumBlob = async ({
111112

112113
// to identify a User Login created album and create a default
113114
if (!props.localStorageID) {
114-
const uniqueUserID = uniqueName();
115+
const uniqueUserID = UNIQUE_LOGIN_USER;
115116
typeof window !== 'undefined' ? window?.localStorage.setItem(IDENTIFY_USER, uniqueUserID) : false;
116117
updateAlbums({
117118
uniqueUserID,
@@ -121,8 +122,13 @@ export const updateAlbumBlob = async ({
121122
});
122123
}
123124
if (props.localStorageID === 'delete-all-albums') await uploadAlbumAction({ parameters: { name: ALBUMS_BLOB } });
125+
if (props.localStorageID === 'cleanup-all-albums') await uploadAlbumAction({ parameters: { name: ALBUMS_BLOB } });
124126

125127
const prepareObj = (obj) => {
128+
Object.keys(existingBlobData ?? {}).forEach((key) => {
129+
if (existingBlobData[key] && existingBlobData[key]?.albums && existingBlobData[key]?.albums['All Photos'])
130+
delete existingBlobData[key]?.albums['All Photos']; // to decrease the payload size
131+
});
126132
if (obj['All Photos']) delete obj['All Photos']; // to decrease the payload size
127133

128134
console.log('uploading ', { obj });
@@ -357,9 +363,15 @@ export const AlbumsAppContent = ({ selectedTab, setActiveApp, activeApp }) => {
357363
)}
358364
</div>
359365
{Object.keys(userAlbums ?? {})?.length ? (
360-
<div style={styles.containerWrapper}>
366+
<div
367+
style={{ ...styles.containerWrapper, height: 370, overflow: 'auto' }}
368+
className="photosContainer"
369+
>
361370
{otherUserAlbumTabHomePage && (
362-
<div style={{ ...styles.albumContainer, height: 370 }} className="photosContainer">
371+
<div
372+
style={{ ...styles.albumContainer, height: 370, overflow: 'auto' }}
373+
className="photosContainer"
374+
>
363375
{Object.keys(blobData ?? {})
364376
?.filter((d) => d !== localStorageID)
365377
?.map((blobUser, k) => {

app/gallery/apps/srikantApp.jsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,26 @@ const References = () => {
121121
</>
122122
)
123123
},
124+
// {
125+
// id: 3,
126+
// text: 'UI Inspiration | Dribbble shot by Andrae Waters',
127+
// url: 'https://dribbble.com/shots/23218407-Apple-Vision-Pro-AR-Photo-Gallery',
128+
// description: (
129+
// <>
130+
// These are directly served from wikipedia random article API
131+
// https://en.wikipedia.org/api/rest_v1/page/random/summary using SSR(Server Side Rendering technique
132+
// of Next JS), and the cache is revalidated by clicking the <code>Next Article</code> button.
133+
// </>
134+
// )
135+
// },
124136
{
125137
id: 4,
126-
text: 'Please vote my submission of Netlify dynamic site challenge in Dev.to.',
138+
text: 'Please refer my submission of Netlify dynamic site challenge in Dev.to.',
127139
url: 'https://dev.to/srikant_code',
128140
description: (
129141
<>
130-
I will open source the code if it gets selected. It would also motivate me to continue doing further
131-
such work😄. You can connect with me here{' '}
142+
I will open source the UI code if it gets selected. It would also motivate me to continue doing
143+
further such work😄. You can connect with me here{' '}
132144
<ExternalLink href="https://www.linkedin.com/in/srikant-design/">LinkedIn</ExternalLink> |{' '}
133145
<ExternalLink href="https://twitter.com/srikant_design">Twitter</ExternalLink>
134146
</>

app/gallery/pageContent.jsx

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import Image from 'next/image';
44
import { Button, ExternalLink, ReuseCSS } from './common';
5-
import { useState } from 'react';
5+
import { useEffect, useState } from 'react';
66
import { GalleryAppContent as MemoriesAppContent } from './apps/memoriesApp';
77
import { NewsAppContent } from './apps/discoverApp';
88
import { SrikantAppContent } from './apps/srikantApp';
@@ -68,11 +68,11 @@ export const APP = {
6868
This project is a hobby endeavor that I&apos;m proud of, and I hope it helps you understand the
6969
potential of Netlify&apos;s capabilities. <br />
7070
It took me more than 5 days to build this. I will be putting up what all challenges I have faced during
71-
the development of this in the submission article. Would really appreciate if you liked it and can vote
72-
my submission here 👇
71+
the development of this, and more details of implementation in the submission article. Would really
72+
appreciate if you liked it and can vote my submission here 👇
7373
<br />
7474
<Button>
75-
<ExternalLink href={'https://dev.to/srikant_code'}>Please vote here😄</ExternalLink>
75+
<ExternalLink href={'https://dev.to/srikant_code'}>Please give a 👍 here😄</ExternalLink>
7676
</Button>
7777
<br /> You can connect with me anytime here{' '}
7878
<ExternalLink href="https://www.linkedin.com/in/srikant-design/">LinkedIn</ExternalLink> |{' '}
@@ -91,6 +91,8 @@ export const PageContent = (props) => {
9191
const [activeApp, setActiveApp] = useState(0);
9292
// console.log({ props });
9393

94+
typeof window !== 'undefined' ? !window.location.origin?.includes('localhost') && (console.log = () => {}) : null;
95+
9496
const internalStyles = {
9597
main: {
9698
...ReuseCSS.font,
@@ -108,6 +110,7 @@ export const PageContent = (props) => {
108110
return (
109111
<main style={internalStyles.main}>
110112
<Background />
113+
<Mouse />
111114
{Object.keys(APP).map((appKey, id) => {
112115
return (
113116
<AppTemplate
@@ -319,7 +322,8 @@ export const Background = () => {
319322
overflow: 'hidden',
320323
width: '100vw',
321324
position: 'absolute',
322-
transition: `all 0.2s linear`
325+
transition: `all 0.2s linear`,
326+
filter: `brightness(60%)`
323327
}
324328
};
325329
return (
@@ -361,3 +365,41 @@ export const Modal = ({ children, style, open, onClose }) => {
361365
</>
362366
);
363367
};
368+
369+
const Mouse = () => {
370+
const [cursorPosition, setCursorPosition] = useState({ x: 0, y: 0 });
371+
372+
// Update cursor position on mouse move
373+
const handleMouseMove = (e) => {
374+
setCursorPosition({ x: e.clientX - 25, y: e.clientY - 25 });
375+
};
376+
377+
useEffect(() => {
378+
// Add event listener for mousemove
379+
typeof window !== 'undefined' ? window.addEventListener('mousemove', handleMouseMove) : null;
380+
381+
// Clean up the event listener when component unmounts
382+
return () => {
383+
typeof window !== 'undefined' ? window.removeEventListener('mousemove', handleMouseMove) : null;
384+
};
385+
}, []);
386+
387+
// {/* Your other components go here */}
388+
return (
389+
<div
390+
style={{
391+
position: 'absolute',
392+
left: cursorPosition.x,
393+
top: cursorPosition.y,
394+
width: 50,
395+
height: 50,
396+
borderRadius: '50%',
397+
pointerEvents: 'none', // Prevent the circle from blocking interactions
398+
backgroundColor: `rgba(147, 147, 147, 0.26)`,
399+
zIndex: 10000,
400+
border: `2px solid rgba(0, 210, 159, 0.69)`,
401+
transition: `all 0.2s ease 0s`
402+
}}
403+
/>
404+
);
405+
};

app/page.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const ctx = getNetlifyContext();
88
const tagName = 'randomWiki';
99
const randomWikiUrl = 'https://en.wikipedia.org/api/rest_v1/page/random/summary';
1010
const maxExtractLength = 200;
11-
const revalidateTTL = 60;
11+
const revalidateTTL = 600;
1212

1313
import { revalidateTag } from 'next/cache';
1414
import { PageContent } from './gallery/pageContent';

next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const nextConfig = {
2727
},
2828
experimental: {
2929
serverActions: {
30-
bodySizeLimit: '12mb'
30+
bodySizeLimit: '50mb'
3131
}
3232
}
3333
};

0 commit comments

Comments
 (0)