Skip to content

Commit

Permalink
Properly append uploaded photos without fetchiung for the full folder
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
  • Loading branch information
skjnldsv authored and nextcloud-command committed Sep 1, 2022
1 parent 3c0ca63 commit a6e7797
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 6 deletions.
4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-src_views_Folders_vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-src_views_Folders_vue.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */

/**
* vue-class-component v7.2.6
* (c) 2015-present Evan You
* @license MIT
*/

/**
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**!
* @fileOverview Kickass library to create and place poppers near their reference elements.
* @version 1.16.1
* @license
* Copyright (c) 2016 Federico Zivolo and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions src/services/FileInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

import { getCurrentUser } from '@nextcloud/auth'
import client from './DavClient'
import request from './DavRequest'
import { genFileInfo } from '../utils/fileUtils'

/**
* Get a file info
*
* @param {string} path the path relative to the user root
* @return {FileInfo} the file info
*/
export default async function(path) {
// getDirectoryContents doesn't accept / for root
const fixedPath = path === '/' ? '' : path

const prefixPath = `/files/${getCurrentUser().uid}`

// fetch listing
const response = await client.stat(prefixPath + fixedPath, {
data: request,
details: true,
})

return genFileInfo(response.data)
}
31 changes: 31 additions & 0 deletions src/store/folders.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ const mutations = {
Vue.set(state.paths, path, fileid)
}
},

/**
* Append files to a folder
*
* @param {object} state vuex state
* @param {object} data destructuring object
* @param {number} data.fileid id of this folder
* @param {Array} data.files list of files to add
*/
addFilesToFolder(state, { fileid, files }) {
if (fileid >= 0 && files.length > 0) {
// and sort by last modified
const list = files
.sort((a, b) => sortCompare(a, b, 'lastmod'))
.filter(file => file.fileid >= 0)
.map(file => file.fileid)
Vue.set(state.folders, fileid, [...list, ...state.folders[fileid]])
}
},
}

const getters = {
Expand Down Expand Up @@ -99,6 +118,18 @@ const actions = {
addPath(context, { path, fileid }) {
context.commit('addPath', { path, fileid })
},

/**
* Append files to a folder
*
* @param {object} context vuex context
* @param {object} data destructuring object
* @param {number} data.fileid id of this folder
* @param {Array} data.files list of files to add
*/
addFilesToFolder(context, { fileid, files }) {
context.commit('addFilesToFolder', { fileid, files })
},
}

export default { state, mutations, getters, actions }
1 change: 1 addition & 0 deletions src/views/Folders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<script>
import { mapGetters } from 'vuex'
import { UploadPicker } from '@nextcloud/upload'
import { getCurrentUser } from '@nextcloud/auth'
import NcEmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
import VirtualGrid from 'vue-virtual-grid'

Expand Down

0 comments on commit a6e7797

Please sign in to comment.