diff --git a/src/renderer/context/LinksContext.js b/src/renderer/context/LinksContext.js
index c699c99..c1fc82a 100644
--- a/src/renderer/context/LinksContext.js
+++ b/src/renderer/context/LinksContext.js
@@ -27,16 +27,20 @@ export const LinksContextProvider = ({ children }) => {
url
);
- addNotification(url, 'thinking', 'Generating preview...');
-
// return cached preview if available
if (preview) {
return preview;
}
- updateNotification(url, 'waiting', 'Generating preview...');
+ addNotification({
+ id: url,
+ type: 'waiting',
+ message: 'Creating link preview',
+ });
+
// otherwise generate a new preview
const _preview = await getPreview(url);
+ updateNotification(url, 'thinking', 'Generating preview...');
const aiCard = await generateMeta(url).catch(() => {
console.log(
'Failed to generate AI link preview, a basic preview will be used.'
@@ -47,10 +51,10 @@ export const LinksContextProvider = ({ children }) => {
const linkPreview = {
url: url,
createdAt: new Date().toISOString(),
- title: _preview.title ?? '',
- images: _preview.images ?? [],
- favicon: _preview.favicon ?? '',
- host: _preview.host ?? '',
+ title: _preview?.title ?? '',
+ images: _preview?.images ?? [],
+ favicon: _preview?.favicon ?? '',
+ host: _preview?.host ?? '',
description: aiCard?.summary ?? '',
summary: '',
aiCard: aiCard ?? null,
@@ -59,6 +63,8 @@ export const LinksContextProvider = ({ children }) => {
// cache it
setLink(url, linkPreview);
+ removeNotification(url);
+
return linkPreview;
},
[currentPile]
diff --git a/src/renderer/context/ToastsContext.js b/src/renderer/context/ToastsContext.js
index c5bb5d5..a071811 100644
--- a/src/renderer/context/ToastsContext.js
+++ b/src/renderer/context/ToastsContext.js
@@ -10,45 +10,49 @@ import {
export const ToastsContext = createContext();
export const ToastsContextProvider = ({ children }) => {
- // this keeps track of async tasks that the user is notified about
- // by the AI. This can include general app notifications as well.
- const [notifications, setNotifications] = useState([]);
- const notificationTimeoutsRef = useRef({});
+ const [notificationsQueue, setNotificationsQueue] = useState([]);
+
+ const notificationTimeoutRef = useRef();
+
+ const processQueue = () => {
+ if (notificationsQueue.length > 0) {
+ // Set a timeout to dismiss the first notification
+ notificationTimeoutRef.current = setTimeout(() => {
+ setNotificationsQueue((currentQueue) => currentQueue.slice(1));
+ }, notificationsQueue[0].dismissTime || 5000); // Default 5 seconds
+ }
+ };
useEffect(() => {
+ // Clear any existing timeouts
+ if (notificationTimeoutRef.current) {
+ clearTimeout(notificationTimeoutRef.current);
+ notificationTimeoutRef.current = null;
+ }
+
+ processQueue();
+
+ // Clean up timeout on unmount
return () => {
- Object.values(notificationTimeoutsRef.current).forEach(clearTimeout);
+ if (notificationTimeoutRef.current) {
+ clearTimeout(notificationTimeoutRef.current);
+ }
};
- }, []);
+ }, [notificationsQueue]);
- const addNotification = (
- targetId,
+ const addNotification = ({
+ id,
type = 'info',
message,
- autoDismiss = true
- ) => {
- const newNotification = { id: targetId, type, message, autoDismiss };
-
- setNotifications((currentNotifications) => [
- ...currentNotifications,
- newNotification,
- ]);
-
- if (autoDismiss) {
- if (notificationTimeoutsRef.current[targetId]) {
- clearTimeout(notificationTimeoutsRef.current[targetId]);
- }
-
- notificationTimeoutsRef.current[targetId] = setTimeout(() => {
- removeNotification(targetId);
- delete notificationTimeoutsRef.current[targetId];
- }, 30000);
- }
+ dismissTime = 5000,
+ }) => {
+ const newNotification = { id, type, message, dismissTime };
+ setNotificationsQueue((currentQueue) => [...currentQueue, newNotification]);
};
const updateNotification = (targetId, newType, newMessage) => {
- setNotifications((currentNotifications) =>
- currentNotifications.map((notification) =>
+ setNotificationsQueue((currentQueue) =>
+ currentQueue.map((notification) =>
notification.id === targetId
? { ...notification, type: newType, message: newMessage }
: notification
@@ -57,19 +61,24 @@ export const ToastsContextProvider = ({ children }) => {
};
const removeNotification = (targetId) => {
- setNotifications((currentNotifications) =>
- currentNotifications.filter(
- (notification) => notification.id !== targetId
- )
+ setNotificationsQueue((currentQueue) =>
+ currentQueue.filter((notification) => notification.id !== targetId)
);
- if (notificationTimeoutsRef.current[targetId]) {
- clearTimeout(notificationTimeoutsRef.current[targetId]);
- delete notificationTimeoutsRef.current[targetId];
+
+ // If the notification being removed is the first in the queue, we need to clear the timeout
+ // and process the next notification if available
+ if (
+ notificationsQueue.length > 0 &&
+ notificationsQueue[0].id === targetId
+ ) {
+ clearTimeout(notificationTimeoutRef.current);
+ notificationTimeoutRef.current = null;
+ processQueue();
}
};
const ToastsContextValue = {
- notifications,
+ notifications: notificationsQueue,
addNotification,
updateNotification,
removeNotification,
diff --git a/src/renderer/pages/Pile/Highlights/index.jsx b/src/renderer/pages/Pile/Highlights/index.jsx
index c210080..9846bba 100644
--- a/src/renderer/pages/Pile/Highlights/index.jsx
+++ b/src/renderer/pages/Pile/Highlights/index.jsx
@@ -5,6 +5,7 @@ import * as Dialog from '@radix-ui/react-dialog';
import { useAIContext } from 'renderer/context/AIContext';
import { useHighlightsContext } from 'renderer/context/HighlightsContext';
+// UNDER CONSTRUCTION
export default function HighlightsDialog() {
const { open, onOpenChange } = useHighlightsContext();
diff --git a/src/renderer/pages/Pile/Layout.tsx b/src/renderer/pages/Pile/Layout.tsx
index 16e5cfc..c71f9c7 100644
--- a/src/renderer/pages/Pile/Layout.tsx
+++ b/src/renderer/pages/Pile/Layout.tsx
@@ -57,18 +57,18 @@ export default function PileLayout({ children }) {
{pileName} ยท {now}
+
-
+ {/* */}
{children}
-
);
}
diff --git a/src/renderer/pages/Pile/PileLayout.module.scss b/src/renderer/pages/Pile/PileLayout.module.scss
index 0169f5a..878f7fd 100644
--- a/src/renderer/pages/Pile/PileLayout.module.scss
+++ b/src/renderer/pages/Pile/PileLayout.module.scss
@@ -229,14 +229,13 @@
align-items: center;
justify-content: center;
height: 32px;
- width: 36px;
+ min-width: 36px;
border-radius: 8px;
transition: all ease-in-out 120ms;
-webkit-app-region: none;
background: transparent;
margin-right: -2px;
-
&:last-child {
margin-right: 8px;
}
diff --git a/src/renderer/pages/Pile/Settings/Settings.module.scss b/src/renderer/pages/Pile/Settings/Settings.module.scss
index 768e2d9..cf1719d 100644
--- a/src/renderer/pages/Pile/Settings/Settings.module.scss
+++ b/src/renderer/pages/Pile/Settings/Settings.module.scss
@@ -3,7 +3,7 @@
align-items: center;
justify-content: center;
height: 32px;
- width: 36px;
+ min-width: 36px;
border-radius: 8px;
transition: all ease-in-out 120ms;
-webkit-app-region: none;
diff --git a/src/renderer/pages/Pile/Settings/index.jsx b/src/renderer/pages/Pile/Settings/index.jsx
index 9a21e78..a2ce05e 100644
--- a/src/renderer/pages/Pile/Settings/index.jsx
+++ b/src/renderer/pages/Pile/Settings/index.jsx
@@ -51,10 +51,6 @@ export default function Settings() {
className={styles.color1}
style={{ background: colors.primary }}
>
- {/* */}
);
});
diff --git a/src/renderer/pages/Pile/Toasts/Toast/Loaders/Info/index.jsx b/src/renderer/pages/Pile/Toasts/Toast/Loaders/Info/index.jsx
new file mode 100644
index 0000000..4f8076a
--- /dev/null
+++ b/src/renderer/pages/Pile/Toasts/Toast/Loaders/Info/index.jsx
@@ -0,0 +1,59 @@
+export default function Info(props) {
+ return (
+
+ );
+}
diff --git a/src/renderer/pages/Pile/Toasts/Toast/Loaders/Readme.md b/src/renderer/pages/Pile/Toasts/Toast/Loaders/Readme.md
new file mode 100644
index 0000000..2a41625
--- /dev/null
+++ b/src/renderer/pages/Pile/Toasts/Toast/Loaders/Readme.md
@@ -0,0 +1,11 @@
+The SVG loading animations used within Pile are from: https://github.com/SamHerbert/SVG-Loaders
+
+The MIT License (MIT)
+
+Copyright (c) 2014 Sam Herbert
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/src/renderer/pages/Pile/Toasts/Toast/Loaders/Thinking/index.jsx b/src/renderer/pages/Pile/Toasts/Toast/Loaders/Thinking/index.jsx
new file mode 100644
index 0000000..73b717b
--- /dev/null
+++ b/src/renderer/pages/Pile/Toasts/Toast/Loaders/Thinking/index.jsx
@@ -0,0 +1,33 @@
+export default function Thinking(props) {
+ return (
+
+ );
+}
diff --git a/src/renderer/pages/Pile/Toasts/Toast/Loaders/Waiting/index.jsx b/src/renderer/pages/Pile/Toasts/Toast/Loaders/Waiting/index.jsx
new file mode 100644
index 0000000..338db7a
--- /dev/null
+++ b/src/renderer/pages/Pile/Toasts/Toast/Loaders/Waiting/index.jsx
@@ -0,0 +1,28 @@
+export default function Waiting(props) {
+ return (
+
+ );
+}
diff --git a/src/renderer/pages/Pile/Toasts/Toast/Thinking/index.jsx b/src/renderer/pages/Pile/Toasts/Toast/Thinking/index.jsx
deleted file mode 100644
index 8efcccf..0000000
--- a/src/renderer/pages/Pile/Toasts/Toast/Thinking/index.jsx
+++ /dev/null
@@ -1,103 +0,0 @@
-export default function Thinking(props) {
- return (
-
- );
-}
diff --git a/src/renderer/pages/Pile/Toasts/Toast/Toast.module.scss b/src/renderer/pages/Pile/Toasts/Toast/Toast.module.scss
index 0c1aa91..0235cc4 100644
--- a/src/renderer/pages/Pile/Toasts/Toast/Toast.module.scss
+++ b/src/renderer/pages/Pile/Toasts/Toast/Toast.module.scss
@@ -1,18 +1,24 @@
.toast {
display: inline-flex;
align-items: center;
- margin: 0 auto;
- margin-bottom: 7px;
- background: var(--base);
- backdrop-filter: blur(30px);
- padding: 7px 18px 7px 12px;
- border-radius: 90px;
- font-size: 0.8em;
- text-align: center;
+ text-align: right;
+ font-size: 0.8rem;
.icon {
height: 18px;
width: 18px;
- margin-right: 8px;
+ margin-left: 10px;
+ }
+
+ &.info {
+ color: var(--primary);
+ }
+
+ &.waiting {
+ color: var(--secondary);
+ }
+
+ &.thinking {
+ color: var(--active);
}
}
\ No newline at end of file
diff --git a/src/renderer/pages/Pile/Toasts/Toast/Waiting/index.jsx b/src/renderer/pages/Pile/Toasts/Toast/Waiting/index.jsx
deleted file mode 100644
index 7e72999..0000000
--- a/src/renderer/pages/Pile/Toasts/Toast/Waiting/index.jsx
+++ /dev/null
@@ -1,105 +0,0 @@
-import styles from './Thinking.module.scss';
-
-export default function Thinking(props) {
- return (
-
- );
-}
diff --git a/src/renderer/pages/Pile/Toasts/Toast/index.jsx b/src/renderer/pages/Pile/Toasts/Toast/index.jsx
index ec92a83..8760bf2 100644
--- a/src/renderer/pages/Pile/Toasts/Toast/index.jsx
+++ b/src/renderer/pages/Pile/Toasts/Toast/index.jsx
@@ -2,19 +2,32 @@ import styles from './Toast.module.scss';
import { motion } from 'framer-motion';
import { useToastsContext } from 'renderer/context/ToastsContext';
import Logo from 'renderer/pages/Home/logo';
-import Thinking from './Thinking';
+import Thinking from './Loaders/Thinking';
+import Waiting from './Loaders/Waiting';
+import Info from './Loaders/Info';
export default function Toast({ notification }) {
+ const renderIcon = (type) => {
+ switch (type) {
+ case 'thinking':
+ return ;
+ case 'waiting':
+ return ;
+ default:
+ return ;
+ }
+ };
+
return (
-
-
+
{notification.message}
+ {renderIcon(notification.type)}
);
diff --git a/src/renderer/pages/Pile/Toasts/Toasts.module.scss b/src/renderer/pages/Pile/Toasts/Toasts.module.scss
index 3f748f4..5c01fad 100644
--- a/src/renderer/pages/Pile/Toasts/Toasts.module.scss
+++ b/src/renderer/pages/Pile/Toasts/Toasts.module.scss
@@ -1,12 +1,8 @@
.container {
- position: fixed;
- bottom: 10px;
- left: 0;
width: 100%;
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
- padding: 0 20px;
- z-index: 99;
+ padding: 0 6px;
}
\ No newline at end of file
diff --git a/src/renderer/pages/Pile/Toasts/index.jsx b/src/renderer/pages/Pile/Toasts/index.jsx
index b835462..5a0a4c4 100644
--- a/src/renderer/pages/Pile/Toasts/index.jsx
+++ b/src/renderer/pages/Pile/Toasts/index.jsx
@@ -8,14 +8,20 @@ export default function Toasts() {
const { notifications, addNotification } = useToastsContext();
const renderNotifications = () => {
- return notifications.map((n) => {
- return
;
+ if (notifications.length === 0) return;
+
+ return notifications.map((n, i) => {
+ if (i == 0) {
+ return
;
+ }
});
};
return (
-
{renderNotifications()}
+
+ {renderNotifications()}
+
);
}