|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
import React, { useState } from 'react' |
|
|
|
|
import React, { useEffect, useState } from 'react' |
|
|
|
|
import { StatusBarInterface } from './types' |
|
|
|
|
import GitStatus from './components/gitStatus' |
|
|
|
|
import AIStatus from './components/aiStatus' |
|
|
|
@ -11,8 +11,14 @@ export interface RemixUIStatusBarProps { |
|
|
|
|
statusBarPlugin: StatusBarInterface |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export type ScamAlert = { |
|
|
|
|
message: string |
|
|
|
|
url: string |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export function RemixUIStatusBar ({ statusBarPlugin }: RemixUIStatusBarProps) { |
|
|
|
|
const [showScamDetails, setShowScamDetails] = useState(false) |
|
|
|
|
const [scamAlerts, setScamAlerts] = useState<ScamAlert[]>([]) |
|
|
|
|
const { refs, context, floatingStyles } = useFloating({ |
|
|
|
|
open: showScamDetails, |
|
|
|
|
onOpenChange: setShowScamDetails, |
|
|
|
@ -32,15 +38,25 @@ export function RemixUIStatusBar ({ statusBarPlugin }: RemixUIStatusBarProps) { |
|
|
|
|
role |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
const abortController = new AbortController() |
|
|
|
|
const signal = abortController.signal |
|
|
|
|
async function getScamAlerts() { |
|
|
|
|
const response = await axios.get('https://raw.githubusercontent.com/remix-project-org/remix-dynamics/main/ide/scam-alerts.json', { signal }) |
|
|
|
|
if (signal.aborted) return |
|
|
|
|
const tips = response.data |
|
|
|
|
const index = Math.floor(Math.random() * (tips.length - 1)) |
|
|
|
|
// setTip(tips[index])
|
|
|
|
|
} |
|
|
|
|
useEffect(() => { |
|
|
|
|
const abortController = new AbortController() |
|
|
|
|
const signal = abortController.signal |
|
|
|
|
async function getScamAlerts() { |
|
|
|
|
const response = await axios.get('https://raw.githubusercontent.com/remix-project-org/remix-dynamics/main/ide/scam-alerts.json', { signal }) |
|
|
|
|
if (signal.aborted) return |
|
|
|
|
console.log('getScamAlerts', response) |
|
|
|
|
setScamAlerts(response.data.alerts) |
|
|
|
|
console.log('getScamAlerts', scamAlerts) |
|
|
|
|
} |
|
|
|
|
getScamAlerts() |
|
|
|
|
return () => { |
|
|
|
|
abortController.abort() |
|
|
|
|
} |
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
console.log('scamAlerts', scamAlerts) |
|
|
|
|
}, [scamAlerts]) |
|
|
|
|
|
|
|
|
|
const getGitBranchName = async () => { |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
@ -51,7 +67,7 @@ export function RemixUIStatusBar ({ statusBarPlugin }: RemixUIStatusBarProps) { |
|
|
|
|
<> |
|
|
|
|
{showScamDetails && ( |
|
|
|
|
<FloatingFocusManager context={context} modal={false}> |
|
|
|
|
<ScamDetails refs={refs} floatStyle={{ ...floatingStyles, minHeight: '300px', alignContent: 'center', paddingRight: '5px' }} getFloatingProps={getFloatingProps} /> |
|
|
|
|
<ScamDetails refs={refs} floatStyle={{ ...floatingStyles, minHeight: '300px', alignContent: 'center', paddingRight: '5px' }} getFloatingProps={getFloatingProps} scamAlerts={scamAlerts} /> |
|
|
|
|
</FloatingFocusManager>)} |
|
|
|
|
<div className="d-flex flex-row bg-primary justify-content-between align-items-center"> |
|
|
|
|
<div className="remixui_statusbar"> |
|
|
|
|