summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2021-05-10 23:01:01 -0400
committermorpheus65535 <[email protected]>2021-05-10 23:01:01 -0400
commit63f759e91ed4f50da5f738cee81352ecc3c64326 (patch)
tree109217ff858e9e2956fb3b6d34d45a1939e313d2
parentffe8a201a9066bfc47d94f5bb2edc718447e7898 (diff)
parent0031e69db6b8b129eefcd2e8c2ea87056c529761 (diff)
downloadbazarr-63f759e91ed4f50da5f738cee81352ecc3c64326.tar.gz
bazarr-63f759e91ed4f50da5f738cee81352ecc3c64326.zip
Merge remote-tracking branch 'origin/development' into developmentv0.9.6-beta.3
-rw-r--r--bazarr/event_handler.py2
-rw-r--r--frontend/src/@socketio/index.ts4
-rw-r--r--frontend/src/@socketio/reducer.ts8
-rw-r--r--frontend/src/@types/socket.d.ts15
-rw-r--r--frontend/src/App/notifications/index.tsx2
5 files changed, 20 insertions, 11 deletions
diff --git a/bazarr/event_handler.py b/bazarr/event_handler.py
index 7e32bed1a..a017db536 100644
--- a/bazarr/event_handler.py
+++ b/bazarr/event_handler.py
@@ -28,4 +28,4 @@ def show_progress(id, header, name, value, count):
def hide_progress(id):
- event_stream(type="progress", action="delete", payload={"id": id})
+ event_stream(type="progress", action="delete", payload=id)
diff --git a/frontend/src/@socketio/index.ts b/frontend/src/@socketio/index.ts
index 44419ef7d..48c73781c 100644
--- a/frontend/src/@socketio/index.ts
+++ b/frontend/src/@socketio/index.ts
@@ -91,8 +91,8 @@ class SocketIOClient {
forIn(element, (ids, key) => {
ids = uniq(ids);
- const action = handler[key as SocketIO.Action];
- if (action) {
+ const action = handler[key];
+ if (typeof action == "function") {
action(ids);
} else if (anyAction === undefined) {
log("warning", "Unhandle action of SocketIO event", key, type);
diff --git a/frontend/src/@socketio/reducer.ts b/frontend/src/@socketio/reducer.ts
index a6506832f..4b39a5eb2 100644
--- a/frontend/src/@socketio/reducer.ts
+++ b/frontend/src/@socketio/reducer.ts
@@ -9,6 +9,7 @@ import {
siteAddNotifications,
siteAddProgress,
siteInitializationFailed,
+ siteRemoveProgress,
siteUpdateOffline,
systemUpdateLanguagesAll,
systemUpdateSettings,
@@ -72,6 +73,13 @@ export function createDefaultReducer(): SocketIO.Reducer[] {
reduxStore.dispatch(siteAddProgress(progress));
}
},
+ delete: (ids) => {
+ setTimeout(() => {
+ ids?.forEach((id) => {
+ reduxStore.dispatch(siteRemoveProgress(id));
+ });
+ }, 3 * 1000);
+ },
},
{
key: "series",
diff --git a/frontend/src/@types/socket.d.ts b/frontend/src/@types/socket.d.ts
index 77ca6d76b..4a00a0a31 100644
--- a/frontend/src/@types/socket.d.ts
+++ b/frontend/src/@types/socket.d.ts
@@ -1,6 +1,4 @@
namespace SocketIO {
- type Action = "update" | "delete";
-
type EventType = NumEventType | NullEventType | SpecialEventType;
type NumEventType =
@@ -25,18 +23,21 @@ namespace SocketIO {
type SpecialEventType = "message" | "progress";
- type ReducerCreator<E extends EventType, T> = ValueOf<
+ type ReducerCreator<E extends EventType, U, D = never> = ValueOf<
{
[P in E]: {
key: P;
any?: () => void;
- } & Partial<Record<Action, ActionFn<T>>>;
+ update?: ActionFn<T>;
+ delete?: ActionFn<D extends never ? T : D>;
+ } & LooseObject;
+ // TODO: Typing
}
>;
type Event = {
type: EventType;
- action: Action;
+ action: string;
payload: any;
};
@@ -46,9 +47,9 @@ namespace SocketIO {
| ReducerCreator<NumEventType, number>
| ReducerCreator<NullEventType, null>
| ReducerCreator<"message", string>
- | ReducerCreator<"progress", CustomEvent.Progress>;
+ | ReducerCreator<"progress", CustomEvent.Progress, string>;
- type ActionRecord = OptionalRecord<EventType, OptionalRecord<Action, any[]>>;
+ type ActionRecord = OptionalRecord<EventType, StrictObject<any[]>>;
namespace CustomEvent {
type Progress = ReduxStore.Progress;
diff --git a/frontend/src/App/notifications/index.tsx b/frontend/src/App/notifications/index.tsx
index 48f312f07..f55fd5157 100644
--- a/frontend/src/App/notifications/index.tsx
+++ b/frontend/src/App/notifications/index.tsx
@@ -86,7 +86,7 @@ const ProgressToast: FunctionComponent<ProgressHolderProps> = ({
const remove = useCallback(() => removeProgress(id), [removeProgress, id]);
useEffect(() => {
- const handle = setTimeout(remove, 5 * 1000);
+ const handle = setTimeout(remove, 10 * 1000);
return () => {
clearTimeout(handle);
};