Skip to content

Commit

Permalink
feat(files): rework store nsfw, scan consent, update diff instances
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmcg authored May 28, 2022
1 parent 87d6d2c commit e0ea80e
Show file tree
Hide file tree
Showing 42 changed files with 417 additions and 463 deletions.
1 change: 0 additions & 1 deletion components/views/chat/chatbar/Chatbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<FilesUpload
v-if="recipient"
:recipient="recipient"
type="quick"
ref="file-upload"
:files="files"
@cancelUpload="onCancelUpload"
Expand Down
4 changes: 2 additions & 2 deletions components/views/files/controls/Controls.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
/>
</div>
<TypographyText
v-if="ui.filesUploadStatus"
v-if="filesUploadStatus"
class="status"
:text="ui.filesUploadStatus"
:text="filesUploadStatus"
:size="6"
/>
<div class="error-container" v-if="errors.length">
Expand Down
13 changes: 9 additions & 4 deletions components/views/files/controls/Controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from 'satellite-lucide-icons'
import { isHeic } from '~/utilities/FileType'
import { SettingsRoutes } from '~/store/ui/types'
import { RootState } from '~/types/store/store'
const convert = require('heic-convert')
export default Vue.extend({
Expand All @@ -37,7 +38,11 @@ export default Vue.extend({
}
},
computed: {
...mapState(['ui', 'settings']),
...mapState({
filesUploadStatus: (state) => (state as RootState).ui.filesUploadStatus,
consentToScan: (state) =>
(state as RootState).textile.userThread.consentToScan,
}),
...mapGetters('ui', ['isFilesIndexLoading']),
},
methods: {
Expand All @@ -46,7 +51,7 @@ export default Vue.extend({
* @description Trigger click on invisible file input on button click
*/
addFile() {
if (!this.settings.consentScan) {
if (!this.consentToScan) {
this.$toast.error(
this.$t('pages.files.errors.enable_consent') as string,
{
Expand Down Expand Up @@ -89,7 +94,7 @@ export default Vue.extend({
return
}
this.text = ''
await this.$TextileManager.bucket?.updateIndex(this.$FileSystem.export)
await this.$store.dispatch('textile/exportFileSystem')
this.$store.commit('ui/setFilesUploadStatus', '')
this.$emit('forceRender')
Expand Down Expand Up @@ -185,7 +190,7 @@ export default Vue.extend({
'ui/setFilesUploadStatus',
this.$t('pages.files.status.index'),
)
await this.$TextileManager.bucket?.updateIndex(this.$FileSystem.export)
await this.$store.dispatch('textile/exportFileSystem')
}
this.$store.commit('ui/setFilesUploadStatus', '')
Expand Down
2 changes: 1 addition & 1 deletion components/views/files/file/File.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default Vue.extend({
computed: {
...mapState({
ui: (state) => (state as RootState).ui,
blockNsfw: (state) => (state as RootState).settings.blockNsfw,
blockNsfw: (state) => (state as RootState).textile.userThread.blockNsfw,
}),
...mapGetters('ui', ['isFilesIndexLoading']),
/**
Expand Down
2 changes: 1 addition & 1 deletion components/views/files/rename/Rename.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default Vue.extend({
'ui/setFilesUploadStatus',
this.$t('pages.files.status.index'),
)
await this.$TextileManager.bucket?.updateIndex(this.$FileSystem.export)
await this.$store.dispatch('textile/exportFileSystem')
this.$store.commit('ui/setFilesUploadStatus', '')
},
},
Expand Down
19 changes: 4 additions & 15 deletions components/views/files/upload/Upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,12 @@
@change="handleFile"
multiple
/>
<label
v-if="type == 'quick'"
<a
@click="handleFileClick"
v-tooltip.top="$t('global.upload')"
:class="`upload-label ${recipient ? 'active' : 'inactive'}`"
class="has-tooltip has-tooltip-top has-tooltip-primary upload-button"
:class="{disabled : !recipient}"
>
<plus-icon size="1.2x" class="control-icon" />
</label>
<div v-if="type =='button'">
<label
@click="handleFileClick"
class="button is-button is-small is-primary is-normal-width"
>
<UiGlowingCursorArea>
<file-plus-icon size="1.2x" class="control-icon" />
&nbsp; {{ $t('global.upload_files') }}
</UiGlowingCursorArea>
</label>
</div>
</a>
</div>
38 changes: 8 additions & 30 deletions components/views/files/upload/Upload.less
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
border: none;
position: absolute;
}
.control-icon {
justify-self: flex-start;
align-self: flex-start;
font-size: @larger-icon-size;
width: unset;

.upload-button {
color: #fff;
display: inline-flex;
.control-icon {
font-size: @larger-icon-size;
width: unset;
}
}
.loading-bar {
max-width: @half;
Expand All @@ -19,28 +22,3 @@
justify-self: flex-start;
align-self: flex-start;
}
.button {
position: relative;
overflow: hidden;
margin-left: @xlight-spacing;
}
.upload-label {
display: inline-flex;
cursor: pointer;
}
.upload-button {
display: inline-flex;
justify-content: center;
align-items: center;
padding: 0;
margin: 0;
height: 20px;
width: 20px;
}
.feather {
height: 20px;
width: 20px;
}
.inactive {
cursor: not-allowed !important;
}
20 changes: 9 additions & 11 deletions components/views/files/upload/Upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<script lang="ts">
import { FilePlusIcon, PlusIcon } from 'satellite-lucide-icons'
import Vue, { PropType } from 'vue'
import { mapState, mapGetters } from 'vuex'
import { mapState } from 'vuex'
import { Config } from '~/config'
import { PropCommonEnum } from '~/libraries/Enums/enums'
import { isHeic } from '~/utilities/FileType'
Expand All @@ -20,10 +20,6 @@ export default Vue.extend({
FilePlusIcon,
},
props: {
type: {
type: String,
default: '',
},
recipient: {
type: Object as PropType<Friend | Group>,
default: null,
Expand All @@ -40,8 +36,12 @@ export default Vue.extend({
},
computed: {
...mapState({
consentScan: (state) => (state as RootState).settings.consentScan,
consentToScan: (state) =>
(state as RootState).textile.userThread.consentToScan,
}),
activeFriend(): Friend | undefined {
return this.$Hounddog.getActiveFriend(this.$store.state.friends)
},
},
methods: {
/**
Expand All @@ -55,7 +55,7 @@ export default Vue.extend({
},
handleFileClick() {
this.resetFileUpload()
if (!this.consentScan) {
if (!this.consentToScan) {
this.$toast.error(
this.$t('pages.files.errors.enable_consent') as string,
{
Expand All @@ -69,10 +69,8 @@ export default Vue.extend({
return
}
setTimeout(() => {
if (this.$refs.quickUpload)
(this.$refs.quickUpload as HTMLFormElement).click()
}, 200)
if (this.$refs.quickUpload)
(this.$refs.quickUpload as HTMLFormElement).click()
},
/**
* @method handleFile
Expand Down
2 changes: 1 addition & 1 deletion components/views/files/view/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default Vue.extend({
...mapState({
file: (state) => (state as RootState).ui.filePreview,
fileDownloadList: (state) => (state as RootState).ui.fileDownloadList,
blockNsfw: (state) => (state as RootState).settings.blockNsfw,
blockNsfw: (state) => (state as RootState).textile.userThread.blockNsfw,
}),
...mapGetters('ui', ['isFilesIndexLoading']),
isDownloading(): boolean {
Expand Down
1 change: 0 additions & 1 deletion components/views/media/actions/settings/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
declare module 'vue/types/vue' {
interface Vue {
settings: any
setupDefaults: () => void
getUserPermissions: () => Promise<any>
requestUserPermissions: (key: PermissionRequestOptions) => Promise<any>
Expand Down
1 change: 0 additions & 1 deletion components/views/settings/pages/audio/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { CaptureMouseTypes } from '~/store/settings/types'
declare module 'vue/types/vue' {
// 3. Declare augmentation for Vue
interface Vue {
settings: any
setupDefaults: () => void
getUserPermissions: () => Promise<any>
requestUserPermissions: (key: PermissionRequestOptions) => Promise<any>
Expand Down
Loading

0 comments on commit e0ea80e

Please sign in to comment.