Skip to content

Commit 79575c5

Browse files
author
Ferenc Nánási
committed
Filebrowser speed optimizations, some bugs fixed with multiple server handling
1 parent b5defc9 commit 79575c5

File tree

6 files changed

+157
-80
lines changed

6 files changed

+157
-80
lines changed

android/app/src/main/AndroidManifest.xml.orig

-18
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@
1515
<action android:name="com.darryncampbell.cordova.plugin.intent.ACTION" />
1616
<category android:name="android.intent.category.DEFAULT" />
1717
</intent-filter>
18-
<!-- This filter captures protocols without type info -->
1918
<intent-filter>
2019
<action android:name="android.intent.action.VIEW" />
21-
2220
<category android:name="android.intent.category.DEFAULT" />
2321
<category android:name="android.intent.category.BROWSABLE" />
24-
2522
<data android:scheme="rtmp" />
2623
<data android:scheme="rtmpe" />
2724
<data android:scheme="rtmps" />
@@ -34,13 +31,10 @@
3431
<data android:scheme="udp" />
3532
<data android:scheme="vlc" />
3633
</intent-filter>
37-
<!-- This filter captures protocols with type info -->
3834
<intent-filter>
3935
<action android:name="android.intent.action.VIEW" />
40-
4136
<category android:name="android.intent.category.DEFAULT" />
4237
<category android:name="android.intent.category.BROWSABLE" />
43-
4438
<data android:mimeType="video/*" />
4539
<data android:mimeType="audio/*" />
4640
<data android:scheme="rtmp" />
@@ -56,10 +50,8 @@
5650
</intent-filter>
5751
<intent-filter>
5852
<action android:name="android.intent.action.VIEW" />
59-
6053
<category android:name="android.intent.category.DEFAULT" />
6154
<category android:name="android.intent.category.BROWSABLE" />
62-
6355
<data android:scheme="" />
6456
<data android:scheme="file" />
6557
<data android:scheme="ftp" />
@@ -94,20 +86,15 @@
9486
</intent-filter>
9587
<intent-filter>
9688
<action android:name="android.intent.action.VIEW" />
97-
9889
<category android:name="android.intent.category.DEFAULT" />
9990
<category android:name="android.intent.category.BROWSABLE" />
100-
10191
<data android:scheme="" />
10292
<data android:scheme="file" />
10393
<data android:scheme="ftp" />
10494
<data android:scheme="content" />
10595
<data android:scheme="http" />
10696
<data android:scheme="https" />
10797
<data android:host="*" />
108-
109-
<!-- video -->
110-
11198
<data android:pathPattern=".*\\.3g2" />
11299
<data android:pathPattern=".*\\.3gp" />
113100
<data android:pathPattern=".*\\.3gp2" />
@@ -128,7 +115,6 @@
128115
<data android:pathPattern=".*\\.m2v" />
129116
<data android:pathPattern=".*\\.m2t" />
130117
<data android:pathPattern=".*\\.m2ts" />
131-
<!-- <data android:pathPattern=".*\\.m3u" /> -->
132118
<data android:pathPattern=".*\\.m3u8" />
133119
<data android:pathPattern=".*\\.mkv" />
134120
<data android:pathPattern=".*\\.mov" />
@@ -187,7 +173,6 @@
187173
<data android:pathPattern=".*\\.M2V" />
188174
<data android:pathPattern=".*\\.M2T" />
189175
<data android:pathPattern=".*\\.M2TS" />
190-
<!-- <data android:pathPattern=".*\\.M3U" /> -->
191176
<data android:pathPattern=".*\\.M3U8" />
192177
<data android:pathPattern=".*\\.MKV" />
193178
<data android:pathPattern=".*\\.MOV" />
@@ -226,9 +211,6 @@
226211
<data android:pathPattern=".*\\.WMV" />
227212
<data android:pathPattern=".*\\.WTV" />
228213
<data android:pathPattern=".*\\.XESC" />
229-
230-
<!-- audio -->
231-
232214
<data android:pathPattern=".*\\.3ga" />
233215
<data android:pathPattern=".*\\.a52" />
234216
<data android:pathPattern=".*\\.aac" />

src/Container.vue

+19-14
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,26 @@
55
<ion-content>
66
<ion-list id="inbox-list">
77
<ion-list-header>MPV Remote</ion-list-header>
8-
<ion-select
9-
class="serverSelect"
10-
interface="action-sheet"
11-
placeholder="No server selected"
12-
:value="currentServerId"
13-
@ionChange="setCurrentServer($event.target.value)"
14-
>
15-
<ion-select-option
16-
v-for="server in servers"
17-
:key="server.id"
18-
:value="server.id"
8+
<template v-if="servers.length > 0">
9+
<ion-select
10+
class="serverSelect"
11+
interface="action-sheet"
12+
placeholder="No server selected"
13+
:value="currentServerId"
14+
@ionChange="setCurrentServer($event.target.value)"
1915
>
20-
{{ server.name }} ({{ server.host }}:{{ server.port }})
21-
</ion-select-option>
22-
</ion-select>
16+
<ion-select-option
17+
v-for="server in servers"
18+
:key="server.id"
19+
:value="server.id"
20+
>
21+
{{ server.name }} ({{ server.host }}:{{ server.port }})
22+
</ion-select-option>
23+
</ion-select>
24+
</template>
25+
<template v-else>
26+
<div class="serverSelect">No server configured</div>
27+
</template>
2328
<div class="horizontalLine"></div>
2429
<ion-menu-toggle
2530
auto-hide="false"

src/api.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,20 @@ function requestOnRejected(error) {
2020
Promise.reject(error);
2121
}
2222

23-
export function configureInstance(host, port) {
24-
// Before reconfiguration set store states.
23+
export function disconnect() {
24+
store.commit("simpleapi/clearPlaybackRefreshInterval");
2525
store.commit("simpleapi/setConnectedState", false);
2626
store.commit("simpleapi/clearPlayerData");
2727
if (callsPending > 0) {
2828
callsPending = 0;
29-
cancelSource.cancel("API reconfigure");
29+
cancelSource.cancel("Cancel pending requests");
3030
cancelSource = axios.CancelToken.source();
3131
}
32+
}
33+
34+
export function configureInstance(host, port) {
35+
// Before reconfiguration set store states.
36+
disconnect();
3237
apiInstance.defaults.baseURL = `http://${host}:${port}/api/v1/`;
3338
apiInstance.interceptors.request.use(requestOnFulfilled, requestOnRejected);
3439
}

src/components/fileBrowserModal.vue

+115-43
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,7 @@
3535
class="ion-padding"
3636
v-if="(files.cwd || files.collection_id) && connectionState"
3737
>
38-
<ion-list>
39-
<ion-item @click="onPrevDirectoryClicked" v-if="files.prevDir">
40-
<ion-icon :icon="folder" slot="start"></ion-icon>
41-
...
42-
</ion-item>
43-
<ion-item
38+
<!-- <ion-item
4439
v-for="(entry, index) in browsableFiles"
4540
:key="index"
4641
@click="onEntryClicked(entry)"
@@ -66,6 +61,46 @@
6661
<ion-icon v-else :icon="decideIcon(entry)" slot="start"></ion-icon>
6762
<ion-label class="ion-text-wrap">{{ entry.name }}</ion-label>
6863
</ion-item>
64+
</ion-list> -->
65+
<ion-list>
66+
<div class="row" @click="onPrevDirectoryClicked" v-if="files.prevDir">
67+
<div class="columnIcon">
68+
<ion-icon :icon="folder"> </ion-icon>
69+
</div>
70+
<div class="column">...</div>
71+
</div>
72+
73+
<div
74+
class="row"
75+
v-for="(entry, index) in browsableFiles"
76+
:key="index"
77+
@click="onEntryClicked(entry)"
78+
>
79+
<div class="columnIcon">
80+
<ion-icon
81+
slot="start"
82+
v-if="entry.mediaStatus && entry.mediaStatus.finished === 0"
83+
class="mediaStatusProgress"
84+
:icon="decideIcon(entry)"
85+
></ion-icon>
86+
<ion-icon
87+
slot="start"
88+
v-else-if="entry.mediaStatus && entry.mediaStatus.finished === 1"
89+
class="mediaStatusFinished"
90+
:icon="decideIcon(entry)"
91+
></ion-icon>
92+
<ion-icon
93+
v-else-if="entry.type === 'subtitle'"
94+
class="fileformatSubtitle"
95+
:icon="journalOutline"
96+
slot="start"
97+
></ion-icon>
98+
<ion-icon v-else :icon="decideIcon(entry)" slot="start"></ion-icon>
99+
</div>
100+
<div class="column">
101+
{{ entry.name }}
102+
</div>
103+
</div>
69104
</ion-list>
70105
<ion-infinite-scroll
71106
@ionInfinite="onInfiniteScroll($event)"
@@ -84,6 +119,7 @@
84119
Lost connection to server.
85120
</ion-content>
86121
<ion-content v-else-if="!loading">
122+
<ion-label>Kurva</ion-label>
87123
<ion-list-header>Collections</ion-list-header>
88124
<ion-list>
89125
<ion-item
@@ -127,6 +163,7 @@
127163
</template>
128164

129165
<script>
166+
/*eslint no-unused-vars: "error"*/
130167
import { ref, computed } from "vue";
131168
import { useStore } from "vuex";
132169
import { apiInstance, openToast } from "../api";
@@ -211,23 +248,50 @@ export default {
211248
return "Filebrowser";
212249
});
213250
214-
// Get paths or drives
215-
if (store.state.simpleapi.MPVInfo.mpvremoteConfig.unsafefilebrowsing) {
216-
apiInstance.get("/drives").then((response) => {
217-
drives.value = response.data;
218-
});
219-
} else {
220-
apiInstance
221-
.get("filebrowser/paths")
222-
.then((response) => (drives.value = response.data));
223-
}
224-
225-
// Get collections.
226-
if (store.state.simpleapi.MPVInfo.mpvremoteConfig.uselocaldb) {
227-
apiInstance
228-
.get("/collections")
229-
.then((response) => (collections.value = response.data));
230-
}
251+
const loadFilebrowserSettings = async () => {
252+
// Get paths or drives
253+
if (store.state.simpleapi.MPVInfo.mpvremoteConfig.unsafefilebrowsing) {
254+
await apiInstance.get("/drives").then((response) => {
255+
drives.value = response.data;
256+
});
257+
} else {
258+
await apiInstance
259+
.get("filebrowser/paths")
260+
.then((response) => (drives.value = response.data));
261+
}
262+
263+
// Get collections.
264+
if (store.state.simpleapi.MPVInfo.mpvremoteConfig.uselocaldb) {
265+
await apiInstance
266+
.get("/collections")
267+
.then((response) => (collections.value = response.data));
268+
}
269+
};
270+
271+
const loadFileBrowser = async () => {
272+
await loadFilebrowserSettings();
273+
if (filemanLastPath) {
274+
console.log("Fileman last path exists ");
275+
if (filemanLastPath.type == "collection") {
276+
console.log("Collection should be loaded");
277+
getDirectoryContents(null, filemanLastPath.collection_id).catch(
278+
() => {
279+
console.log("Got error, loading basic");
280+
getDirectoryContents();
281+
}
282+
);
283+
} else if (filemanLastPath.type == "directory") {
284+
getDirectoryContents(filemanLastPath.cwd).catch(() => {
285+
getDirectoryContents();
286+
});
287+
} else {
288+
// No valid directory content detected
289+
loading.value = false;
290+
}
291+
} else {
292+
loading.value = false;
293+
}
294+
};
231295
232296
const saveLastPath = async () => {
233297
let filemanLastPath = {};
@@ -257,7 +321,7 @@ export default {
257321
let loadingTimeout = setTimeout(() => {
258322
loading.value = true;
259323
}, 150);
260-
return apiInstance
324+
return await apiInstance
261325
.post("filebrowser/browse", data)
262326
.then((response) => {
263327
files.value = response.data;
@@ -299,25 +363,6 @@ export default {
299363
ev.target.complete();
300364
};
301365
302-
if (filemanLastPath) {
303-
console.log("Fileman last path exists ");
304-
if (filemanLastPath.type == "collection") {
305-
console.log("Collection should be loaded");
306-
getDirectoryContents(null, filemanLastPath.collection_id).catch(() => {
307-
console.log("Got error, loading basic");
308-
getDirectoryContents();
309-
});
310-
} else if (filemanLastPath.type == "directory") {
311-
getDirectoryContents(filemanLastPath.cwd).catch(() => {
312-
getDirectoryContents();
313-
});
314-
} else {
315-
getDirectoryContents();
316-
}
317-
} else {
318-
loading.value = false;
319-
}
320-
321366
const onCancelClicked = () => {
322367
saveLastPath().then(() => props.modalController.dismiss());
323368
};
@@ -546,6 +591,7 @@ export default {
546591
}
547592
};
548593
594+
loadFileBrowser();
549595
return {
550596
onCancelClicked,
551597
onPrevDirectoryClicked,
@@ -626,4 +672,30 @@ ion-footer ion-button {
626672
.mediaStatusProgress {
627673
color: yellow;
628674
}
675+
676+
.row {
677+
display: flex;
678+
background-color: #172246;
679+
align-items: center;
680+
justify-content: center;
681+
padding-top: 10px;
682+
padding-bottom: 10px;
683+
font-size: 15px;
684+
border-bottom: 1px solid rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.3);
685+
}
686+
687+
.columnIcon {
688+
padding-left: 17px;
689+
padding-right: 30px;
690+
flex: 10%;
691+
min-width: 72px;
692+
font-size: 25px;
693+
color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.54);
694+
}
695+
696+
.column {
697+
flex: 90%;
698+
min-width: 0px;
699+
padding-right: 10px;
700+
}
629701
</style>

0 commit comments

Comments
 (0)