added sync indicator for q-apps

This commit is contained in:
PhilReact 2024-11-05 11:45:00 +02:00
parent 9b9facb711
commit 1b8137fe35
8 changed files with 55 additions and 18 deletions

View File

@ -651,6 +651,9 @@ function App() {
if (message.action === "QORTAL_REQUEST_PERMISSION") { if (message.action === "QORTAL_REQUEST_PERMISSION") {
try { try {
await showQortalRequestExtension(message?.payload); await showQortalRequestExtension(message?.payload);
if(message?.payload?.checkbox1){
qortalRequestCheckbox1Ref.current = message?.payload?.checkbox1
}
if (qortalRequestCheckbox1Ref.current) { if (qortalRequestCheckbox1Ref.current) {
event.source.postMessage( event.source.postMessage(
{ {

View File

@ -111,7 +111,7 @@ export const groupApi = "https://ext-node.qortal.link";
export const groupApiSocket = "wss://ext-node.qortal.link"; export const groupApiSocket = "wss://ext-node.qortal.link";
export const groupApiLocal = "http://127.0.0.1:12391"; export const groupApiLocal = "http://127.0.0.1:12391";
export const groupApiSocketLocal = "ws://127.0.0.1:12391"; export const groupApiSocketLocal = "ws://127.0.0.1:12391";
const timeDifferenceForNotificationChatsBackground = 600000; const timeDifferenceForNotificationChatsBackground = 86400000;
const requestQueueAnnouncements = new RequestQueueWithPromise(1); const requestQueueAnnouncements = new RequestQueueWithPromise(1);
let isMobile = true; let isMobile = true;
@ -3212,4 +3212,27 @@ export const checkThreads = async (bringBack) => {
// BackgroundFetch.finish(taskId); // BackgroundFetch.finish(taskId);
// }); // });
let notificationCheckInterval
const createNotificationCheck = () => {
// Check if an interval already exists before creating it
if (!notificationCheckInterval) {
notificationCheckInterval = setInterval(async () => {
try {
// This would replace the Chrome alarm callback
const wallet = await getSaveWallet();
const address = wallet?.address0;
if (!address) return;
checkActiveChatsForNotifications();
checkNewMessages();
checkThreads();
} catch (error) {
console.error('Error checking notifications:', error);
}
}, 10 * 60 * 1000); // 10 minutes
}
};
// Call this function when initializing your app
createNotificationCheck();

View File

@ -20,6 +20,7 @@ import { HomeIcon } from "../../assets/Icons/HomeIcon";
import { MessagingIcon } from "../../assets/Icons/MessagingIcon"; import { MessagingIcon } from "../../assets/Icons/MessagingIcon";
import { Save } from "../Save/Save"; import { Save } from "../Save/Save";
import { HubsIcon } from "../../assets/Icons/HubsIcon"; import { HubsIcon } from "../../assets/Icons/HubsIcon";
import { CoreSyncStatus } from "../CoreSyncStatus";
const uid = new ShortUniqueId({ length: 8 }); const uid = new ShortUniqueId({ length: 8 });
@ -299,7 +300,7 @@ export const AppsDesktop = ({ mode, setMode, show , myName, goToHome, setDesktop
height: '100vh', height: '100vh',
alignItems: 'center', alignItems: 'center',
display: 'flex', display: 'flex',
gap: '30px' gap: '25px'
}}> }}>
<ButtonBase <ButtonBase
sx={{ sx={{
@ -356,7 +357,9 @@ export const AppsDesktop = ({ mode, setMode, show , myName, goToHome, setDesktop
/> />
</ButtonBase> </ButtonBase>
<Save isDesktop /> <Save isDesktop disableWidth />
<CoreSyncStatus imageSize="30px" position="left" />
{mode !== 'home' && ( {mode !== 'home' && (
<AppsNavBarDesktop /> <AppsNavBarDesktop />

View File

@ -21,6 +21,7 @@ import { MessagingIcon } from "../../assets/Icons/MessagingIcon";
import { Save } from "../Save/Save"; import { Save } from "../Save/Save";
import { HubsIcon } from "../../assets/Icons/HubsIcon"; import { HubsIcon } from "../../assets/Icons/HubsIcon";
import { AppsDevModeNavBar } from "./AppsDevModeNavBar"; import { AppsDevModeNavBar } from "./AppsDevModeNavBar";
import { CoreSyncStatus } from "../CoreSyncStatus";
const uid = new ShortUniqueId({ length: 8 }); const uid = new ShortUniqueId({ length: 8 });
@ -191,7 +192,7 @@ export const AppsDevMode = ({ mode, setMode, show , myName, goToHome, setDesktop
height: '100vh', height: '100vh',
alignItems: 'center', alignItems: 'center',
display: 'flex', display: 'flex',
gap: '30px' gap: '25px'
}}> }}>
<ButtonBase <ButtonBase
sx={{ sx={{
@ -248,7 +249,8 @@ export const AppsDevMode = ({ mode, setMode, show , myName, goToHome, setDesktop
/> />
</ButtonBase> </ButtonBase>
<Save isDesktop /> <Save isDesktop disableWidth />
<CoreSyncStatus imageSize="30px" position="left" />
{mode !== 'home' && ( {mode !== 'home' && (
<AppsDevModeNavBar /> <AppsDevModeNavBar />

View File

@ -9,7 +9,7 @@
} }
.tooltip .bottom { .tooltip .bottom {
min-width: 200px; min-width: 225px;
max-width: 250px; max-width: 250px;
top: 35px; top: 35px;
right: 0px; right: 0px;

View File

@ -4,7 +4,7 @@ import syncedMintingImg from '../assets/syncStatus/synced.png'
import syncingImg from '../assets/syncStatus/synced.png' import syncingImg from '../assets/syncStatus/synced.png'
import { getBaseApiReact } from '../App'; import { getBaseApiReact } from '../App';
import './CoreSyncStatus.css' import './CoreSyncStatus.css'
export const CoreSyncStatus = () => { export const CoreSyncStatus = ({imageSize, position}) => {
const [nodeInfos, setNodeInfos] = useState({}); const [nodeInfos, setNodeInfos] = useState({});
const [coreInfos, setCoreInfos] = useState({}); const [coreInfos, setCoreInfos] = useState({});
const [isUsingGateway, setIsUsingGateway] = useState(false); const [isUsingGateway, setIsUsingGateway] = useState(false);
@ -68,22 +68,27 @@ export const CoreSyncStatus = () => {
imagePath = syncingImg imagePath = syncingImg
} else if (isSynchronizing && !isMintingPossible && syncPercent === 100) { } else if (isSynchronizing && !isMintingPossible && syncPercent === 100) {
imagePath = syncingImg; imagePath = syncingImg;
message = `Synchronized (Not Minting)` message = `Synchronizing ${isUsingGateway ? '' :'(Not Minting)'}`
} else if (!isSynchronizing && !isMintingPossible && syncPercent === 100) { } else if (!isSynchronizing && !isMintingPossible && syncPercent === 100) {
imagePath = syncedImg imagePath = syncedImg
message = `Synchronized (Not Minting)` message = `Synchronized ${isUsingGateway ? '' :'(Not Minting)'}`
} else if (isSynchronizing && isMintingPossible && syncPercent === 100) { } else if (isSynchronizing && isMintingPossible && syncPercent === 100) {
imagePath = syncedMintingImg; imagePath = syncingImg;
message = `Synchronized (Minting)` message = `Synchronizing ${isUsingGateway ? '' :'(Minting)'}`
} else if (!isSynchronizing && isMintingPossible && syncPercent === 100) { } else if (!isSynchronizing && isMintingPossible && syncPercent === 100) {
imagePath = syncedMintingImg; imagePath = syncedMintingImg;
message = `Synchronized (Minting)` message = `Synchronized ${isUsingGateway ? '' :'(Minting)'}`
} }
return ( return (
<div className="tooltip" style={{ display: 'inline' }}> <div className="tooltip" style={{ display: 'inline' }}>
<span><img src={imagePath} style={{ height: 'auto', width: '24px' }} alt="sync status" /></span> <span><img src={imagePath} style={{ height: 'auto', width: imageSize ? imageSize : '24px' }} alt="sync status" /></span>
<div className="bottom"> <div className="bottom" style={{
right: position && 'unset',
left: position && '0px'
}}>
<h3>Core Information</h3> <h3>Core Information</h3>
<h4 className="lineHeight">Core Version: <span style={{ color: '#03a9f4' }}>{buildVersion}</span></h4> <h4 className="lineHeight">Core Version: <span style={{ color: '#03a9f4' }}>{buildVersion}</span></h4>
<h4 className="lineHeight">{message}</h4> <h4 className="lineHeight">{message}</h4>

View File

@ -20,7 +20,7 @@ import { Save } from "../Save/Save";
import { useRecoilState } from "recoil"; import { useRecoilState } from "recoil";
import { enabledDevModeAtom } from "../../atoms/global"; import { enabledDevModeAtom } from "../../atoms/global";
export const IconWrapper = ({ children, label, color, selected }) => { export const IconWrapper = ({ children, label, color, selected, disableWidth }) => {
return ( return (
<Box <Box
sx={{ sx={{
@ -29,8 +29,8 @@ export const IconWrapper = ({ children, label, color, selected }) => {
alignItems: "center", alignItems: "center",
gap: "5px", gap: "5px",
flexDirection: "column", flexDirection: "column",
height: "89px", height: disableWidth ? 'auto' : "89px",
width: "89px", width: disableWidth ? 'auto' : "89px",
borderRadius: "50%", borderRadius: "50%",
backgroundColor: selected ? "rgba(28, 29, 32, 1)" : "transparent", backgroundColor: selected ? "rgba(28, 29, 32, 1)" : "transparent",
}} }}

View File

@ -16,7 +16,7 @@ import { getFee } from "../../background";
import { CustomizedSnackbars } from "../Snackbar/Snackbar"; import { CustomizedSnackbars } from "../Snackbar/Snackbar";
import { SaveIcon } from "../../assets/svgs/SaveIcon"; import { SaveIcon } from "../../assets/svgs/SaveIcon";
import { IconWrapper } from "../Desktop/DesktopFooter"; import { IconWrapper } from "../Desktop/DesktopFooter";
export const Save = ({ isDesktop }) => { export const Save = ({ isDesktop, disableWidth }) => {
const [pinnedApps, setPinnedApps] = useRecoilState(sortablePinnedAppsAtom); const [pinnedApps, setPinnedApps] = useRecoilState(sortablePinnedAppsAtom);
const [settingsQdnLastUpdated, setSettingsQdnLastUpdated] = useRecoilState( const [settingsQdnLastUpdated, setSettingsQdnLastUpdated] = useRecoilState(
settingsQDNLastUpdatedAtom settingsQDNLastUpdatedAtom
@ -160,6 +160,7 @@ export const Save = ({ isDesktop }) => {
> >
{isDesktop ? ( {isDesktop ? (
<IconWrapper <IconWrapper
disableWidth={disableWidth}
color="rgba(250, 250, 250, 0.5)" color="rgba(250, 250, 250, 0.5)"
label="Save" label="Save"
selected={false} selected={false}