Skip to content

Commit 9ff305d

Browse files
committed
Improved filebrowser
1 parent fc2f561 commit 9ff305d

File tree

6 files changed

+52
-45
lines changed

6 files changed

+52
-45
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ Important Android stuff:
4747
- Created a basic clipart icon with Android studio
4848
- Toast rendering improved
4949

50-
## 1.0.9
50+
## 1.0.9 (Draft not released yet)
5151

5252
- Fixed icon for older Android versions,
5353
- [Android project]: minSdkVersion have changed to 24 (Android 7.0)
5454
- [Android project]: compileSdkVersion have changed from 30 to 32
5555
- [Android project]: Upgraded gradle, some ionic versions etc...
56+
- Filebrowser minor improvemnts

android/app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ android {
66
applicationId "com.husudosu.mpvremote"
77
minSdkVersion rootProject.ext.minSdkVersion
88
targetSdkVersion rootProject.ext.targetSdkVersion
9-
versionCode 9
9+
versionCode 10
1010
versionName "1.0.9"
1111
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1212
aaptOptions {

android/app/release/output-metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"type": "SINGLE",
1212
"filters": [],
1313
"attributes": [],
14-
"versionCode": 9,
14+
"versionCode": 10,
1515
"versionName": "1.0.9",
1616
"outputFile": "app-release.apk"
1717
}

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/fileBrowserModal.vue

+45-38
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@
154154
</template>
155155

156156
<script>
157-
/*eslint no-unused-vars: "error"*/
158157
import { ref, computed } from "vue";
159158
import { useStore } from "vuex";
160159
import { apiInstance } from "../api";
@@ -180,6 +179,7 @@ import {
180179
IonInfiniteScrollContent,
181180
IonFab,
182181
IonFabButton,
182+
modalController,
183183
} from "@ionic/vue";
184184
import {
185185
arrowUp,
@@ -201,7 +201,7 @@ import {
201201
} from "../enums";
202202
203203
export default {
204-
props: ["modalController", "action"],
204+
props: ["action"],
205205
setup(props) {
206206
const store = useStore();
207207
const serverConfig = computed(
@@ -243,47 +243,55 @@ export default {
243243
});
244244
245245
const loadFilebrowserSettings = async () => {
246-
// Get paths or drives
247-
if (store.state.simpleapi.MPVInfo.mpvremoteConfig.unsafefilebrowsing) {
248-
await apiInstance.get("/drives").then((response) => {
249-
drives.value = response.data;
250-
});
251-
} else {
252-
await apiInstance
253-
.get("filebrowser/paths")
254-
.then((response) => (drives.value = response.data));
255-
}
246+
try {
247+
// Get paths or drives
248+
if (serverConfig.value.unsafefilebrowsing) {
249+
await apiInstance
250+
.get("/drives")
251+
.then((response) => {
252+
drives.value = response.data;
253+
})
254+
.catch(async () => {
255+
// If got error fetching driver fallback to filebrowser paths
256+
await apiInstance
257+
.get("filebrowser/paths")
258+
.then((response) => (drives.value = response.data));
259+
});
260+
} else {
261+
await apiInstance
262+
.get("filebrowser/paths")
263+
.then((response) => (drives.value = response.data));
264+
}
256265
257-
// Get collections.
258-
if (store.state.simpleapi.MPVInfo.mpvremoteConfig.uselocaldb) {
259-
await apiInstance
260-
.get("/collections")
261-
.then((response) => (collections.value = response.data));
266+
// Get collections.
267+
if (serverConfig.value.uselocaldb) {
268+
await apiInstance
269+
.get("/collections")
270+
.then((response) => (collections.value = response.data));
271+
}
272+
} catch (err) {
273+
console.log(err);
274+
store.dispatch("app/showToast", {
275+
message: `Failed to load settings: ${err}`,
276+
duration: 5000,
277+
});
262278
}
263279
};
264280
265281
const loadFileBrowser = async () => {
266282
await loadFilebrowserSettings();
267283
if (filemanLastPath) {
268-
console.log("Fileman last path exists ");
269284
if (filemanLastPath.type == "collection") {
270-
console.log("Collection should be loaded");
271-
getDirectoryContents(null, filemanLastPath.collection_id).catch(
272-
() => {
273-
console.log("Got error, loading basic");
274-
getDirectoryContents();
285+
await getDirectoryContents(null, filemanLastPath.collection_id).catch(
286+
async () => {
287+
await getDirectoryContents();
275288
}
276289
);
277290
} else if (filemanLastPath.type == "directory") {
278-
getDirectoryContents(filemanLastPath.cwd).catch(() => {
279-
getDirectoryContents();
291+
await getDirectoryContents(filemanLastPath.cwd).catch(async () => {
292+
await getDirectoryContents();
280293
});
281-
} else {
282-
// No valid directory content detected
283-
loading.value = false;
284294
}
285-
} else {
286-
loading.value = false;
287295
}
288296
};
289297
@@ -353,7 +361,7 @@ export default {
353361
};
354362
355363
const onCancelClicked = () => {
356-
saveLastPath().then(() => props.modalController.dismiss());
364+
saveLastPath().then(() => modalController.dismiss());
357365
};
358366
359367
const handlePlayAction = async (entry) => {
@@ -382,23 +390,22 @@ export default {
382390
383391
if (role === "continue") {
384392
saveLastPath().then(() => {
385-
props.modalController.dismiss({
393+
modalController.dismiss({
386394
filename: entry.fullPath,
387395
seekTo: entry.mediaStatus.current_time,
388396
});
389397
});
390398
} else if (role === "play") {
391399
saveLastPath().then(() => {
392-
props.modalController.dismiss({
400+
modalController.dismiss({
393401
filename: entry.fullPath,
394402
appendToPlaylist: true,
395403
});
396-
console.log("Play from start");
397404
});
398405
}
399406
} else {
400407
saveLastPath().then(() => {
401-
props.modalController.dismiss({
408+
modalController.dismiss({
402409
filename: entry.fullPath,
403410
appendToPlaylist: true,
404411
});
@@ -421,7 +428,7 @@ export default {
421428
props.action == FileBrowserActions.OPENSUB &&
422429
entry.type == FileBrowserEntryTypes.SUBTITLE
423430
) {
424-
props.modalController.dismiss({ filename: entry.fullPath });
431+
modalController.dismiss({ filename: entry.fullPath });
425432
}
426433
};
427434
@@ -497,7 +504,7 @@ export default {
497504
browsableFiles.value = files.value.content.slice(0, INFINITE_SCROLL_STEP);
498505
};
499506
const onOpenDirectoryClicked = () => {
500-
saveLastPath().then(() => props.modalController.dismiss(files.value.cwd));
507+
saveLastPath().then(() => modalController.dismiss(files.value.cwd));
501508
};
502509
503510
const doSort = () => {
@@ -590,7 +597,7 @@ export default {
590597
browserContent.value.$el.scrollToPoint(0, 0, 500);
591598
};
592599
593-
loadFileBrowser();
600+
loadFileBrowser().finally(() => (loading.value = false));
594601
return {
595602
logScroll,
596603
onCancelClicked,

src/views/Player.vue

-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ export default {
160160
const modal = await modalController.create({
161161
component: fileBrowserModal,
162162
componentProps: {
163-
modalController: modalController,
164163
action: FileBrowserActions.PLAY,
165164
},
166165
});

0 commit comments

Comments
 (0)