Move more functions to lodash/fp
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Родитель
7a4489e0a1
Коммит
807553af6c
|
@ -144,7 +144,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import _ from 'lodash'
|
import debounce from 'lodash/fp/debounce'
|
||||||
|
import uniqBy from 'lodash/fp/uniqBy'
|
||||||
import Autosize from 'vue-autosize'
|
import Autosize from 'vue-autosize'
|
||||||
import debouncePromise from 'debounce-promise'
|
import debouncePromise from 'debounce-promise'
|
||||||
import Actions from '@nextcloud/vue/dist/Components/Actions'
|
import Actions from '@nextcloud/vue/dist/Components/Actions'
|
||||||
|
@ -239,7 +240,7 @@ export default {
|
||||||
draftsPromise: Promise.resolve(),
|
draftsPromise: Promise.resolve(),
|
||||||
attachmentsPromise: Promise.resolve(),
|
attachmentsPromise: Promise.resolve(),
|
||||||
savingDraft: undefined,
|
savingDraft: undefined,
|
||||||
saveDraftDebounced: _.debounce(this.saveDraft, 700),
|
saveDraftDebounced: debounce(700)(this.saveDraft),
|
||||||
state: STATES.EDITING,
|
state: STATES.EDITING,
|
||||||
errorText: undefined,
|
errorText: undefined,
|
||||||
STATES,
|
STATES,
|
||||||
|
@ -331,7 +332,7 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
debouncedSearch(term).then(results => {
|
debouncedSearch(term).then(results => {
|
||||||
this.autocompleteRecipients = _.uniqBy(this.autocompleteRecipients.concat(results), 'email')
|
this.autocompleteRecipients = uniqBy('email')(this.autocompleteRecipients.concat(results))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onAttachmentsUploading(uploaded) {
|
onAttachmentsUploading(uploaded) {
|
||||||
|
|
|
@ -46,7 +46,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import _ from 'lodash'
|
import map from 'lodash/fp/map'
|
||||||
|
import trimStart from 'lodash/fp/trimCharsStart'
|
||||||
import {translate as t} from '@nextcloud/l10n'
|
import {translate as t} from '@nextcloud/l10n'
|
||||||
import {getFilePickerBuilder} from '@nextcloud/dialogs'
|
import {getFilePickerBuilder} from '@nextcloud/dialogs'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
@ -86,7 +87,7 @@ export default {
|
||||||
fileNameToAttachment(name, id) {
|
fileNameToAttachment(name, id) {
|
||||||
return {
|
return {
|
||||||
fileName: name,
|
fileName: name,
|
||||||
displayName: _.trimStart(name, '/'),
|
displayName: trimStart('/')(name),
|
||||||
id,
|
id,
|
||||||
isLocal: id !== undefined,
|
isLocal: id !== undefined,
|
||||||
}
|
}
|
||||||
|
@ -103,7 +104,7 @@ export default {
|
||||||
this.uploads[id].uploaded = uploaded
|
this.uploads[id].uploaded = uploaded
|
||||||
}
|
}
|
||||||
|
|
||||||
const promises = _.map(e.target.files, file => {
|
const promises = map(file => {
|
||||||
Vue.set(this.uploads, file.name, {
|
Vue.set(this.uploads, file.name, {
|
||||||
total: file.size,
|
total: file.size,
|
||||||
uploaded: 0,
|
uploaded: 0,
|
||||||
|
@ -113,7 +114,7 @@ export default {
|
||||||
Logger.info('uploaded')
|
Logger.info('uploaded')
|
||||||
return this.emitNewAttachment(this.fileNameToAttachment(file.name, id))
|
return this.emitNewAttachment(this.fileNameToAttachment(file.name, id))
|
||||||
})
|
})
|
||||||
})
|
})(e.target.files)
|
||||||
|
|
||||||
const done = Promise.all(promises)
|
const done = Promise.all(promises)
|
||||||
.catch(error => Logger.error('could not upload all attachments', {error}))
|
.catch(error => Logger.error('could not upload all attachments', {error}))
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import _ from 'lodash'
|
|
||||||
import AppContent from '@nextcloud/vue/dist/Components/AppContent'
|
import AppContent from '@nextcloud/vue/dist/Components/AppContent'
|
||||||
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile'
|
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile'
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* 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']
|
const specialRolesOrder = ['all', 'inbox', 'flagged', 'drafts', 'sent', 'archive', 'junk', 'trash']
|
||||||
|
|
||||||
export const sortMailboxes = mailboxes => {
|
export const sortMailboxes = mailboxes => {
|
||||||
const clone = _.clone(mailboxes)
|
const c = clone(mailboxes)
|
||||||
clone.sort((f1, f2) => {
|
c.sort((f1, f2) => {
|
||||||
if (f1.specialUse.length && f2.specialUse.length) {
|
if (f1.specialUse.length && f2.specialUse.length) {
|
||||||
const s1 = specialRolesOrder.indexOf(f1.specialUse[0])
|
const s1 = specialRolesOrder.indexOf(f1.specialUse[0])
|
||||||
const s2 = specialRolesOrder.indexOf(f2.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 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/>.
|
* 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 {translate as t} from '@nextcloud/l10n'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
|
@ -54,7 +54,7 @@ export const getters = {
|
||||||
return folder.folders.map(id => state.folders[id])
|
return folder.folders.map(id => state.folders[id])
|
||||||
},
|
},
|
||||||
getUnifiedFolder: state => specialRole => {
|
getUnifiedFolder: state => specialRole => {
|
||||||
return _.head(
|
return head(
|
||||||
state.accounts[UNIFIED_ACCOUNT_ID].folders
|
state.accounts[UNIFIED_ACCOUNT_ID].folders
|
||||||
.map(folderId => state.folders[folderId])
|
.map(folderId => state.folders[folderId])
|
||||||
.filter(folder => folder.specialRole === specialRole)
|
.filter(folder => folder.specialRole === specialRole)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче