Skip to content

Commit 85aa3c8

Browse files
committed
Added ShellToast event and fixed drag and drop subs missing notification
- Added ShowToast event for shell to allow for showing toast by the shell - Fixed the missing notification for drag and drop subs loading
1 parent 986b713 commit 85aa3c8

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "stremio",
33
"displayName": "Stremio",
44
"version": "5.0.0-beta.23",
5-
"subVersion": "33",
5+
"subVersion": "34",
66
"author": "Smart Code OOD",
77
"private": true,
88
"license": "gpl-2.0",

src/App/ServicesToaster.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { useServices } = require('stremio/services');
55
const { useToast } = require('stremio/common');
66

77
const ServicesToaster = () => {
8-
const { core, dragAndDrop } = useServices();
8+
const { core, dragAndDrop, shell } = useServices();
99
const toast = useToast();
1010
React.useEffect(() => {
1111
const onCoreEvent = ({ event, args }) => {
@@ -76,13 +76,23 @@ const ServicesToaster = () => {
7676
timeout: 4000
7777
});
7878
};
79+
const onShellToast = (type, title, message, timeout) => {
80+
toast.show({
81+
type: type,
82+
title: title,
83+
message: message,
84+
timeout: timeout,
85+
});
86+
};
7987
core.transport.on('CoreEvent', onCoreEvent);
8088
dragAndDrop.on('error', onDragAndDropError);
8189
dragAndDrop.on('success', onDragAndDropSuccess);
90+
shell.on('ShowToast', onShellToast);
8291
return () => {
8392
core.transport.off('CoreEvent', onCoreEvent);
8493
dragAndDrop.off('error', onDragAndDropError);
8594
dragAndDrop.off('success', onDragAndDropSuccess);
95+
shell.off('ShowToast', onShellToast);
8696
};
8797
}, []);
8898
return null;

src/services/Shell/Shell.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ function Shell({ core }) {
7070
if (pipOverlay) pipOverlay.style.display = 'none';
7171
break;
7272
}
73+
case 'SubtitleDropped': {
74+
const file_name = decodeURIComponent(nativeMsg.path.split(/[\\/]/).pop() || 'subtitle');
75+
events.emit('ShowToast', 'success', 'Added subtitle file', file_name, 4000);
76+
break;
77+
}
7378
case 'FileDropped': {
7479
playLocalFile(nativeMsg.path);
7580
break;
@@ -189,6 +194,7 @@ function Shell({ core }) {
189194
transport.on('showPictureInPicture', (data) => onAppEvent('showPictureInPicture', data));
190195
transport.on('hidePictureInPicture', (data) => onAppEvent('hidePictureInPicture', data));
191196
transport.on('FileDropped', (data) => onAppEvent('FileDropped', data));
197+
transport.on('SubtitleDropped', (data) => onAppEvent('SubtitleDropped', data));
192198
transport.on('AddonInstall', (data) => onAppEvent('AddonInstall', data));
193199
transport.on('OpenFile', (data) => onAppEvent('OpenFile', data));
194200
transport.on('OpenTorrent', (data) => onAppEvent('OpenTorrent', data));

0 commit comments

Comments
 (0)