Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(files): rework store for files modal #2745

Merged
merged 3 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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