Move more functions to lodash/fp

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2019-10-17 00:22:29 +02:00
Родитель 7a4489e0a1
Коммит 807553af6c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F941078878347C0C
5 изменённых файлов: 15 добавлений и 14 удалений

Просмотреть файл

@ -144,7 +144,8 @@
</template>
<script>
import _ from 'lodash'
import debounce from 'lodash/fp/debounce'
import uniqBy from 'lodash/fp/uniqBy'
import Autosize from 'vue-autosize'
import debouncePromise from 'debounce-promise'
import Actions from '@nextcloud/vue/dist/Components/Actions'
@ -239,7 +240,7 @@ export default {
draftsPromise: Promise.resolve(),
attachmentsPromise: Promise.resolve(),
savingDraft: undefined,
saveDraftDebounced: _.debounce(this.saveDraft, 700),
saveDraftDebounced: debounce(700)(this.saveDraft),
state: STATES.EDITING,
errorText: undefined,
STATES,
@ -331,7 +332,7 @@ export default {
return
}
debouncedSearch(term).then(results => {
this.autocompleteRecipients = _.uniqBy(this.autocompleteRecipients.concat(results), 'email')
this.autocompleteRecipients = uniqBy('email')(this.autocompleteRecipients.concat(results))
})
},
onAttachmentsUploading(uploaded) {

Просмотреть файл

@ -46,7 +46,8 @@
</template>
<script>
import _ from 'lodash'
import map from 'lodash/fp/map'
import trimStart from 'lodash/fp/trimCharsStart'
import {translate as t} from '@nextcloud/l10n'
import {getFilePickerBuilder} from '@nextcloud/dialogs'
import Vue from 'vue'
@ -86,7 +87,7 @@ export default {
fileNameToAttachment(name, id) {
return {
fileName: name,
displayName: _.trimStart(name, '/'),
displayName: trimStart('/')(name),
id,
isLocal: id !== undefined,
}
@ -103,7 +104,7 @@ export default {
this.uploads[id].uploaded = uploaded
}
const promises = _.map(e.target.files, file => {
const promises = map(file => {
Vue.set(this.uploads, file.name, {
total: file.size,
uploaded: 0,
@ -113,7 +114,7 @@ export default {
Logger.info('uploaded')
return this.emitNewAttachment(this.fileNameToAttachment(file.name, id))
})
})
})(e.target.files)
const done = Promise.all(promises)
.catch(error => Logger.error('could not upload all attachments', {error}))

Просмотреть файл

@ -20,7 +20,6 @@
</template>
<script>
import _ from 'lodash'
import AppContent from '@nextcloud/vue/dist/Components/AppContent'
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile'

Просмотреть файл

@ -19,13 +19,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import _ from 'lodash'
import clone from 'lodash/fp/clone'
const specialRolesOrder = ['all', 'inbox', 'flagged', 'drafts', 'sent', 'archive', 'junk', 'trash']
export const sortMailboxes = mailboxes => {
const clone = _.clone(mailboxes)
clone.sort((f1, f2) => {
const c = clone(mailboxes)
c.sort((f1, f2) => {
if (f1.specialUse.length && f2.specialUse.length) {
const s1 = specialRolesOrder.indexOf(f1.specialUse[0])
const s2 = specialRolesOrder.indexOf(f2.specialUse[0])
@ -43,5 +43,5 @@ export const sortMailboxes = mailboxes => {
return atob(f1.id).localeCompare(atob(f2.id))
}
})
return clone
return c
}

Просмотреть файл

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import _ from 'lodash'
import head from 'lodash/fp/head'
import {translate as t} from '@nextcloud/l10n'
import Vue from 'vue'
import Vuex from 'vuex'
@ -54,7 +54,7 @@ export const getters = {
return folder.folders.map(id => state.folders[id])
},
getUnifiedFolder: state => specialRole => {
return _.head(
return head(
state.accounts[UNIFIED_ACCOUNT_ID].folders
.map(folderId => state.folders[folderId])
.filter(folder => folder.specialRole === specialRole)