Skip to content

Commit

Permalink
fix(files): rework store for files modal (#2745)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmcg committed Apr 11, 2022
1 parent 60b47a8 commit 58f0b22
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
9 changes: 2 additions & 7 deletions components/ui/Global/Global.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,8 @@
v-if="ui.modals.changelog"
v-click-outside="() => toggleModal(ModalWindows.CHANGELOG)"
/>
<UiChatImageOverlay v-if="ui.chatImageOverlay"></UiChatImageOverlay>
<FilesView
v-if="ui.filePreview"
:file="ui.filePreview"
@close="closeFilePreview()"
@share="share"
/>
<UiChatImageOverlay v-if="ui.chatImageOverlay" />
<FilesView v-if="ui.filePreview" @close="closeFilePreview()" @share="share" />
<transition :name="$device.isMobile ? 'slide' : ''">
<InteractablesQuickProfile v-if="ui.quickProfile" :user="ui.quickProfile" />
</transition>
Expand Down
17 changes: 8 additions & 9 deletions components/views/files/view/View.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template src="./View.html"></template>
<script lang="ts">
import Vue, { PropType } from 'vue'
import Vue from 'vue'
import { mapState } from 'vuex'
import {
FileIcon,
Expand All @@ -22,25 +22,24 @@ export default Vue.extend({
XIcon,
LinkIcon,
},
props: {
file: {
type: Object as PropType<Fil>,
required: true,
},
},
data() {
return {
load: false as boolean,
name: this.file.name as string,
file: undefined as Fil | undefined,
name: '' as string,
}
},
computed: {
...mapState(['ui']),
},
/**
*/
async mounted() {
async created() {
this.load = true
this.file = this.$FileSystem.getChild(this.ui.filePreview) as Fil
this.name = this.file?.name
// if no file data available, pull encrypted file from textile bucket
if (!this.file.file) {
const fsFil: Fil = this.$FileSystem.getChild(this.file.name) as Fil
Expand Down
2 changes: 1 addition & 1 deletion pages/files/browse/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default Vue.extend({
*/
handle(item: Item) {
if (item instanceof Fil) {
this.$store.commit('ui/setFilePreview', item)
this.$store.commit('ui/setFilePreview', item.name)
}
if (item instanceof Directory) {
this.fileSystem.openDirectory(item.name)
Expand Down
1 change: 1 addition & 0 deletions plugins/thirdparty/persist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const commonProperties = [
'groups.groupSubscriptions',
'ui.modals',
'ui.isScrollOver',
'ui.filePreview',
]

const propertiesNoStorePin = [
Expand Down
4 changes: 2 additions & 2 deletions store/ui/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export default {
fullscreen(state: UIState, fullscreen: boolean) {
state.fullscreen = fullscreen
},
setFilePreview(state: UIState, file: Fil | undefined) {
state.filePreview = file
setFilePreview(state: UIState, name: string) {
state.filePreview = name
},
setChatImageOverlay(state: UIState, image: ImageMessage | undefined) {
state.chatImageOverlay = image
Expand Down
5 changes: 2 additions & 3 deletions store/ui/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { TranslateResult } from 'vue-i18n'
import { Fil } from '~/libraries/Files/Fil'
import { ImageMessage } from '~/types/textile/mailbox'
import { FileSortEnum } from '~/libraries/Enums/enums'
import { Glyph } from '~/types/ui/glyph'
Expand Down Expand Up @@ -214,8 +213,8 @@ export interface UIState {
}
isLoadingFileIndex: boolean
renameCurrentName?: string
filePreview: Fil | undefined
chatImageOverlay: ImageMessage | undefined
filePreview?: string
chatImageOverlay?: ImageMessage
fileSort: FileSort
}

Expand Down

0 comments on commit 58f0b22

Please sign in to comment.