Skip to content

Commit

Permalink
Add a section which displays the current data directory
Browse files Browse the repository at this point in the history
  • Loading branch information
MarmadileManteater committed Mar 4, 2024
1 parent e5c92ae commit 41d040f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/renderer/components/data-settings/data-settings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

.data-directory-heading {
margin-block-start: 20px;
}

.data-directory {
word-wrap: break-word;
font-family: monospace;
max-inline-size: 70vw;
margin-block-start: -10px;
}
14 changes: 13 additions & 1 deletion src/renderer/components/data-settings/data-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { invidiousAPICall } from '../../helpers/api/invidious'
import { getLocalChannel } from '../../helpers/api/local'
import { handleAmbigiousContent, initalizeDatabasesInDirectory, readFile, requestDirectory, writeFile } from '../../helpers/android'
import android from 'android'
import pkg from '../../../../package.json'

export default defineComponent({
name: 'DataSettings',
Expand All @@ -34,6 +35,14 @@ export default defineComponent({
'ft-toggle-switch': FtToggleSwitch,
},
data: function () {
let dataDirectory = `Android/data/io.freetubeapp.${pkg.name}/`
if (process.env.IS_ANDROID) {
const dataLocation = readFile('data://', 'data-location.json')
if (dataLocation !== '') {
const { directory } = JSON.parse(dataLocation)
dataDirectory = directory
}
}
return {
showExportSubscriptionsPrompt: false,
subscriptionsPromptValues: [
Expand All @@ -45,7 +54,8 @@ export default defineComponent({
],

shouldExportPlaylistForOlderVersions: false,
shouldCopyDataFilesWhenMoving: true
shouldCopyDataFilesWhenMoving: true,
dataDirectory
}
},
computed: {
Expand Down Expand Up @@ -107,6 +117,7 @@ export default defineComponent({
}
// clear out data-location.json
writeFile('data://', 'data-location.json', '')
this.dataDirectory = `Android/data/io.freetubeapp.${pkg.name}/`
showToast(this.$t('Data Settings.Your data directory has been moved successfully'))
if (!this.shouldCopyDataFilesWhenMoving) {
// the application must restart in order to refresh the dbs
Expand Down Expand Up @@ -145,6 +156,7 @@ export default defineComponent({
directory: directory.uri,
files
}))
this.dataDirectory = directory.uri
showToast(this.$t('Data Settings.Your data directory has been moved successfully'))
if (!this.shouldCopyDataFilesWhenMoving) {
// the application must restart in order to refresh the dbs
Expand Down
11 changes: 10 additions & 1 deletion src/renderer/components/data-settings/data-settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:title="$t('Settings.Data Settings.Data Settings')"
>
<template v-if="usingAndroid">
<h4 class="groupTitle">
<h4 class="groupTitle data-directory-heading">
{{ $t('Data Settings.Data Directory') }}
</h4>
<ft-flex-box class="dataSettingsBox">
Expand All @@ -23,6 +23,14 @@
@change="shouldCopyDataFilesWhenMoving = !shouldCopyDataFilesWhenMoving"
/>
</ft-flex-box>
<ft-flex-box>
<p>
{{ $t("Data Settings.Data Is Currently Stored In") }}:
</p>
<p class="data-directory">
{{ dataDirectory }}
</p>
</ft-flex-box>
</template>
<h4 class="groupTitle">
{{ $t('Subscriptions.Subscriptions') }}
Expand Down Expand Up @@ -96,3 +104,4 @@
</template>

<script src="./data-settings.js" />
<style scoped src="./data-settings.css" />
1 change: 1 addition & 0 deletions static/locales-android/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Data Settings:
Nothing to change: Nothing to change
Copy Data Files When Moving: Copy data files when moving directories
Copy Data Files When Moving Tooltip: This option overwrites the db files present in the directory you have selected with the current db files. Disabling this option will force the app to restart immediately after the directory has been moved.
Data Is Currently Stored In: Data is currently stored in

0 comments on commit 41d040f

Please sign in to comment.