mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 18:26:20 +01:00
Merge pull request #1057 from ilhamsyahids/master
Fix active users not appear
This commit is contained in:
commit
46cfab864c
@ -9,14 +9,18 @@ import styles from './ActiveUsers.module.css';
|
|||||||
|
|
||||||
export default function ActiveUsers({ websiteId, className, value, interval = 60000 }) {
|
export default function ActiveUsers({ websiteId, className, value, interval = 60000 }) {
|
||||||
const shareToken = useShareToken();
|
const shareToken = useShareToken();
|
||||||
const url = value !== undefined && websiteId ? `/website/${websiteId}/active` : null;
|
const url = websiteId ? `/website/${websiteId}/active` : null;
|
||||||
const { data } = useFetch(url, {
|
const { data } = useFetch(url, {
|
||||||
interval,
|
interval,
|
||||||
headers: { [TOKEN_HEADER]: shareToken?.token },
|
headers: { [TOKEN_HEADER]: shareToken?.token },
|
||||||
});
|
});
|
||||||
const count = useMemo(() => {
|
const count = useMemo(() => {
|
||||||
return value || data?.[0]?.x || 0;
|
if (websiteId) {
|
||||||
}, [data, value]);
|
return data?.[0]?.x || 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return value !== undefined ? value : 0;
|
||||||
|
}, [data, value, websiteId]);
|
||||||
|
|
||||||
if (count === 0) {
|
if (count === 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -33,7 +33,7 @@ export default function RealtimeHeader({ websites, data, websiteId, onSelect })
|
|||||||
<FormattedMessage id="label.realtime" defaultMessage="Realtime" />
|
<FormattedMessage id="label.realtime" defaultMessage="Realtime" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ActiveUsers className={styles.active} value={count} />
|
<ActiveUsers className={styles.active} value={count} websiteId={websiteId} />
|
||||||
</div>
|
</div>
|
||||||
<DropDown value={websiteId} options={options} onChange={onSelect} />
|
<DropDown value={websiteId} options={options} onChange={onSelect} />
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
|
Loading…
Reference in New Issue
Block a user