aboutsummaryrefslogtreecommitdiffstats
path: root/src/web
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-11-08 10:15:14 -0600
committerGitHub <noreply@github.com>2026-11-08 10:15:14 -0600
commit169bb8a3c0098599a617d8553e93c694bd813795 (patch)
tree4d825302717fc76d543b6a24469ad23a605cd5c8 /src/web
parent4eaa2b13e2da250d7b89073a15e9f1e077661fd7 (diff)
parentcefdcd02e28b1f02f546002fdd475de4fa03e839 (diff)
downloadslskd-169bb8a3c0098599a617d8553e93c694bd813795.tar.gz
Merge branch 'master' into dependabot/npm_and_yarn/src/web/follow-redirects-1.16.2
Diffstat (limited to 'src/web')
-rw-r--r--src/web/src/components/App.jsx2
-rw-r--r--src/web/src/components/Browse/Browse.jsx9
-rw-r--r--src/web/src/components/Chat/Chat.jsx9
-rw-r--r--src/web/src/components/Rooms/RoomJoinModal.jsx2
-rw-r--r--src/web/src/components/Rooms/Rooms.jsx22
-rw-r--r--src/web/src/components/Search/Response.jsx5
-rw-r--r--src/web/src/components/Search/Searches.jsx16
-rw-r--r--src/web/src/components/Shared/CodeEditor.jsx2
-rw-r--r--src/web/src/components/System/Data/index.jsx12
-rw-r--r--src/web/src/components/System/Events/index.jsx27
-rw-r--r--src/web/src/components/System/Files/Explorer.jsx27
-rw-r--r--src/web/src/components/System/Info/index.jsx3
-rw-r--r--src/web/src/components/System/Logs/Live.jsx5
-rw-r--r--src/web/src/components/System/Options/EditModal.jsx9
-rw-r--r--src/web/src/components/System/Shares/ContentsModal.jsx11
-rw-r--r--src/web/src/components/Transfers/TransferGroup.jsx34
-rw-r--r--src/web/src/components/Transfers/Transfers.jsx2
-rw-r--r--src/web/src/components/Users/User.jsx4
-rw-r--r--src/web/src/components/Users/Users.jsx12
-rw-r--r--src/web/src/lib/api.js2
-rw-r--r--src/web/src/lib/options.js4
-rw-r--r--src/web/src/lib/session.js2
22 files changed, 149 insertions, 72 deletions
diff --git a/src/web/src/components/App.jsx b/src/web/src/components/App.jsx
index 2d2713c4..091cc2f8 100644
--- a/src/web/src/components/App.jsx
+++ b/src/web/src/components/App.jsx
@@ -127,7 +127,7 @@ const ModeSpecificConnectButton = ({
color = 'yellow';
}
- if (server?.isConnecting || server?.IsLoggingIn) {
+ if (server?.isConnecting || server?.isLoggingIn) {
icon = 'sync alternate loading';
color = 'green';
}
diff --git a/src/web/src/components/Browse/Browse.jsx b/src/web/src/components/Browse/Browse.jsx
index 44e6b2dd..c6107bd5 100644
--- a/src/web/src/components/Browse/Browse.jsx
+++ b/src/web/src/components/Browse/Browse.jsx
@@ -251,8 +251,13 @@ class Browse extends Component {
return;
}
- const response = await users.getBrowseStatus({ username });
- this.setState({ browseStatus: response.data });
+ try {
+ const response = await users.getBrowseStatus({ username });
+ this.setState({ browseStatus: response.data });
+ } catch {
+ // status is not available until the first progress update, and is removed shortly after completion;
+ // this runs on an interval, so just try again next time
+ }
};
getDirectoryTree = ({ directories, separator }) => {
diff --git a/src/web/src/components/Chat/Chat.jsx b/src/web/src/components/Chat/Chat.jsx
index 9224fb30..4fcb44ed 100644
--- a/src/web/src/components/Chat/Chat.jsx
+++ b/src/web/src/components/Chat/Chat.jsx
@@ -60,7 +60,13 @@ class Chat extends Component {
this.setState(
{
active: sessionStorage.getItem(activeChatKey) || '',
- interval: window.setInterval(this.fetchConversations, 5_000),
+ interval: window.setInterval(async () => {
+ try {
+ await this.fetchConversations();
+ } catch (error) {
+ console.error(error);
+ }
+ }, 5_000),
},
async () => {
await this.fetchConversations();
@@ -113,7 +119,6 @@ class Chat extends Component {
// check to see if the active chat is still active
// this will happen whenever a chat is closed/removed
if (activeConversation) {
- console.log('active?', activeConversation);
// *before* fetching messages, ack any unacked messages
// for the active chat
if (activeConversation.hasUnAcknowledgedMessages === true) {
diff --git a/src/web/src/components/Rooms/RoomJoinModal.jsx b/src/web/src/components/Rooms/RoomJoinModal.jsx
index 5a6cf0c2..dd3c7178 100644
--- a/src/web/src/components/Rooms/RoomJoinModal.jsx
+++ b/src/web/src/components/Rooms/RoomJoinModal.jsx
@@ -25,7 +25,7 @@ const RoomJoinModal = ({ joinRoom: parentJoinRoom, ...modalOptions }) => {
const getAvailableRooms = async () => {
setLoading(true);
const availableResult = await rooms.getAvailable();
- setAvailable(availableResult);
+ setAvailable(availableResult ?? []);
setLoading(false);
};
diff --git a/src/web/src/components/Rooms/Rooms.jsx b/src/web/src/components/Rooms/Rooms.jsx
index f6bdb685..87fe51be 100644
--- a/src/web/src/components/Rooms/Rooms.jsx
+++ b/src/web/src/components/Rooms/Rooms.jsx
@@ -1,4 +1,4 @@
-import { activeRoomKey } from '../../config';
+import { activeRoomKey, urlBase } from '../../config';
import * as rooms from '../../lib/rooms';
import PlaceholderSegment from '../Shared/PlaceholderSegment';
import RoomMenu from './RoomMenu';
@@ -81,8 +81,20 @@ class Rooms extends Component {
{
active: sessionStorage.getItem(activeRoomKey) || '',
intervals: {
- messages: window.setInterval(this.fetchActiveRoom, 1_000),
- rooms: window.setInterval(this.fetchJoinedRooms, 500),
+ messages: window.setInterval(async () => {
+ try {
+ await this.fetchActiveRoom();
+ } catch (error) {
+ console.error(error);
+ }
+ }, 1_000),
+ rooms: window.setInterval(async () => {
+ try {
+ await this.fetchJoinedRooms();
+ } catch (error) {
+ console.error(error);
+ }
+ }, 500),
},
},
async () => {
@@ -248,13 +260,13 @@ class Rooms extends Component {
};
handleUserProfile = () => {
- this.props.history.push('/users', {
+ this.props.history.push(`${urlBase}/users`, {
user: this.state.contextMenu.message.username,
});
};
handleBrowseShares = () => {
- this.props.history.push('/browse', {
+ this.props.history.push(`${urlBase}/browse`, {
user: this.state.contextMenu.message.username,
});
};
diff --git a/src/web/src/components/Search/Response.jsx b/src/web/src/components/Search/Response.jsx
index 567b80a3..a17df823 100644
--- a/src/web/src/components/Search/Response.jsx
+++ b/src/web/src/components/Search/Response.jsx
@@ -254,8 +254,9 @@ class Response extends Component {
size="large"
/>
<Label>
- {downloadError.data +
- ` (HTTP ${downloadError.status} ${downloadError.statusText})`}
+ {downloadError?.data
+ ? `${downloadError.data} (HTTP ${downloadError.status} ${downloadError.statusText})`
+ : 'Download failed'}
</Label>
</span>
)}
diff --git a/src/web/src/components/Search/Searches.jsx b/src/web/src/components/Search/Searches.jsx
index d50462ba..9306867c 100644
--- a/src/web/src/components/Search/Searches.jsx
+++ b/src/web/src/components/Search/Searches.jsx
@@ -145,9 +145,11 @@ const Searches = ({ server } = {}) => {
});
setRemoving(false);
- } catch (error_) {
- console.error(error_);
- toast.error(error?.response?.data ?? error?.message ?? error);
+ } catch (removeError) {
+ console.error(removeError);
+ toast.error(
+ removeError?.response?.data ?? removeError?.message ?? removeError,
+ );
setRemoving(false);
}
};
@@ -218,24 +220,24 @@ const Searches = ({ server } = {}) => {
action={
<>
<Button
- disabled={creating || !server.isConnected}
+ disabled={creating || !server?.isConnected}
icon="plus"
onClick={create}
/>
<Button
- disabled={creating || !server.isConnected}
+ disabled={creating || !server?.isConnected}
icon="search"
onClick={() => create({ navigate: true })}
/>
</>
}
className="search-input"
- disabled={creating || !server.isConnected}
+ disabled={creating || !server?.isConnected}
input={
<input
data-lpignore="true"
placeholder={
- server.isConnected
+ server?.isConnected
? 'Search phrase'
: 'Connect to server to perform a search'
}
diff --git a/src/web/src/components/Shared/CodeEditor.jsx b/src/web/src/components/Shared/CodeEditor.jsx
index 8780bc31..b82683de 100644
--- a/src/web/src/components/Shared/CodeEditor.jsx
+++ b/src/web/src/components/Shared/CodeEditor.jsx
@@ -8,8 +8,6 @@ import CodeMirror from '@uiw/react-codemirror';
import React from 'react';
const CodeEditor = ({ onChange = () => {}, theme, value, ...rest }) => {
- console.log(defaultHighlightStyle);
-
return (
<CodeMirror
extensions={[
diff --git a/src/web/src/components/System/Data/index.jsx b/src/web/src/components/System/Data/index.jsx
index 8b6a99eb..2424ea87 100644
--- a/src/web/src/components/System/Data/index.jsx
+++ b/src/web/src/components/System/Data/index.jsx
@@ -5,9 +5,15 @@ import { Button, Divider, Header, Icon } from 'semantic-ui-react';
const clear = async ({ direction, setState }) => {
setState(true);
- await clearCompleted({ direction });
- setState(false);
- toast.success(`Completed ${direction}s cleared!`);
+
+ try {
+ await clearCompleted({ direction });
+ toast.success(`Completed ${direction}s cleared!`);
+ } catch (error) {
+ toast.error(error?.response?.data ?? error?.message ?? error);
+ } finally {
+ setState(false);
+ }
};
const Data = () => {
diff --git a/src/web/src/components/System/Events/index.jsx b/src/web/src/components/System/Events/index.jsx
index 7f708908..b0549259 100644
--- a/src/web/src/components/System/Events/index.jsx
+++ b/src/web/src/components/System/Events/index.jsx
@@ -17,18 +17,27 @@ const Events = () => {
const fetch = async () => {
setLoading(true);
- const { events: items, totalCount } = await list({
- limit: PER_PAGE,
- offset: (page - 1) * PER_PAGE,
- });
+ try {
+ const { events: items, totalCount } = await list({
+ limit: PER_PAGE,
+ offset: (page - 1) * PER_PAGE,
+ });
- const tp = Math.ceil(totalCount / PER_PAGE);
+ const tp = Math.ceil(totalCount / PER_PAGE);
- setEvents(items);
- setTotalPages(Number.isNaN(tp) ? 0 : tp);
- setLoading(false);
+ setEvents(items);
+ setTotalPages(Number.isNaN(tp) ? 0 : tp);
- return items;
+ return items;
+ } catch (error) {
+ console.error(error);
+ setEvents([]);
+ setTotalPages(0);
+
+ return [];
+ } finally {
+ setLoading(false);
+ }
};
const paginationChanged = ({ activePage }) => {
diff --git a/src/web/src/components/System/Files/Explorer.jsx b/src/web/src/components/System/Files/Explorer.jsx
index ca0bdba1..a4f0bbbe 100644
--- a/src/web/src/components/System/Files/Explorer.jsx
+++ b/src/web/src/components/System/Files/Explorer.jsx
@@ -9,6 +9,7 @@ const FileRow = ({
length,
modifiedAt,
name,
+ onDeleted,
remoteFileManagement,
root,
subdirectory,
@@ -34,7 +35,7 @@ const FileRow = ({
path: `${subdirectory.join('/')}/${fullName}`,
root,
});
- fetch();
+ onDeleted();
},
},
]}
@@ -66,6 +67,7 @@ const DirectoryRow = ({
modifiedAt,
name,
onClick = () => {},
+ onDeleted,
remoteFileManagement,
root,
subdirectory,
@@ -94,7 +96,7 @@ const DirectoryRow = ({
path: `${subdirectory.join('/')}/${fullName}`,
root,
});
- fetch();
+ onDeleted();
},
},
]}
@@ -131,12 +133,19 @@ const Explorer = ({ remoteFileManagement, root }) => {
const fetch = async () => {
setLoading(true);
- const directoryResult = await list({
- root,
- subdirectory: subdirectory.join('/'),
- });
- setDirectory(directoryResult);
- setLoading(false);
+
+ try {
+ const directoryResult = await list({
+ root,
+ subdirectory: subdirectory.join('/'),
+ });
+ setDirectory(directoryResult);
+ } catch (error) {
+ console.error(error);
+ setDirectory({ directories: [], files: [] });
+ } finally {
+ setLoading(false);
+ }
};
useEffect(() => {
@@ -281,6 +290,7 @@ const Explorer = ({ remoteFileManagement, root }) => {
<DirectoryRow
key={d.name}
onClick={() => select({ path: d.name })}
+ onDeleted={fetch}
remoteFileManagement={remoteFileManagement}
root={root}
subdirectory={subdirectory}
@@ -290,6 +300,7 @@ const Explorer = ({ remoteFileManagement, root }) => {
{sortedFiles?.map((f) => (
<FileRow
key={f.name}
+ onDeleted={fetch}
remoteFileManagement={remoteFileManagement}
root={root}
subdirectory={subdirectory}
diff --git a/src/web/src/components/System/Info/index.jsx b/src/web/src/components/System/Info/index.jsx
index 8672b5df..016b683f 100644
--- a/src/web/src/components/System/Info/index.jsx
+++ b/src/web/src/components/System/Info/index.jsx
@@ -42,8 +42,9 @@ const Info = ({ state, theme }) => {
mediaQuery="(max-width: 686px)"
onClick={() =>
window.open(
- `http://www.slsknet.org/qtlogin.php?username=${state?.user?.username}`,
+ `http://www.slsknet.org/qtlogin.php?username=${encodeURIComponent(state?.user?.username ?? '')}`,
'_blank',
+ 'noopener,noreferrer',
)
}
>
diff --git a/src/web/src/components/System/Logs/Live.jsx b/src/web/src/components/System/Logs/Live.jsx
index 2699a2e3..c572b2f9 100644
--- a/src/web/src/components/System/Logs/Live.jsx
+++ b/src/web/src/components/System/Logs/Live.jsx
@@ -20,6 +20,7 @@ class Live extends Component {
componentDidMount() {
const logsHub = createLogsHubConnection();
+ this.logsHub = logsHub;
logsHub.on('buffer', (buffer) => {
this.setState({
@@ -44,6 +45,10 @@ class Live extends Component {
logsHub.start();
}
+ componentWillUnmount() {
+ this.logsHub?.stop();
+ }
+
nextId = 0;
withId = (log) => ({ ...log, id: this.nextId++ });
diff --git a/src/web/src/components/System/Options/EditModal.jsx b/src/web/src/components/System/Options/EditModal.jsx
index 6fc2af69..0727b83e 100644
--- a/src/web/src/components/System/Options/EditModal.jsx
+++ b/src/web/src/components/System/Options/EditModal.jsx
@@ -43,6 +43,7 @@ const EditModal = ({ onClose, open, theme }) => {
const validate = async (newYaml) => {
const response = await validateYaml({ yaml: newYaml });
setYamlError(response);
+ return response;
};
const update = async (newYaml) => {
@@ -51,14 +52,16 @@ const EditModal = ({ onClose, open, theme }) => {
};
const save = async (newYaml) => {
- await validate(newYaml);
+ const validationError = await validate(newYaml);
- if (!yamlError) {
+ if (!validationError) {
try {
await updateYaml({ yaml: newYaml });
onClose();
} catch (nextUpdateError) {
- setUpdateError(nextUpdateError.response.data);
+ setUpdateError(
+ nextUpdateError?.response?.data ?? nextUpdateError?.message,
+ );
}
}
};
diff --git a/src/web/src/components/System/Shares/ContentsModal.jsx b/src/web/src/components/System/Shares/ContentsModal.jsx
index 5399bcf2..36d1d79d 100644
--- a/src/web/src/components/System/Shares/ContentsModal.jsx
+++ b/src/web/src/components/System/Shares/ContentsModal.jsx
@@ -13,7 +13,16 @@ const ContentsModal = ({ onClose, share, theme }) => {
const fetch = async () => {
setLoading(true);
- const result = await browse({ id });
+ let result;
+
+ try {
+ result = await browse({ id });
+ } catch (error) {
+ console.error(error);
+ setContents(error?.response?.data ?? error?.message ?? String(error));
+ setLoading(false);
+ return;
+ }
const directories = result.map((directory) => {
const lines = [directory.name.replace(remotePath, localPath)];
diff --git a/src/web/src/components/Transfers/TransferGroup.jsx b/src/web/src/components/Transfers/TransferGroup.jsx
index 12354362..f150459a 100644
--- a/src/web/src/components/Transfers/TransferGroup.jsx
+++ b/src/web/src/components/Transfers/TransferGroup.jsx
@@ -42,7 +42,7 @@ class TransferGroup extends Component {
.map((s) =>
user.directories
.find((d) => d.directory === s.directory)
- .files.find((f) => f.filename === s.filename),
+ ?.files?.find((f) => f.filename === s.filename),
)
.filter((s) => s !== undefined);
};
@@ -65,21 +65,29 @@ class TransferGroup extends Component {
};
cancelAll = async (direction, username, selected) => {
- await Promise.all(
- selected.map((file) =>
- transfers.cancel({ direction, id: file.id, username }),
- ),
- );
+ try {
+ await Promise.all(
+ selected.map((file) =>
+ transfers.cancel({ direction, id: file.id, username }),
+ ),
+ );
+ } catch (error) {
+ console.error(error);
+ }
};
removeAll = async (direction, username, selected) => {
- await Promise.all(
- selected.map((file) =>
- transfers
- .cancel({ direction, id: file.id, remove: true, username })
- .then(() => this.removeFileSelection(file)),
- ),
- );
+ try {
+ await Promise.all(
+ selected.map((file) =>
+ transfers
+ .cancel({ direction, id: file.id, remove: true, username })
+ .then(() => this.removeFileSelection(file)),
+ ),
+ );
+ } catch (error) {
+ console.error(error);
+ }
};
handleRetry = async (file) => {
diff --git a/src/web/src/components/Transfers/Transfers.jsx b/src/web/src/components/Transfers/Transfers.jsx
index f43ed1ae..025de9e2 100644
--- a/src/web/src/components/Transfers/Transfers.jsx
+++ b/src/web/src/components/Transfers/Transfers.jsx
@@ -17,7 +17,7 @@ const Transfers = ({ direction, server }) => {
const fetch = async () => {
try {
const response = await transfersLibrary.getAll({ direction });
- setTransfers(response);
+ setTransfers(response ?? []);
} catch (error) {
console.error(error);
toast.error(error?.response?.data ?? error?.message ?? error);
diff --git a/src/web/src/components/Users/User.jsx b/src/web/src/components/Users/User.jsx
index 0e392122..457c095b 100644
--- a/src/web/src/components/Users/User.jsx
+++ b/src/web/src/components/Users/User.jsx
@@ -33,6 +33,7 @@ const FreeUploadSlot = ({ hasFreeUploadSlot }) => (
const User = ({
address,
description,
+ hasFreeUploadSlot,
hasPicture,
picture,
port,
@@ -57,7 +58,8 @@ const User = ({
{username}
</Item.Header>
<Item.Meta>
- Free Upload Slot: <FreeUploadSlot hasFreeUploadSlot />, Total Upload
+ Free Upload Slot:{' '}
+ <FreeUploadSlot hasFreeUploadSlot={hasFreeUploadSlot} />, Total Upload
Slots: {uploadSlots}, Queue Length: {queueLength}, IP Address: {address}
, Port: {port}
</Item.Meta>
diff --git a/src/web/src/components/Users/Users.jsx b/src/web/src/components/Users/Users.jsx
index 55dc1047..fd9c3c6c 100644
--- a/src/web/src/components/Users/Users.jsx
+++ b/src/web/src/components/Users/Users.jsx
@@ -3,7 +3,7 @@ import { activeUserInfoKey } from '../../config';
import * as users from '../../lib/users';
import PlaceholderSegment from '../Shared/PlaceholderSegment';
import User from './User';
-import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
+import React, { useEffect, useRef, useState } from 'react';
import { useLocation } from 'react-router-dom';
import { Icon, Input, Item, Loader, Segment } from 'semantic-ui-react';
@@ -37,20 +37,20 @@ const Users = () => {
const keyUp = (event) => (event.key === 'Escape' ? clear() : '');
- useLayoutEffect(() => {
- document.removeEventListener('keyup', keyUp, false);
- }, []); // eslint-disable-line react-hooks/exhaustive-deps
-
useEffect(() => {
document.addEventListener('keyup', keyUp, false);
const storedUsername =
location.state?.user || localStorage.getItem(activeUserInfoKey);
- if (storedUsername !== undefined) {
+ if (storedUsername) {
setSelectedUsername(storedUsername);
setInputText(storedUsername);
}
+
+ return () => {
+ document.removeEventListener('keyup', keyUp, false);
+ };
}, []); // eslint-disable-line react-hooks/exhaustive-deps
useEffect(() => {
diff --git a/src/web/src/lib/api.js b/src/web/src/lib/api.js
index 9506a0da..74602d63 100644
--- a/src/web/src/lib/api.js
+++ b/src/web/src/lib/api.js
@@ -26,7 +26,7 @@ api.interceptors.response.use(
},
(error) => {
if (
- error.response.status === 401 &&
+ error.response?.status === 401 &&
!['/session', '/server', '/application'].includes(
error.response.config.url,
)
diff --git a/src/web/src/lib/options.js b/src/web/src/lib/options.js
index 1c3c55c5..891d0ee2 100644
--- a/src/web/src/lib/options.js
+++ b/src/web/src/lib/options.js
@@ -17,9 +17,9 @@ export const getYamlLocation = async () => {
};
export const validateYaml = async ({ yaml }) => {
- return (await api.post('/options/yaml/validate', yaml)).data;
+ return (await api.post('/options/yaml/validate', JSON.stringify(yaml))).data;
};
export const updateYaml = async ({ yaml }) => {
- return (await api.put('/options/yaml', yaml)).data;
+ return (await api.put('/options/yaml', JSON.stringify(yaml))).data;
};
diff --git a/src/web/src/lib/session.js b/src/web/src/lib/session.js
index 014b131c..cf6966c6 100644
--- a/src/web/src/lib/session.js
+++ b/src/web/src/lib/session.js
@@ -36,7 +36,7 @@ export const check = async () => {
await api.get('/session');
return true;
} catch (error) {
- if (error.response.status === 401) {
+ if (error.response?.status === 401) {
console.error('session error; not logged in or session has expired');
logout();
return false;