feat: Add isVisitor check to BasicSettings and useVideoProgress
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
# Change Log
|
||||
|
||||
|
||||
## v1.7.34 (2026-01-04)
|
||||
|
||||
### Feat
|
||||
|
||||
- feat: Add refetchOnMount option to DownloadProvider (91d53f0)
|
||||
|
||||
## v1.7.33 (2026-01-04)
|
||||
|
||||
### Feat
|
||||
|
||||
@@ -12,6 +12,7 @@ interface BasicSettingsProps {
|
||||
const BasicSettings: React.FC<BasicSettingsProps> = ({ language, websiteName, onChange }) => {
|
||||
const { t } = useLanguage();
|
||||
const { userRole } = useAuth();
|
||||
const isVisitor = userRole === 'visitor';
|
||||
|
||||
return (
|
||||
<Box>
|
||||
@@ -38,7 +39,7 @@ const BasicSettings: React.FC<BasicSettingsProps> = ({ language, websiteName, on
|
||||
</Select>
|
||||
</FormControl>
|
||||
|
||||
{userRole !== 'visitor' && (
|
||||
{!isVisitor && (
|
||||
<TextField
|
||||
fullWidth
|
||||
label={t('websiteName')}
|
||||
|
||||
@@ -16,6 +16,7 @@ interface UseVideoProgressProps {
|
||||
*/
|
||||
export function useVideoProgress({ videoId, video }: UseVideoProgressProps) {
|
||||
const { userRole } = useAuth();
|
||||
const isVisitor = userRole === 'visitor';
|
||||
const queryClient = useQueryClient();
|
||||
const [hasViewed, setHasViewed] = useState<boolean>(false);
|
||||
const lastProgressSave = useRef<number>(0);
|
||||
@@ -31,7 +32,7 @@ export function useVideoProgress({ videoId, video }: UseVideoProgressProps) {
|
||||
// Save progress on unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (videoId && currentTimeRef.current > 0 && !isDeletingRef.current && userRole !== 'visitor') {
|
||||
if (videoId && currentTimeRef.current > 0 && !isDeletingRef.current && !isVisitor) {
|
||||
axios.put(`${API_URL}/videos/${videoId}/progress`, {
|
||||
progress: Math.floor(currentTimeRef.current)
|
||||
})
|
||||
@@ -44,7 +45,7 @@ export function useVideoProgress({ videoId, video }: UseVideoProgressProps) {
|
||||
currentTimeRef.current = currentTime;
|
||||
|
||||
// Increment view count after 10 seconds
|
||||
if (currentTime > 10 && !hasViewed && videoId && userRole !== 'visitor') {
|
||||
if (currentTime > 10 && !hasViewed && videoId && !isVisitor) {
|
||||
setHasViewed(true);
|
||||
axios.post(`${API_URL}/videos/${videoId}/view`)
|
||||
.then(res => {
|
||||
@@ -59,7 +60,7 @@ export function useVideoProgress({ videoId, video }: UseVideoProgressProps) {
|
||||
|
||||
// Save progress every 5 seconds
|
||||
const now = Date.now();
|
||||
if (now - lastProgressSave.current > 5000 && videoId && userRole !== 'visitor') {
|
||||
if (now - lastProgressSave.current > 5000 && videoId && !isVisitor) {
|
||||
lastProgressSave.current = now;
|
||||
axios.put(`${API_URL}/videos/${videoId}/progress`, {
|
||||
progress: Math.floor(currentTime)
|
||||
|
||||
@@ -3,8 +3,6 @@ import {
|
||||
Alert,
|
||||
Box,
|
||||
Button,
|
||||
Card,
|
||||
CardContent,
|
||||
Container,
|
||||
Grid,
|
||||
Snackbar,
|
||||
@@ -172,8 +170,7 @@ const SettingsPage: React.FC = () => {
|
||||
</Box>
|
||||
|
||||
{/* Settings Card */}
|
||||
<Card variant="outlined">
|
||||
<CardContent>
|
||||
|
||||
<Grid container spacing={2}>
|
||||
{/* 1. Basic Settings */}
|
||||
<Grid size={12}>
|
||||
@@ -202,7 +199,7 @@ const SettingsPage: React.FC = () => {
|
||||
)}
|
||||
|
||||
{/* 3. Security & Access */}
|
||||
{!isVisitor && userRole !== 'visitor' && (
|
||||
{!isVisitor && (
|
||||
<Grid size={12}>
|
||||
<CollapsibleSection title={t('securityAccess')} defaultExpanded={false}>
|
||||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}>
|
||||
@@ -325,8 +322,7 @@ const SettingsPage: React.FC = () => {
|
||||
</>
|
||||
)}
|
||||
</Grid>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
||||
{/* Save Button */}
|
||||
{/* Save Button Placeholder & Logic */}
|
||||
|
||||
Reference in New Issue
Block a user