npm eslint --fix .
This commit is contained in:
parent
6bea363b9d
commit
2c2b84d31d
@ -24,8 +24,8 @@ export default (store) => {
|
|||||||
path: '/',
|
path: '/',
|
||||||
redirect: _to => {
|
redirect: _to => {
|
||||||
return (store.state.users.currentUser
|
return (store.state.users.currentUser
|
||||||
? store.state.instance.redirectRootLogin
|
? store.state.instance.redirectRootLogin
|
||||||
: store.state.instance.redirectRootNoLogin) || '/main/all'
|
: store.state.instance.redirectRootNoLogin) || '/main/all'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ name: 'public-external-timeline', path: '/main/all', component: PublicAndExternalTimeline },
|
{ name: 'public-external-timeline', path: '/main/all', component: PublicAndExternalTimeline },
|
||||||
|
@ -51,7 +51,7 @@ const Attachment = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
linkClicked ({target}) {
|
linkClicked ({ target }) {
|
||||||
if (target.tagName === 'A') {
|
if (target.tagName === 'A') {
|
||||||
window.open(target.href, '_blank')
|
window.open(target.href, '_blank')
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@ const debounceMilliseconds = 500
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
query: { // function to query results and return a promise
|
query: { // function to query results and return a promise
|
||||||
type: Function,
|
type: Function,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
filter: { // function to filter results in real time
|
filter: { // function to filter results in real time
|
||||||
type: Function
|
type: Function
|
||||||
},
|
},
|
||||||
placeholder: {
|
placeholder: {
|
||||||
|
@ -16,7 +16,7 @@ const chatPanel = {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submit (message) {
|
submit (message) {
|
||||||
this.$store.state.chat.channel.push('new_msg', {text: message}, 10000)
|
this.$store.state.chat.channel.push('new_msg', { text: message }, 10000)
|
||||||
this.currentMessage = ''
|
this.currentMessage = ''
|
||||||
},
|
},
|
||||||
togglePanel () {
|
togglePanel () {
|
||||||
|
@ -86,7 +86,7 @@ const conversation = {
|
|||||||
},
|
},
|
||||||
replies () {
|
replies () {
|
||||||
let i = 1
|
let i = 1
|
||||||
return reduce(this.conversation, (result, {id, in_reply_to_status_id}) => {
|
return reduce(this.conversation, (result, { id, in_reply_to_status_id }) => {
|
||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
const irid = in_reply_to_status_id
|
const irid = in_reply_to_status_id
|
||||||
/* eslint-enable camelcase */
|
/* eslint-enable camelcase */
|
||||||
@ -119,15 +119,15 @@ const conversation = {
|
|||||||
methods: {
|
methods: {
|
||||||
fetchConversation () {
|
fetchConversation () {
|
||||||
if (this.status) {
|
if (this.status) {
|
||||||
this.$store.state.api.backendInteractor.fetchConversation({id: this.status.id})
|
this.$store.state.api.backendInteractor.fetchConversation({ id: this.status.id })
|
||||||
.then(({ancestors, descendants}) => {
|
.then(({ ancestors, descendants }) => {
|
||||||
this.$store.dispatch('addNewStatuses', { statuses: ancestors })
|
this.$store.dispatch('addNewStatuses', { statuses: ancestors })
|
||||||
this.$store.dispatch('addNewStatuses', { statuses: descendants })
|
this.$store.dispatch('addNewStatuses', { statuses: descendants })
|
||||||
})
|
})
|
||||||
.then(() => this.setHighlight(this.statusId))
|
.then(() => this.setHighlight(this.statusId))
|
||||||
} else {
|
} else {
|
||||||
const id = this.$route.params.id
|
const id = this.$route.params.id
|
||||||
this.$store.state.api.backendInteractor.fetchStatus({id})
|
this.$store.state.api.backendInteractor.fetchStatus({ id })
|
||||||
.then((status) => this.$store.dispatch('addNewStatuses', { statuses: [status] }))
|
.then((status) => this.$store.dispatch('addNewStatuses', { statuses: [status] }))
|
||||||
.then(() => this.fetchConversation())
|
.then(() => this.fetchConversation())
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ const EmojiInput = {
|
|||||||
required: true,
|
required: true,
|
||||||
type: String
|
type: String
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
input: undefined,
|
input: undefined,
|
||||||
|
@ -11,9 +11,9 @@ const FavoriteButton = {
|
|||||||
methods: {
|
methods: {
|
||||||
favorite () {
|
favorite () {
|
||||||
if (!this.status.favorited) {
|
if (!this.status.favorited) {
|
||||||
this.$store.dispatch('favorite', {id: this.status.id})
|
this.$store.dispatch('favorite', { id: this.status.id })
|
||||||
} else {
|
} else {
|
||||||
this.$store.dispatch('unfavorite', {id: this.status.id})
|
this.$store.dispatch('unfavorite', { id: this.status.id })
|
||||||
}
|
}
|
||||||
this.animated = true
|
this.animated = true
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -58,7 +58,7 @@ const LoginForm = {
|
|||||||
).then((result) => {
|
).then((result) => {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
if (result.error === 'mfa_required') {
|
if (result.error === 'mfa_required') {
|
||||||
this.requireMFA({app: app, settings: result})
|
this.requireMFA({ app: app, settings: result })
|
||||||
} else {
|
} else {
|
||||||
this.error = result.error
|
this.error = result.error
|
||||||
this.focusOnPasswordInput()
|
this.focusOnPasswordInput()
|
||||||
@ -66,7 +66,7 @@ const LoginForm = {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.login(result).then(() => {
|
this.login(result).then(() => {
|
||||||
this.$router.push({name: 'friends'})
|
this.$router.push({ name: 'friends' })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -16,7 +16,7 @@ const mediaUpload = {
|
|||||||
if (file.size > store.state.instance.uploadlimit) {
|
if (file.size > store.state.instance.uploadlimit) {
|
||||||
const filesize = fileSizeFormatService.fileSizeFormat(file.size)
|
const filesize = fileSizeFormatService.fileSizeFormat(file.size)
|
||||||
const allowedsize = fileSizeFormatService.fileSizeFormat(store.state.instance.uploadlimit)
|
const allowedsize = fileSizeFormatService.fileSizeFormat(store.state.instance.uploadlimit)
|
||||||
self.$emit('upload-failed', 'file_too_big', {filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit})
|
self.$emit('upload-failed', 'file_too_big', { filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
@ -36,7 +36,7 @@ const mediaUpload = {
|
|||||||
},
|
},
|
||||||
fileDrop (e) {
|
fileDrop (e) {
|
||||||
if (e.dataTransfer.files.length > 0) {
|
if (e.dataTransfer.files.length > 0) {
|
||||||
e.preventDefault() // allow dropping text like before
|
e.preventDefault() // allow dropping text like before
|
||||||
this.uploadFile(e.dataTransfer.files[0])
|
this.uploadFile(e.dataTransfer.files[0])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -54,7 +54,7 @@ const mediaUpload = {
|
|||||||
this.uploadReady = true
|
this.uploadReady = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
change ({target}) {
|
change ({ target }) {
|
||||||
for (var i = 0; i < target.files.length; i++) {
|
for (var i = 0; i < target.files.length; i++) {
|
||||||
let file = target.files[i]
|
let file = target.files[i]
|
||||||
this.uploadFile(file)
|
this.uploadFile(file)
|
||||||
|
@ -33,7 +33,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.login(result).then(() => {
|
this.login(result).then(() => {
|
||||||
this.$router.push({name: 'friends'})
|
this.$router.push({ name: 'friends' })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.login(result).then(() => {
|
this.login(result).then(() => {
|
||||||
this.$router.push({name: 'friends'})
|
this.$router.push({ name: 'friends' })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -96,12 +96,12 @@ const MobilePostStatusModal = {
|
|||||||
this.hidden = false
|
this.hidden = false
|
||||||
}
|
}
|
||||||
this.oldScrollPos = window.scrollY
|
this.oldScrollPos = window.scrollY
|
||||||
}, 100, {leading: true, trailing: false}),
|
}, 100, { leading: true, trailing: false }),
|
||||||
|
|
||||||
handleScrollEnd: debounce(function () {
|
handleScrollEnd: debounce(function () {
|
||||||
this.hidden = false
|
this.hidden = false
|
||||||
this.oldScrollPos = window.scrollY
|
this.oldScrollPos = window.scrollY
|
||||||
}, 100, {leading: false, trailing: true})
|
}, 100, { leading: false, trailing: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,12 +52,12 @@ const ModerationTools = {
|
|||||||
if (this.tagsSet.has(tag)) {
|
if (this.tagsSet.has(tag)) {
|
||||||
store.state.api.backendInteractor.untagUser(this.user, tag).then(response => {
|
store.state.api.backendInteractor.untagUser(this.user, tag).then(response => {
|
||||||
if (!response.ok) { return }
|
if (!response.ok) { return }
|
||||||
store.commit('untagUser', {user: this.user, tag})
|
store.commit('untagUser', { user: this.user, tag })
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
store.state.api.backendInteractor.tagUser(this.user, tag).then(response => {
|
store.state.api.backendInteractor.tagUser(this.user, tag).then(response => {
|
||||||
if (!response.ok) { return }
|
if (!response.ok) { return }
|
||||||
store.commit('tagUser', {user: this.user, tag})
|
store.commit('tagUser', { user: this.user, tag })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -66,12 +66,12 @@ const ModerationTools = {
|
|||||||
if (this.user.rights[right]) {
|
if (this.user.rights[right]) {
|
||||||
store.state.api.backendInteractor.deleteRight(this.user, right).then(response => {
|
store.state.api.backendInteractor.deleteRight(this.user, right).then(response => {
|
||||||
if (!response.ok) { return }
|
if (!response.ok) { return }
|
||||||
store.commit('updateRight', {user: this.user, right: right, value: false})
|
store.commit('updateRight', { user: this.user, right: right, value: false })
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
store.state.api.backendInteractor.addRight(this.user, right).then(response => {
|
store.state.api.backendInteractor.addRight(this.user, right).then(response => {
|
||||||
if (!response.ok) { return }
|
if (!response.ok) { return }
|
||||||
store.commit('updateRight', {user: this.user, right: right, value: true})
|
store.commit('updateRight', { user: this.user, right: right, value: true })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -80,7 +80,7 @@ const ModerationTools = {
|
|||||||
const status = !!this.user.deactivated
|
const status = !!this.user.deactivated
|
||||||
store.state.api.backendInteractor.setActivationStatus(this.user, status).then(response => {
|
store.state.api.backendInteractor.setActivationStatus(this.user, status).then(response => {
|
||||||
if (!response.ok) { return }
|
if (!response.ok) { return }
|
||||||
store.commit('updateActivationStatus', {user: this.user, status: status})
|
store.commit('updateActivationStatus', { user: this.user, status: status })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteUserDialog (show) {
|
deleteUserDialog (show) {
|
||||||
@ -89,7 +89,7 @@ const ModerationTools = {
|
|||||||
deleteUser () {
|
deleteUser () {
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
const user = this.user
|
const user = this.user
|
||||||
const {id, name} = user
|
const { id, name } = user
|
||||||
store.state.api.backendInteractor.deleteUser(user)
|
store.state.api.backendInteractor.deleteUser(user)
|
||||||
.then(e => {
|
.then(e => {
|
||||||
this.$store.dispatch('markStatusesAsDeleted', status => user.id === status.user.id)
|
this.$store.dispatch('markStatusesAsDeleted', status => user.id === status.user.id)
|
||||||
|
@ -28,7 +28,7 @@ const registration = {
|
|||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
if ((!this.registrationOpen && !this.token) || this.signedIn) {
|
if ((!this.registrationOpen && !this.token) || this.signedIn) {
|
||||||
this.$router.push({name: 'root'})
|
this.$router.push({ name: 'root' })
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setCaptcha()
|
this.setCaptcha()
|
||||||
@ -61,7 +61,7 @@ const registration = {
|
|||||||
if (!this.$v.$invalid) {
|
if (!this.$v.$invalid) {
|
||||||
try {
|
try {
|
||||||
await this.signUp(this.user)
|
await this.signUp(this.user)
|
||||||
this.$router.push({name: 'friends'})
|
this.$router.push({ name: 'friends' })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Registration failed: ' + error)
|
console.warn('Registration failed: ' + error)
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ const RetweetButton = {
|
|||||||
methods: {
|
methods: {
|
||||||
retweet () {
|
retweet () {
|
||||||
if (!this.status.repeated) {
|
if (!this.status.repeated) {
|
||||||
this.$store.dispatch('retweet', {id: this.status.id})
|
this.$store.dispatch('retweet', { id: this.status.id })
|
||||||
} else {
|
} else {
|
||||||
this.$store.dispatch('unretweet', {id: this.status.id})
|
this.$store.dispatch('unretweet', { id: this.status.id })
|
||||||
}
|
}
|
||||||
this.animated = true
|
this.animated = true
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -29,10 +29,10 @@ const ScopeSelector = {
|
|||||||
},
|
},
|
||||||
css () {
|
css () {
|
||||||
return {
|
return {
|
||||||
public: {selected: this.currentScope === 'public'},
|
public: { selected: this.currentScope === 'public' },
|
||||||
unlisted: {selected: this.currentScope === 'unlisted'},
|
unlisted: { selected: this.currentScope === 'unlisted' },
|
||||||
private: {selected: this.currentScope === 'private'},
|
private: { selected: this.currentScope === 'private' },
|
||||||
direct: {selected: this.currentScope === 'direct'}
|
direct: { selected: this.currentScope === 'direct' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -10,6 +10,12 @@ export default Vue.component('tab-switcher', {
|
|||||||
active: this.$slots.default.findIndex(_ => _.tag)
|
active: this.$slots.default.findIndex(_ => _.tag)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
beforeUpdate () {
|
||||||
|
const currentSlot = this.$slots.default[this.active]
|
||||||
|
if (!currentSlot.tag) {
|
||||||
|
this.active = this.$slots.default.findIndex(_ => _.tag)
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
activateTab (index, dataset) {
|
activateTab (index, dataset) {
|
||||||
return () => {
|
return () => {
|
||||||
@ -20,34 +26,28 @@ export default Vue.component('tab-switcher', {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeUpdate () {
|
|
||||||
const currentSlot = this.$slots.default[this.active]
|
|
||||||
if (!currentSlot.tag) {
|
|
||||||
this.active = this.$slots.default.findIndex(_ => _.tag)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
render (h) {
|
render (h) {
|
||||||
const tabs = this.$slots.default
|
const tabs = this.$slots.default
|
||||||
.map((slot, index) => {
|
.map((slot, index) => {
|
||||||
if (!slot.tag) return
|
if (!slot.tag) return
|
||||||
const classesTab = ['tab']
|
const classesTab = ['tab']
|
||||||
const classesWrapper = ['tab-wrapper']
|
const classesWrapper = ['tab-wrapper']
|
||||||
|
|
||||||
if (index === this.active) {
|
if (index === this.active) {
|
||||||
classesTab.push('active')
|
classesTab.push('active')
|
||||||
classesWrapper.push('active')
|
classesWrapper.push('active')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={ classesWrapper.join(' ')}>
|
<div class={ classesWrapper.join(' ')}>
|
||||||
<button
|
<button
|
||||||
disabled={slot.data.attrs.disabled}
|
disabled={slot.data.attrs.disabled}
|
||||||
onClick={this.activateTab(index)}
|
onClick={this.activateTab(index)}
|
||||||
class={classesTab.join(' ')}>
|
class={classesTab.join(' ')}>
|
||||||
{slot.data.attrs.label}</button>
|
{slot.data.attrs.label}</button>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const contents = this.$slots.default.map((slot, index) => {
|
const contents = this.$slots.default.map((slot, index) => {
|
||||||
if (!slot.tag) return
|
if (!slot.tag) return
|
||||||
|
@ -139,7 +139,7 @@ const Timeline = {
|
|||||||
if (top < 15 &&
|
if (top < 15 &&
|
||||||
!this.paused &&
|
!this.paused &&
|
||||||
!(this.unfocused && this.$store.state.config.pauseOnUnfocused)
|
!(this.unfocused && this.$store.state.config.pauseOnUnfocused)
|
||||||
) {
|
) {
|
||||||
this.showNewStatuses()
|
this.showNewStatuses()
|
||||||
} else {
|
} else {
|
||||||
this.paused = true
|
this.paused = true
|
||||||
|
@ -23,15 +23,15 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
classes () {
|
classes () {
|
||||||
return [{
|
return [{
|
||||||
'user-card-rounded-t': this.rounded === 'top', // set border-top-left-radius and border-top-right-radius
|
'user-card-rounded-t': this.rounded === 'top', // set border-top-left-radius and border-top-right-radius
|
||||||
'user-card-rounded': this.rounded === true, // set border-radius for all sides
|
'user-card-rounded': this.rounded === true, // set border-radius for all sides
|
||||||
'user-card-bordered': this.bordered === true // set border for all sides
|
'user-card-bordered': this.bordered === true // set border for all sides
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
style () {
|
style () {
|
||||||
const color = this.$store.state.config.customTheme.colors
|
const color = this.$store.state.config.customTheme.colors
|
||||||
? this.$store.state.config.customTheme.colors.bg // v2
|
? this.$store.state.config.customTheme.colors.bg // v2
|
||||||
: this.$store.state.config.colors.bg // v1
|
: this.$store.state.config.colors.bg // v1
|
||||||
|
|
||||||
if (color) {
|
if (color) {
|
||||||
const rgb = (typeof color === 'string') ? hex2rgb(color) : color
|
const rgb = (typeof color === 'string') ? hex2rgb(color) : color
|
||||||
@ -110,7 +110,7 @@ export default {
|
|||||||
followUser () {
|
followUser () {
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
this.followRequestInProgress = true
|
this.followRequestInProgress = true
|
||||||
requestFollow(this.user, store).then(({sent}) => {
|
requestFollow(this.user, store).then(({ sent }) => {
|
||||||
this.followRequestInProgress = false
|
this.followRequestInProgress = false
|
||||||
this.followRequestSent = sent
|
this.followRequestSent = sent
|
||||||
})
|
})
|
||||||
@ -141,7 +141,7 @@ export default {
|
|||||||
store.commit('setProfileView', { v })
|
store.commit('setProfileView', { v })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
linkClicked ({target}) {
|
linkClicked ({ target }) {
|
||||||
if (target.tagName === 'SPAN') {
|
if (target.tagName === 'SPAN') {
|
||||||
target = target.parentNode
|
target = target.parentNode
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ const Mfa = {
|
|||||||
this.setupState.setupOTPState = 'confirm'
|
this.setupState.setupOTPState = 'confirm'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
doConfirmOTP () { // handler confirm enable OTP
|
doConfirmOTP () { // handler confirm enable OTP
|
||||||
this.error = null
|
this.error = null
|
||||||
this.backendInteractor.mfaConfirmOTP({
|
this.backendInteractor.mfaConfirmOTP({
|
||||||
token: this.otpConfirmToken,
|
token: this.otpConfirmToken,
|
||||||
|
@ -99,7 +99,7 @@ const UserSettings = {
|
|||||||
return suggestor({ emoji: [
|
return suggestor({ emoji: [
|
||||||
...this.$store.state.instance.emoji,
|
...this.$store.state.instance.emoji,
|
||||||
...this.$store.state.instance.customEmoji
|
...this.$store.state.instance.customEmoji
|
||||||
]})
|
] })
|
||||||
},
|
},
|
||||||
pleromaBackend () {
|
pleromaBackend () {
|
||||||
return this.$store.state.instance.pleromaBackend
|
return this.$store.state.instance.pleromaBackend
|
||||||
@ -144,10 +144,10 @@ const UserSettings = {
|
|||||||
hide_followers: this.hideFollowers,
|
hide_followers: this.hideFollowers,
|
||||||
show_role: this.showRole
|
show_role: this.showRole
|
||||||
/* eslint-enable camelcase */
|
/* eslint-enable camelcase */
|
||||||
}}).then((user) => {
|
} }).then((user) => {
|
||||||
this.$store.commit('addNewUsers', [user])
|
this.$store.commit('addNewUsers', [user])
|
||||||
this.$store.commit('setCurrentUser', user)
|
this.$store.commit('setCurrentUser', user)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateNotificationSettings () {
|
updateNotificationSettings () {
|
||||||
this.$store.state.api.backendInteractor
|
this.$store.state.api.backendInteractor
|
||||||
@ -162,12 +162,12 @@ const UserSettings = {
|
|||||||
if (file.size > this.$store.state.instance[slot + 'limit']) {
|
if (file.size > this.$store.state.instance[slot + 'limit']) {
|
||||||
const filesize = fileSizeFormatService.fileSizeFormat(file.size)
|
const filesize = fileSizeFormatService.fileSizeFormat(file.size)
|
||||||
const allowedsize = fileSizeFormatService.fileSizeFormat(this.$store.state.instance[slot + 'limit'])
|
const allowedsize = fileSizeFormatService.fileSizeFormat(this.$store.state.instance[slot + 'limit'])
|
||||||
this[slot + 'UploadError'] = this.$t('upload.error.base') + ' ' + this.$t('upload.error.file_too_big', {filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit})
|
this[slot + 'UploadError'] = this.$t('upload.error.base') + ' ' + this.$t('upload.error.file_too_big', { filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
reader.onload = ({target}) => {
|
reader.onload = ({ target }) => {
|
||||||
const img = target.result
|
const img = target.result
|
||||||
this[slot + 'Preview'] = img
|
this[slot + 'Preview'] = img
|
||||||
this[slot] = file
|
this[slot] = file
|
||||||
@ -203,7 +203,7 @@ const UserSettings = {
|
|||||||
if (!this.bannerPreview) { return }
|
if (!this.bannerPreview) { return }
|
||||||
|
|
||||||
this.bannerUploading = true
|
this.bannerUploading = true
|
||||||
this.$store.state.api.backendInteractor.updateBanner({banner: this.banner})
|
this.$store.state.api.backendInteractor.updateBanner({ banner: this.banner })
|
||||||
.then((user) => {
|
.then((user) => {
|
||||||
this.$store.commit('addNewUsers', [user])
|
this.$store.commit('addNewUsers', [user])
|
||||||
this.$store.commit('setCurrentUser', user)
|
this.$store.commit('setCurrentUser', user)
|
||||||
@ -269,11 +269,11 @@ const UserSettings = {
|
|||||||
this.deletingAccount = true
|
this.deletingAccount = true
|
||||||
},
|
},
|
||||||
deleteAccount () {
|
deleteAccount () {
|
||||||
this.$store.state.api.backendInteractor.deleteAccount({password: this.deleteAccountConfirmPasswordInput})
|
this.$store.state.api.backendInteractor.deleteAccount({ password: this.deleteAccountConfirmPasswordInput })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 'success') {
|
if (res.status === 'success') {
|
||||||
this.$store.dispatch('logout')
|
this.$store.dispatch('logout')
|
||||||
this.$router.push({name: 'root'})
|
this.$router.push({ name: 'root' })
|
||||||
} else {
|
} else {
|
||||||
this.deleteAccountError = res.error
|
this.deleteAccountError = res.error
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ const UserSettings = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
queryUserIds (query) {
|
queryUserIds (query) {
|
||||||
return userSearchApi.search({query, store: this.$store})
|
return userSearchApi.search({ query, store: this.$store })
|
||||||
.then((users) => {
|
.then((users) => {
|
||||||
this.$store.dispatch('addNewUsers', users)
|
this.$store.dispatch('addNewUsers', users)
|
||||||
return map(users, 'id')
|
return map(users, 'id')
|
||||||
|
@ -37,7 +37,7 @@ const WhoToFollow = {
|
|||||||
getWhoToFollow () {
|
getWhoToFollow () {
|
||||||
const credentials = this.$store.state.users.currentUser.credentials
|
const credentials = this.$store.state.users.currentUser.credentials
|
||||||
if (credentials) {
|
if (credentials) {
|
||||||
apiService.suggestions({credentials: credentials})
|
apiService.suggestions({ credentials: credentials })
|
||||||
.then((reply) => {
|
.then((reply) => {
|
||||||
this.showWhoToFollow(reply)
|
this.showWhoToFollow(reply)
|
||||||
})
|
})
|
||||||
|
@ -29,7 +29,7 @@ function getWhoToFollow (panel) {
|
|||||||
panel.usersToFollow.forEach(toFollow => {
|
panel.usersToFollow.forEach(toFollow => {
|
||||||
toFollow.name = 'Loading...'
|
toFollow.name = 'Loading...'
|
||||||
})
|
})
|
||||||
apiService.suggestions({credentials: credentials})
|
apiService.suggestions({ credentials: credentials })
|
||||||
.then((reply) => {
|
.then((reply) => {
|
||||||
showWhoToFollow(panel, reply)
|
showWhoToFollow(panel, reply)
|
||||||
})
|
})
|
||||||
|
@ -4,39 +4,16 @@ import { getComponentProps } from '../../services/component_utils/component_util
|
|||||||
import './with_load_more.scss'
|
import './with_load_more.scss'
|
||||||
|
|
||||||
const withLoadMore = ({
|
const withLoadMore = ({
|
||||||
fetch, // function to fetch entries and return a promise
|
fetch, // function to fetch entries and return a promise
|
||||||
select, // function to select data from store
|
select, // function to select data from store
|
||||||
destroy, // function called at "destroyed" lifecycle
|
destroy, // function called at "destroyed" lifecycle
|
||||||
childPropName = 'entries', // name of the prop to be passed into the wrapped component
|
childPropName = 'entries', // name of the prop to be passed into the wrapped component
|
||||||
additionalPropNames = [] // additional prop name list of the wrapper component
|
additionalPropNames = [] // additional prop name list of the wrapper component
|
||||||
}) => (WrappedComponent) => {
|
}) => (WrappedComponent) => {
|
||||||
const originalProps = Object.keys(getComponentProps(WrappedComponent))
|
const originalProps = Object.keys(getComponentProps(WrappedComponent))
|
||||||
const props = originalProps.filter(v => v !== childPropName).concat(additionalPropNames)
|
const props = originalProps.filter(v => v !== childPropName).concat(additionalPropNames)
|
||||||
|
|
||||||
return Vue.component('withLoadMore', {
|
return Vue.component('withLoadMore', {
|
||||||
render (createElement) {
|
|
||||||
const props = {
|
|
||||||
props: {
|
|
||||||
...this.$props,
|
|
||||||
[childPropName]: this.entries
|
|
||||||
},
|
|
||||||
on: this.$listeners,
|
|
||||||
scopedSlots: this.$scopedSlots
|
|
||||||
}
|
|
||||||
const children = Object.entries(this.$slots).map(([key, value]) => createElement('template', { slot: key }, value))
|
|
||||||
return (
|
|
||||||
<div class="with-load-more">
|
|
||||||
<WrappedComponent {...props}>
|
|
||||||
{children}
|
|
||||||
</WrappedComponent>
|
|
||||||
<div class="with-load-more-footer">
|
|
||||||
{this.error && <a onClick={this.fetchEntries} class="alert error">{this.$t('general.generic_error')}</a>}
|
|
||||||
{!this.error && this.loading && <i class="icon-spin3 animate-spin"/>}
|
|
||||||
{!this.error && !this.loading && !this.bottomedOut && <a onClick={this.fetchEntries}>{this.$t('general.more')}</a>}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
props,
|
props,
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@ -87,6 +64,29 @@ const withLoadMore = ({
|
|||||||
this.fetchEntries()
|
this.fetchEntries()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
render (createElement) {
|
||||||
|
const props = {
|
||||||
|
props: {
|
||||||
|
...this.$props,
|
||||||
|
[childPropName]: this.entries
|
||||||
|
},
|
||||||
|
on: this.$listeners,
|
||||||
|
scopedSlots: this.$scopedSlots
|
||||||
|
}
|
||||||
|
const children = Object.entries(this.$slots).map(([key, value]) => createElement('template', { slot: key }, value))
|
||||||
|
return (
|
||||||
|
<div class="with-load-more">
|
||||||
|
<WrappedComponent {...props}>
|
||||||
|
{children}
|
||||||
|
</WrappedComponent>
|
||||||
|
<div class="with-load-more-footer">
|
||||||
|
{this.error && <a onClick={this.fetchEntries} class="alert error">{this.$t('general.generic_error')}</a>}
|
||||||
|
{!this.error && this.loading && <i class="icon-spin3 animate-spin"/>}
|
||||||
|
{!this.error && !this.loading && !this.bottomedOut && <a onClick={this.fetchEntries}>{this.$t('general.more')}</a>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@ import { getComponentProps } from '../../services/component_utils/component_util
|
|||||||
import './with_subscription.scss'
|
import './with_subscription.scss'
|
||||||
|
|
||||||
const withSubscription = ({
|
const withSubscription = ({
|
||||||
fetch, // function to fetch entries and return a promise
|
fetch, // function to fetch entries and return a promise
|
||||||
select, // function to select data from store
|
select, // function to select data from store
|
||||||
childPropName = 'content', // name of the prop to be passed into the wrapped component
|
childPropName = 'content', // name of the prop to be passed into the wrapped component
|
||||||
additionalPropNames = [] // additional prop name list of the wrapper component
|
additionalPropNames = [] // additional prop name list of the wrapper component
|
||||||
}) => (WrappedComponent) => {
|
}) => (WrappedComponent) => {
|
||||||
const originalProps = Object.keys(getComponentProps(WrappedComponent))
|
const originalProps = Object.keys(getComponentProps(WrappedComponent))
|
||||||
const props = originalProps.filter(v => v !== childPropName).concat(additionalPropNames)
|
const props = originalProps.filter(v => v !== childPropName).concat(additionalPropNames)
|
||||||
@ -15,37 +15,8 @@ const withSubscription = ({
|
|||||||
return Vue.component('withSubscription', {
|
return Vue.component('withSubscription', {
|
||||||
props: [
|
props: [
|
||||||
...props,
|
...props,
|
||||||
'refresh' // boolean saying to force-fetch data whenever created
|
'refresh' // boolean saying to force-fetch data whenever created
|
||||||
],
|
],
|
||||||
render (createElement) {
|
|
||||||
if (!this.error && !this.loading) {
|
|
||||||
const props = {
|
|
||||||
props: {
|
|
||||||
...this.$props,
|
|
||||||
[childPropName]: this.fetchedData
|
|
||||||
},
|
|
||||||
on: this.$listeners,
|
|
||||||
scopedSlots: this.$scopedSlots
|
|
||||||
}
|
|
||||||
const children = Object.entries(this.$slots).map(([key, value]) => createElement('template', { slot: key }, value))
|
|
||||||
return (
|
|
||||||
<div class="with-subscription">
|
|
||||||
<WrappedComponent {...props}>
|
|
||||||
{children}
|
|
||||||
</WrappedComponent>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<div class="with-subscription-loading">
|
|
||||||
{this.error
|
|
||||||
? <a onClick={this.fetchData} class="alert error">{this.$t('general.generic_error')}</a>
|
|
||||||
: <i class="icon-spin3 animate-spin"/>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
@ -77,6 +48,35 @@ const withSubscription = ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
render (createElement) {
|
||||||
|
if (!this.error && !this.loading) {
|
||||||
|
const props = {
|
||||||
|
props: {
|
||||||
|
...this.$props,
|
||||||
|
[childPropName]: this.fetchedData
|
||||||
|
},
|
||||||
|
on: this.$listeners,
|
||||||
|
scopedSlots: this.$scopedSlots
|
||||||
|
}
|
||||||
|
const children = Object.entries(this.$slots).map(([key, value]) => createElement('template', { slot: key }, value))
|
||||||
|
return (
|
||||||
|
<div class="with-subscription">
|
||||||
|
<WrappedComponent {...props}>
|
||||||
|
{children}
|
||||||
|
</WrappedComponent>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<div class="with-subscription-loading">
|
||||||
|
{this.error
|
||||||
|
? <a onClick={this.fetchData} class="alert error">{this.$t('general.generic_error')}</a>
|
||||||
|
: <i class="icon-spin3 animate-spin"/>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ const mutations = {
|
|||||||
requireToken (state) {
|
requireToken (state) {
|
||||||
state.strategy = TOKEN_STRATEGY
|
state.strategy = TOKEN_STRATEGY
|
||||||
},
|
},
|
||||||
requireMFA (state, {app, settings}) {
|
requireMFA (state, { app, settings }) {
|
||||||
state.settings = settings
|
state.settings = settings
|
||||||
state.app = app
|
state.app = app
|
||||||
state.strategy = TOTP_STRATEGY // default strategy of MFA
|
state.strategy = TOTP_STRATEGY // default strategy of MFA
|
||||||
@ -73,7 +73,7 @@ const mutations = {
|
|||||||
|
|
||||||
// actions
|
// actions
|
||||||
const actions = {
|
const actions = {
|
||||||
async login ({state, dispatch, commit}, {access_token}) {
|
async login ({ state, dispatch, commit }, { access_token }) {
|
||||||
commit('setToken', access_token, { root: true })
|
commit('setToken', access_token, { root: true })
|
||||||
await dispatch('loginUser', access_token, { root: true })
|
await dispatch('loginUser', access_token, { root: true })
|
||||||
resetState(state)
|
resetState(state)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const chat = {
|
const chat = {
|
||||||
state: {
|
state: {
|
||||||
messages: [],
|
messages: [],
|
||||||
channel: {state: ''},
|
channel: { state: '' },
|
||||||
socket: null
|
socket: null
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
@ -29,7 +29,7 @@ const chat = {
|
|||||||
channel.on('new_msg', (msg) => {
|
channel.on('new_msg', (msg) => {
|
||||||
store.commit('addMessage', msg)
|
store.commit('addMessage', msg)
|
||||||
})
|
})
|
||||||
channel.on('messages', ({messages}) => {
|
channel.on('messages', ({ messages }) => {
|
||||||
store.commit('setMessages', messages)
|
store.commit('setMessages', messages)
|
||||||
})
|
})
|
||||||
channel.join()
|
channel.join()
|
||||||
|
@ -56,10 +56,10 @@ const config = {
|
|||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setHighlight ({ commit, dispatch }, { user, color, type }) {
|
setHighlight ({ commit, dispatch }, { user, color, type }) {
|
||||||
commit('setHighlight', {user, color, type})
|
commit('setHighlight', { user, color, type })
|
||||||
},
|
},
|
||||||
setOption ({ commit, dispatch }, { name, value }) {
|
setOption ({ commit, dispatch }, { name, value }) {
|
||||||
commit('setOption', {name, value})
|
commit('setOption', { name, value })
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'theme':
|
case 'theme':
|
||||||
setPreset(value, commit)
|
setPreset(value, commit)
|
||||||
|
@ -9,4 +9,3 @@ export function humanizeErrors (errors) {
|
|||||||
return [...errs, message]
|
return [...errs, message]
|
||||||
}, [])
|
}, [])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ const instance = {
|
|||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setInstanceOption ({ commit, dispatch }, { name, value }) {
|
setInstanceOption ({ commit, dispatch }, { name, value }) {
|
||||||
commit('setInstanceOption', {name, value})
|
commit('setInstanceOption', { name, value })
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'name':
|
case 'name':
|
||||||
dispatch('setPageTitle')
|
dispatch('setPageTitle')
|
||||||
|
@ -3,12 +3,12 @@ const oauthTokens = {
|
|||||||
tokens: []
|
tokens: []
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
fetchTokens ({rootState, commit}) {
|
fetchTokens ({ rootState, commit }) {
|
||||||
rootState.api.backendInteractor.fetchOAuthTokens().then((tokens) => {
|
rootState.api.backendInteractor.fetchOAuthTokens().then((tokens) => {
|
||||||
commit('swapTokens', tokens)
|
commit('swapTokens', tokens)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
revokeToken ({rootState, commit, state}, id) {
|
revokeToken ({ rootState, commit, state }, id) {
|
||||||
rootState.api.backendInteractor.revokeOAuthToken(id).then((response) => {
|
rootState.api.backendInteractor.revokeOAuthToken(id).then((response) => {
|
||||||
if (response.status === 201) {
|
if (response.status === 201) {
|
||||||
commit('swapTokens', state.tokens.filter(token => token.id !== id))
|
commit('swapTokens', state.tokens.filter(token => token.id !== id))
|
||||||
|
@ -80,13 +80,13 @@ const mergeOrAdd = (arr, obj, item) => {
|
|||||||
merge(oldItem, omitBy(item, (v, k) => v === null || k === 'user'))
|
merge(oldItem, omitBy(item, (v, k) => v === null || k === 'user'))
|
||||||
// Reactivity fix.
|
// Reactivity fix.
|
||||||
oldItem.attachments.splice(oldItem.attachments.length)
|
oldItem.attachments.splice(oldItem.attachments.length)
|
||||||
return {item: oldItem, new: false}
|
return { item: oldItem, new: false }
|
||||||
} else {
|
} else {
|
||||||
// This is a new item, prepare it
|
// This is a new item, prepare it
|
||||||
prepareStatus(item)
|
prepareStatus(item)
|
||||||
arr.push(item)
|
arr.push(item)
|
||||||
set(obj, item.id, item)
|
set(obj, item.id, item)
|
||||||
return {item, new: true}
|
return { item, new: true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ const removeStatusFromGlobalStorage = (state, status) => {
|
|||||||
// TODO: Need to remove from allStatusesObject?
|
// TODO: Need to remove from allStatusesObject?
|
||||||
|
|
||||||
// Remove possible notification
|
// Remove possible notification
|
||||||
remove(state.notifications.data, ({action: {id}}) => id === status.id)
|
remove(state.notifications.data, ({ action: { id } }) => id === status.id)
|
||||||
|
|
||||||
// Remove from conversation
|
// Remove from conversation
|
||||||
const conversationId = status.statusnet_conversation_id
|
const conversationId = status.statusnet_conversation_id
|
||||||
@ -270,7 +270,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
|
|||||||
},
|
},
|
||||||
'deletion': (deletion) => {
|
'deletion': (deletion) => {
|
||||||
const uri = deletion.uri
|
const uri = deletion.uri
|
||||||
const status = find(allStatuses, {uri})
|
const status = find(allStatuses, { uri })
|
||||||
if (!status) {
|
if (!status) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -346,8 +346,8 @@ const users = {
|
|||||||
|
|
||||||
const notificationsObject = store.rootState.statuses.notifications.idStore
|
const notificationsObject = store.rootState.statuses.notifications.idStore
|
||||||
const relevantNotifications = Object.entries(notificationsObject)
|
const relevantNotifications = Object.entries(notificationsObject)
|
||||||
.filter(([k, val]) => notificationIds.includes(k))
|
.filter(([k, val]) => notificationIds.includes(k))
|
||||||
.map(([k, val]) => val)
|
.map(([k, val]) => val)
|
||||||
|
|
||||||
// Reconnect users to notifications
|
// Reconnect users to notifications
|
||||||
each(relevantNotifications, (notification) => {
|
each(relevantNotifications, (notification) => {
|
||||||
@ -459,11 +459,11 @@ const users = {
|
|||||||
commit('endLogin')
|
commit('endLogin')
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
commit('endLogin')
|
commit('endLogin')
|
||||||
reject('Failed to connect to server, try again')
|
reject('Failed to connect to server, try again')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,7 @@ const exportFriends = ({ id, credentials }) => {
|
|||||||
let more = true
|
let more = true
|
||||||
while (more) {
|
while (more) {
|
||||||
const maxId = friends.length > 0 ? last(friends).id : undefined
|
const maxId = friends.length > 0 ? last(friends).id : undefined
|
||||||
const users = await fetchFriends({id, maxId, credentials})
|
const users = await fetchFriends({ id, maxId, credentials })
|
||||||
friends = concat(friends, users)
|
friends = concat(friends, users)
|
||||||
if (users.length === 0) {
|
if (users.length === 0) {
|
||||||
more = false
|
more = false
|
||||||
|
@ -59,7 +59,7 @@ const srgbToLinear = (srgb) => {
|
|||||||
* @returns {Number} relative luminance
|
* @returns {Number} relative luminance
|
||||||
*/
|
*/
|
||||||
const relativeLuminance = (srgb) => {
|
const relativeLuminance = (srgb) => {
|
||||||
const {r, g, b} = srgbToLinear(srgb)
|
const { r, g, b } = srgbToLinear(srgb)
|
||||||
return 0.2126 * r + 0.7152 * g + 0.0722 * b
|
return 0.2126 * r + 0.7152 * g + 0.0722 * b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ export const wordAtPosition = (str, pos) => {
|
|||||||
const words = splitIntoWords(str)
|
const words = splitIntoWords(str)
|
||||||
const wordsWithPosition = addPositionToWords(words)
|
const wordsWithPosition = addPositionToWords(words)
|
||||||
|
|
||||||
return find(wordsWithPosition, ({start, end}) => start <= pos && end > pos)
|
return find(wordsWithPosition, ({ start, end }) => start <= pos && end > pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addPositionToWords = (words) => {
|
export const addPositionToWords = (words) => {
|
||||||
|
@ -9,7 +9,7 @@ const fileSizeFormat = (num) => {
|
|||||||
exponent = Math.min(Math.floor(Math.log(num) / Math.log(1024)), units.length - 1)
|
exponent = Math.min(Math.floor(Math.log(num) / Math.log(1024)), units.length - 1)
|
||||||
num = (num / Math.pow(1024, exponent)).toFixed(2) * 1
|
num = (num / Math.pow(1024, exponent)).toFixed(2) * 1
|
||||||
unit = units[exponent]
|
unit = units[exponent]
|
||||||
return {num: num, unit: unit}
|
return { num: num, unit: unit }
|
||||||
}
|
}
|
||||||
const fileSizeFormatService = {
|
const fileSizeFormatService = {
|
||||||
fileSizeFormat
|
fileSizeFormat
|
||||||
|
@ -8,7 +8,7 @@ const fetchAndUpdate = ({ store, credentials }) => {
|
|||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
const startFetching = ({credentials, store}) => {
|
const startFetching = ({ credentials, store }) => {
|
||||||
fetchAndUpdate({ credentials, store })
|
fetchAndUpdate({ credentials, store })
|
||||||
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
|
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
|
||||||
return setInterval(boundFetchAndUpdate, 10000)
|
return setInterval(boundFetchAndUpdate, 10000)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const verifyOTPCode = ({app, instance, mfaToken, code}) => {
|
const verifyOTPCode = ({ app, instance, mfaToken, code }) => {
|
||||||
const url = `${instance}/oauth/mfa/challenge`
|
const url = `${instance}/oauth/mfa/challenge`
|
||||||
const form = new window.FormData()
|
const form = new window.FormData()
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ const verifyOTPCode = ({app, instance, mfaToken, code}) => {
|
|||||||
}).then((data) => data.json())
|
}).then((data) => data.json())
|
||||||
}
|
}
|
||||||
|
|
||||||
const verifyRecoveryCode = ({app, instance, mfaToken, code}) => {
|
const verifyRecoveryCode = ({ app, instance, mfaToken, code }) => {
|
||||||
const url = `${instance}/oauth/mfa/challenge`
|
const url = `${instance}/oauth/mfa/challenge`
|
||||||
const form = new window.FormData()
|
const form = new window.FormData()
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ export const getClientToken = ({ clientId, clientSecret, instance }) => {
|
|||||||
body: form
|
body: form
|
||||||
}).then((data) => data.json())
|
}).then((data) => data.json())
|
||||||
}
|
}
|
||||||
const verifyOTPCode = ({app, instance, mfaToken, code}) => {
|
const verifyOTPCode = ({ app, instance, mfaToken, code }) => {
|
||||||
const url = `${instance}/oauth/mfa/challenge`
|
const url = `${instance}/oauth/mfa/challenge`
|
||||||
const form = new window.FormData()
|
const form = new window.FormData()
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ const verifyOTPCode = ({app, instance, mfaToken, code}) => {
|
|||||||
}).then((data) => data.json())
|
}).then((data) => data.json())
|
||||||
}
|
}
|
||||||
|
|
||||||
const verifyRecoveryCode = ({app, instance, mfaToken, code}) => {
|
const verifyRecoveryCode = ({ app, instance, mfaToken, code }) => {
|
||||||
const url = `${instance}/oauth/mfa/challenge`
|
const url = `${instance}/oauth/mfa/challenge`
|
||||||
const form = new window.FormData()
|
const form = new window.FormData()
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import utils from './utils.js'
|
import utils from './utils.js'
|
||||||
import { parseUser } from '../entity_normalizer/entity_normalizer.service.js'
|
import { parseUser } from '../entity_normalizer/entity_normalizer.service.js'
|
||||||
|
|
||||||
const search = ({query, store}) => {
|
const search = ({ query, store }) => {
|
||||||
return utils.request({
|
return utils.request({
|
||||||
store,
|
store,
|
||||||
url: '/api/v1/accounts/search',
|
url: '/api/v1/accounts/search',
|
||||||
@ -10,8 +10,8 @@ const search = ({query, store}) => {
|
|||||||
resolve: true
|
resolve: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((data) => data.json())
|
.then((data) => data.json())
|
||||||
.then((data) => data.map(parseUser))
|
.then((data) => data.map(parseUser))
|
||||||
}
|
}
|
||||||
const UserSearch = {
|
const UserSearch = {
|
||||||
search
|
search
|
||||||
|
@ -13,7 +13,7 @@ const headers = (store) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const request = ({method = 'GET', url, params, store}) => {
|
const request = ({ method = 'GET', url, params, store }) => {
|
||||||
const instance = store.state.instance.server
|
const instance = store.state.instance.server
|
||||||
let fullUrl = `${instance}${url}`
|
let fullUrl = `${instance}${url}`
|
||||||
|
|
||||||
|
@ -35,4 +35,4 @@ export const visibleNotificationsFromStore = (store, types) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const unseenNotificationsFromStore = store =>
|
export const unseenNotificationsFromStore = store =>
|
||||||
filter(visibleNotificationsFromStore(store), ({seen}) => !seen)
|
filter(visibleNotificationsFromStore(store), ({ seen }) => !seen)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import apiService from '../api/api.service.js'
|
import apiService from '../api/api.service.js'
|
||||||
|
|
||||||
const update = ({store, notifications, older}) => {
|
const update = ({ store, notifications, older }) => {
|
||||||
store.dispatch('setNotificationsError', { value: false })
|
store.dispatch('setNotificationsError', { value: false })
|
||||||
|
|
||||||
store.dispatch('addNewNotifications', { notifications, older })
|
store.dispatch('addNewNotifications', { notifications, older })
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchAndUpdate = ({store, credentials, older = false}) => {
|
const fetchAndUpdate = ({ store, credentials, older = false }) => {
|
||||||
const args = { credentials }
|
const args = { credentials }
|
||||||
const rootState = store.rootState || store.state
|
const rootState = store.rootState || store.state
|
||||||
const timelineData = rootState.statuses.notifications
|
const timelineData = rootState.statuses.notifications
|
||||||
@ -45,7 +45,7 @@ const fetchNotifications = ({ store, args, older }) => {
|
|||||||
.catch(() => store.dispatch('setNotificationsError', { value: true }))
|
.catch(() => store.dispatch('setNotificationsError', { value: true }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const startFetching = ({credentials, store}) => {
|
const startFetching = ({ credentials, store }) => {
|
||||||
fetchAndUpdate({ credentials, store })
|
fetchAndUpdate({ credentials, store })
|
||||||
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
|
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
|
||||||
// Initially there's set flag to silence all desktop notifications so
|
// Initially there's set flag to silence all desktop notifications so
|
||||||
|
@ -13,7 +13,7 @@ const postStatus = ({ store, status, spoilerText, visibility, sensitive, poll, m
|
|||||||
mediaIds,
|
mediaIds,
|
||||||
inReplyToStatusId,
|
inReplyToStatusId,
|
||||||
contentType,
|
contentType,
|
||||||
poll})
|
poll })
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (!data.error) {
|
if (!data.error) {
|
||||||
store.dispatch('addNewStatuses', {
|
store.dispatch('addNewStatuses', {
|
||||||
|
@ -239,12 +239,12 @@ const generateColors = (input) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const htmlColors = Object.entries(colors)
|
const htmlColors = Object.entries(colors)
|
||||||
.reduce((acc, [k, v]) => {
|
.reduce((acc, [k, v]) => {
|
||||||
if (!v) return acc
|
if (!v) return acc
|
||||||
acc.solid[k] = rgb2hex(v)
|
acc.solid[k] = rgb2hex(v)
|
||||||
acc.complete[k] = typeof v.a === 'undefined' ? rgb2hex(v) : rgb2rgba(v)
|
acc.complete[k] = typeof v.a === 'undefined' ? rgb2hex(v) : rgb2rgba(v)
|
||||||
return acc
|
return acc
|
||||||
}, { complete: {}, solid: {} })
|
}, { complete: {}, solid: {} })
|
||||||
return {
|
return {
|
||||||
rules: {
|
rules: {
|
||||||
colors: Object.entries(htmlColors.complete)
|
colors: Object.entries(htmlColors.complete)
|
||||||
|
@ -2,7 +2,7 @@ import { camelCase } from 'lodash'
|
|||||||
|
|
||||||
import apiService from '../api/api.service.js'
|
import apiService from '../api/api.service.js'
|
||||||
|
|
||||||
const update = ({store, statuses, timeline, showImmediately, userId}) => {
|
const update = ({ store, statuses, timeline, showImmediately, userId }) => {
|
||||||
const ccTimeline = camelCase(timeline)
|
const ccTimeline = camelCase(timeline)
|
||||||
|
|
||||||
store.dispatch('setError', { value: false })
|
store.dispatch('setError', { value: false })
|
||||||
@ -15,7 +15,7 @@ const update = ({store, statuses, timeline, showImmediately, userId}) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false, userId = false, tag = false, until}) => {
|
const fetchAndUpdate = ({ store, credentials, timeline = 'friends', older = false, showImmediately = false, userId = false, tag = false, until }) => {
|
||||||
const args = { timeline, credentials }
|
const args = { timeline, credentials }
|
||||||
const rootState = store.rootState || store.state
|
const rootState = store.rootState || store.state
|
||||||
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
|
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
|
||||||
@ -40,17 +40,17 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false
|
|||||||
if (!older && statuses.length >= 20 && !timelineData.loading && numStatusesBeforeFetch > 0) {
|
if (!older && statuses.length >= 20 && !timelineData.loading && numStatusesBeforeFetch > 0) {
|
||||||
store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId })
|
store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId })
|
||||||
}
|
}
|
||||||
update({store, statuses, timeline, showImmediately, userId})
|
update({ store, statuses, timeline, showImmediately, userId })
|
||||||
return statuses
|
return statuses
|
||||||
}, () => store.dispatch('setError', { value: true }))
|
}, () => store.dispatch('setError', { value: true }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const startFetching = ({timeline = 'friends', credentials, store, userId = false, tag = false}) => {
|
const startFetching = ({ timeline = 'friends', credentials, store, userId = false, tag = false }) => {
|
||||||
const rootState = store.rootState || store.state
|
const rootState = store.rootState || store.state
|
||||||
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
|
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
|
||||||
const showImmediately = timelineData.visibleStatuses.length === 0
|
const showImmediately = timelineData.visibleStatuses.length === 0
|
||||||
timelineData.userId = userId
|
timelineData.userId = userId
|
||||||
fetchAndUpdate({timeline, credentials, store, showImmediately, userId, tag})
|
fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag })
|
||||||
const boundFetchAndUpdate = () => fetchAndUpdate({ timeline, credentials, store, userId, tag })
|
const boundFetchAndUpdate = () => fetchAndUpdate({ timeline, credentials, store, userId, tag })
|
||||||
return setInterval(boundFetchAndUpdate, 10000)
|
return setInterval(boundFetchAndUpdate, 10000)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { hex2rgb } from '../color_convert/color_convert.js'
|
import { hex2rgb } from '../color_convert/color_convert.js'
|
||||||
const highlightStyle = (prefs) => {
|
const highlightStyle = (prefs) => {
|
||||||
if (prefs === undefined) return
|
if (prefs === undefined) return
|
||||||
const {color, type} = prefs
|
const { color, type } = prefs
|
||||||
if (typeof color !== 'string') return
|
if (typeof color !== 'string') return
|
||||||
const rgb = hex2rgb(color)
|
const rgb = hex2rgb(color)
|
||||||
if (rgb == null) return
|
if (rgb == null) return
|
||||||
|
@ -3,43 +3,43 @@ var config = require('../../config')
|
|||||||
|
|
||||||
// http://nightwatchjs.org/guide#settings-file
|
// http://nightwatchjs.org/guide#settings-file
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"src_folders": ["test/e2e/specs"],
|
'src_folders': ['test/e2e/specs'],
|
||||||
"output_folder": "test/e2e/reports",
|
'output_folder': 'test/e2e/reports',
|
||||||
"custom_assertions_path": ["test/e2e/custom-assertions"],
|
'custom_assertions_path': ['test/e2e/custom-assertions'],
|
||||||
|
|
||||||
"selenium": {
|
'selenium': {
|
||||||
"start_process": true,
|
'start_process': true,
|
||||||
"server_path": "node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.1.jar",
|
'server_path': 'node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.1.jar',
|
||||||
"host": "127.0.0.1",
|
'host': '127.0.0.1',
|
||||||
"port": 4444,
|
'port': 4444,
|
||||||
"cli_args": {
|
'cli_args': {
|
||||||
"webdriver.chrome.driver": require('chromedriver').path
|
'webdriver.chrome.driver': require('chromedriver').path
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"test_settings": {
|
'test_settings': {
|
||||||
"default": {
|
'default': {
|
||||||
"selenium_port": 4444,
|
'selenium_port': 4444,
|
||||||
"selenium_host": "localhost",
|
'selenium_host': 'localhost',
|
||||||
"silent": true,
|
'silent': true,
|
||||||
"globals": {
|
'globals': {
|
||||||
"devServerURL": "http://localhost:" + (process.env.PORT || config.dev.port)
|
'devServerURL': 'http://localhost:' + (process.env.PORT || config.dev.port)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"chrome": {
|
'chrome': {
|
||||||
"desiredCapabilities": {
|
'desiredCapabilities': {
|
||||||
"browserName": "chrome",
|
'browserName': 'chrome',
|
||||||
"javascriptEnabled": true,
|
'javascriptEnabled': true,
|
||||||
"acceptSslCerts": true
|
'acceptSslCerts': true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"firefox": {
|
'firefox': {
|
||||||
"desiredCapabilities": {
|
'desiredCapabilities': {
|
||||||
"browserName": "firefox",
|
'browserName': 'firefox',
|
||||||
"javascriptEnabled": true,
|
'javascriptEnabled': true,
|
||||||
"acceptSslCerts": true
|
'acceptSslCerts': true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ module.exports = function (config) {
|
|||||||
'FirefoxHeadless': {
|
'FirefoxHeadless': {
|
||||||
base: 'Firefox',
|
base: 'Firefox',
|
||||||
flags: [
|
flags: [
|
||||||
'-headless',
|
'-headless'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { defaultState, mutations, prepareStatus } from '../../../../src/modules/statuses.js'
|
import { defaultState, mutations, prepareStatus } from '../../../../src/modules/statuses.js'
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
const makeMockStatus = ({id, text, type = 'status'}) => {
|
const makeMockStatus = ({ id, text, type = 'status' }) => {
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
user: {id: '0'},
|
user: { id: '0' },
|
||||||
name: 'status',
|
name: 'status',
|
||||||
text: text || `Text number ${id}`,
|
text: text || `Text number ${id}`,
|
||||||
fave_num: 0,
|
fave_num: 0,
|
||||||
@ -17,7 +17,7 @@ const makeMockStatus = ({id, text, type = 'status'}) => {
|
|||||||
describe('Statuses module', () => {
|
describe('Statuses module', () => {
|
||||||
describe('prepareStatus', () => {
|
describe('prepareStatus', () => {
|
||||||
it('sets deleted flag to false', () => {
|
it('sets deleted flag to false', () => {
|
||||||
const aStatus = makeMockStatus({id: '1', text: 'Hello oniichan'})
|
const aStatus = makeMockStatus({ id: '1', text: 'Hello oniichan' })
|
||||||
expect(prepareStatus(aStatus).deleted).to.eq(false)
|
expect(prepareStatus(aStatus).deleted).to.eq(false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -25,7 +25,7 @@ describe('Statuses module', () => {
|
|||||||
describe('addNewStatuses', () => {
|
describe('addNewStatuses', () => {
|
||||||
it('adds the status to allStatuses and to the given timeline', () => {
|
it('adds the status to allStatuses and to the given timeline', () => {
|
||||||
const state = defaultState()
|
const state = defaultState()
|
||||||
const status = makeMockStatus({id: '1'})
|
const status = makeMockStatus({ id: '1' })
|
||||||
|
|
||||||
mutations.addNewStatuses(state, { statuses: [status], timeline: 'public' })
|
mutations.addNewStatuses(state, { statuses: [status], timeline: 'public' })
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ describe('Statuses module', () => {
|
|||||||
|
|
||||||
it('counts the status as new if it has not been seen on this timeline', () => {
|
it('counts the status as new if it has not been seen on this timeline', () => {
|
||||||
const state = defaultState()
|
const state = defaultState()
|
||||||
const status = makeMockStatus({id: '1'})
|
const status = makeMockStatus({ id: '1' })
|
||||||
|
|
||||||
mutations.addNewStatuses(state, { statuses: [status], timeline: 'public' })
|
mutations.addNewStatuses(state, { statuses: [status], timeline: 'public' })
|
||||||
mutations.addNewStatuses(state, { statuses: [status], timeline: 'friends' })
|
mutations.addNewStatuses(state, { statuses: [status], timeline: 'friends' })
|
||||||
@ -55,7 +55,7 @@ describe('Statuses module', () => {
|
|||||||
|
|
||||||
it('add the statuses to allStatuses if no timeline is given', () => {
|
it('add the statuses to allStatuses if no timeline is given', () => {
|
||||||
const state = defaultState()
|
const state = defaultState()
|
||||||
const status = makeMockStatus({id: '1'})
|
const status = makeMockStatus({ id: '1' })
|
||||||
|
|
||||||
mutations.addNewStatuses(state, { statuses: [status] })
|
mutations.addNewStatuses(state, { statuses: [status] })
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ describe('Statuses module', () => {
|
|||||||
|
|
||||||
it('adds the status to allStatuses and to the given timeline, directly visible', () => {
|
it('adds the status to allStatuses and to the given timeline, directly visible', () => {
|
||||||
const state = defaultState()
|
const state = defaultState()
|
||||||
const status = makeMockStatus({id: '1'})
|
const status = makeMockStatus({ id: '1' })
|
||||||
|
|
||||||
mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' })
|
mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' })
|
||||||
|
|
||||||
@ -79,10 +79,10 @@ describe('Statuses module', () => {
|
|||||||
|
|
||||||
it('removes statuses by tag on deletion', () => {
|
it('removes statuses by tag on deletion', () => {
|
||||||
const state = defaultState()
|
const state = defaultState()
|
||||||
const status = makeMockStatus({id: '1'})
|
const status = makeMockStatus({ id: '1' })
|
||||||
const otherStatus = makeMockStatus({id: '3'})
|
const otherStatus = makeMockStatus({ id: '3' })
|
||||||
status.uri = 'xxx'
|
status.uri = 'xxx'
|
||||||
const deletion = makeMockStatus({id: '2', type: 'deletion'})
|
const deletion = makeMockStatus({ id: '2', type: 'deletion' })
|
||||||
deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.'
|
deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.'
|
||||||
deletion.uri = 'xxx'
|
deletion.uri = 'xxx'
|
||||||
|
|
||||||
@ -97,8 +97,8 @@ describe('Statuses module', () => {
|
|||||||
|
|
||||||
it('does not update the maxId when the noIdUpdate flag is set', () => {
|
it('does not update the maxId when the noIdUpdate flag is set', () => {
|
||||||
const state = defaultState()
|
const state = defaultState()
|
||||||
const status = makeMockStatus({id: '1'})
|
const status = makeMockStatus({ id: '1' })
|
||||||
const secondStatus = makeMockStatus({id: '2'})
|
const secondStatus = makeMockStatus({ id: '2' })
|
||||||
|
|
||||||
mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' })
|
mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' })
|
||||||
expect(state.timelines.public.maxId).to.eql('1')
|
expect(state.timelines.public.maxId).to.eql('1')
|
||||||
@ -111,10 +111,10 @@ describe('Statuses module', () => {
|
|||||||
|
|
||||||
it('keeps a descending by id order in timeline.visibleStatuses and timeline.statuses', () => {
|
it('keeps a descending by id order in timeline.visibleStatuses and timeline.statuses', () => {
|
||||||
const state = defaultState()
|
const state = defaultState()
|
||||||
const nonVisibleStatus = makeMockStatus({id: '1'})
|
const nonVisibleStatus = makeMockStatus({ id: '1' })
|
||||||
const status = makeMockStatus({id: '3'})
|
const status = makeMockStatus({ id: '3' })
|
||||||
const statusTwo = makeMockStatus({id: '2'})
|
const statusTwo = makeMockStatus({ id: '2' })
|
||||||
const statusThree = makeMockStatus({id: '4'})
|
const statusThree = makeMockStatus({ id: '4' })
|
||||||
|
|
||||||
mutations.addNewStatuses(state, { statuses: [nonVisibleStatus], showImmediately: false, timeline: 'public' })
|
mutations.addNewStatuses(state, { statuses: [nonVisibleStatus], showImmediately: false, timeline: 'public' })
|
||||||
|
|
||||||
@ -131,9 +131,9 @@ describe('Statuses module', () => {
|
|||||||
|
|
||||||
it('splits retweets from their status and links them', () => {
|
it('splits retweets from their status and links them', () => {
|
||||||
const state = defaultState()
|
const state = defaultState()
|
||||||
const status = makeMockStatus({id: '1'})
|
const status = makeMockStatus({ id: '1' })
|
||||||
const retweet = makeMockStatus({id: '2', type: 'retweet'})
|
const retweet = makeMockStatus({ id: '2', type: 'retweet' })
|
||||||
const modStatus = makeMockStatus({id: '1', text: 'something else'})
|
const modStatus = makeMockStatus({ id: '1', text: 'something else' })
|
||||||
|
|
||||||
retweet.retweeted_status = status
|
retweet.retweeted_status = status
|
||||||
|
|
||||||
@ -156,8 +156,8 @@ describe('Statuses module', () => {
|
|||||||
|
|
||||||
it('replaces existing statuses with the same id', () => {
|
it('replaces existing statuses with the same id', () => {
|
||||||
const state = defaultState()
|
const state = defaultState()
|
||||||
const status = makeMockStatus({id: '1'})
|
const status = makeMockStatus({ id: '1' })
|
||||||
const modStatus = makeMockStatus({id: '1', text: 'something else'})
|
const modStatus = makeMockStatus({ id: '1', text: 'something else' })
|
||||||
|
|
||||||
// Add original status
|
// Add original status
|
||||||
mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' })
|
mutations.addNewStatuses(state, { statuses: [status], showImmediately: true, timeline: 'public' })
|
||||||
@ -173,9 +173,9 @@ describe('Statuses module', () => {
|
|||||||
|
|
||||||
it('replaces existing statuses with the same id, coming from a retweet', () => {
|
it('replaces existing statuses with the same id, coming from a retweet', () => {
|
||||||
const state = defaultState()
|
const state = defaultState()
|
||||||
const status = makeMockStatus({id: '1'})
|
const status = makeMockStatus({ id: '1' })
|
||||||
const modStatus = makeMockStatus({id: '1', text: 'something else'})
|
const modStatus = makeMockStatus({ id: '1', text: 'something else' })
|
||||||
const retweet = makeMockStatus({id: '2', type: 'retweet'})
|
const retweet = makeMockStatus({ id: '2', type: 'retweet' })
|
||||||
retweet.retweeted_status = modStatus
|
retweet.retweeted_status = modStatus
|
||||||
|
|
||||||
// Add original status
|
// Add original status
|
||||||
@ -194,7 +194,7 @@ describe('Statuses module', () => {
|
|||||||
|
|
||||||
it('handles favorite actions', () => {
|
it('handles favorite actions', () => {
|
||||||
const state = defaultState()
|
const state = defaultState()
|
||||||
const status = makeMockStatus({id: '1'})
|
const status = makeMockStatus({ id: '1' })
|
||||||
|
|
||||||
const favorite = {
|
const favorite = {
|
||||||
id: '2',
|
id: '2',
|
||||||
@ -272,14 +272,14 @@ describe('Statuses module', () => {
|
|||||||
it('removes a notification when the notice gets removed', () => {
|
it('removes a notification when the notice gets removed', () => {
|
||||||
const user = { id: '1' }
|
const user = { id: '1' }
|
||||||
const state = defaultState()
|
const state = defaultState()
|
||||||
const status = makeMockStatus({id: '1'})
|
const status = makeMockStatus({ id: '1' })
|
||||||
const otherStatus = makeMockStatus({id: '3'})
|
const otherStatus = makeMockStatus({ id: '3' })
|
||||||
const mentionedStatus = makeMockStatus({id: '2'})
|
const mentionedStatus = makeMockStatus({ id: '2' })
|
||||||
mentionedStatus.attentions = [user]
|
mentionedStatus.attentions = [user]
|
||||||
mentionedStatus.uri = 'xxx'
|
mentionedStatus.uri = 'xxx'
|
||||||
otherStatus.attentions = [user]
|
otherStatus.attentions = [user]
|
||||||
|
|
||||||
const deletion = makeMockStatus({id: '4', type: 'deletion'})
|
const deletion = makeMockStatus({ id: '4', type: 'deletion' })
|
||||||
deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.'
|
deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.'
|
||||||
deletion.uri = 'xxx'
|
deletion.uri = 'xxx'
|
||||||
|
|
||||||
|
@ -24,11 +24,11 @@ describe('The users module', () => {
|
|||||||
const user = { id: '1', name: 'Guy' }
|
const user = { id: '1', name: 'Guy' }
|
||||||
|
|
||||||
mutations.addNewUsers(state, [user])
|
mutations.addNewUsers(state, [user])
|
||||||
mutations.setMuted(state, {user, muted: true})
|
mutations.setMuted(state, { user, muted: true })
|
||||||
|
|
||||||
expect(user.muted).to.eql(true)
|
expect(user.muted).to.eql(true)
|
||||||
|
|
||||||
mutations.setMuted(state, {user, muted: false})
|
mutations.setMuted(state, { user, muted: false })
|
||||||
|
|
||||||
expect(user.muted).to.eql(false)
|
expect(user.muted).to.eql(false)
|
||||||
})
|
})
|
||||||
|
@ -37,4 +37,4 @@ describe('DateUtils', () => {
|
|||||||
expect(DateUtils.relativeTimeShort(time)).to.eql({ num: 2, key: 'time.years_short' })
|
expect(DateUtils.relativeTimeShort(time)).to.eql({ num: 2, key: 'time.years_short' })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -206,15 +206,15 @@ describe('API Entities normalizer', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('sets nsfw for statuses with the #nsfw tag', () => {
|
it('sets nsfw for statuses with the #nsfw tag', () => {
|
||||||
const safe = makeMockStatusQvitter({id: '1', text: 'Hello oniichan'})
|
const safe = makeMockStatusQvitter({ id: '1', text: 'Hello oniichan' })
|
||||||
const nsfw = makeMockStatusQvitter({id: '1', text: 'Hello oniichan #nsfw'})
|
const nsfw = makeMockStatusQvitter({ id: '1', text: 'Hello oniichan #nsfw' })
|
||||||
|
|
||||||
expect(parseStatus(safe).nsfw).to.eq(false)
|
expect(parseStatus(safe).nsfw).to.eq(false)
|
||||||
expect(parseStatus(nsfw).nsfw).to.eq(true)
|
expect(parseStatus(nsfw).nsfw).to.eq(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('leaves existing nsfw settings alone', () => {
|
it('leaves existing nsfw settings alone', () => {
|
||||||
const nsfw = makeMockStatusQvitter({id: '1', text: 'Hello oniichan #nsfw', nsfw: false})
|
const nsfw = makeMockStatusQvitter({ id: '1', text: 'Hello oniichan #nsfw', nsfw: false })
|
||||||
|
|
||||||
expect(parseStatus(nsfw).nsfw).to.eq(false)
|
expect(parseStatus(nsfw).nsfw).to.eq(false)
|
||||||
})
|
})
|
||||||
@ -323,9 +323,9 @@ describe('API Entities normalizer', () => {
|
|||||||
describe('MastoAPI emoji adder', () => {
|
describe('MastoAPI emoji adder', () => {
|
||||||
const emojis = makeMockEmojiMasto()
|
const emojis = makeMockEmojiMasto()
|
||||||
const imageHtml = '<img src="https://example.com/image.png" alt="image" title="image" class="emoji" />'
|
const imageHtml = '<img src="https://example.com/image.png" alt="image" title="image" class="emoji" />'
|
||||||
.replace(/"/g, '\'')
|
.replace(/"/g, '\'')
|
||||||
const thinkHtml = '<img src="https://example.com/think.png" alt="thinking" title="thinking" class="emoji" />'
|
const thinkHtml = '<img src="https://example.com/think.png" alt="thinking" title="thinking" class="emoji" />'
|
||||||
.replace(/"/g, '\'')
|
.replace(/"/g, '\'')
|
||||||
|
|
||||||
it('correctly replaces shortcodes in supplied string', () => {
|
it('correctly replaces shortcodes in supplied string', () => {
|
||||||
const result = addEmojis('This post has :image: emoji and :thinking: emoji', emojis)
|
const result = addEmojis('This post has :image: emoji and :thinking: emoji', emojis)
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
import fileSizeFormatService from '../../../../../src/services/file_size_format/file_size_format.js'
|
import fileSizeFormatService from '../../../../../src/services/file_size_format/file_size_format.js'
|
||||||
describe('fileSizeFormat', () => {
|
describe('fileSizeFormat', () => {
|
||||||
it('Formats file size', () => {
|
it('Formats file size', () => {
|
||||||
const values = [1, 1024, 1048576, 1073741824, 1099511627776]
|
const values = [1, 1024, 1048576, 1073741824, 1099511627776]
|
||||||
const expected = [
|
const expected = [
|
||||||
{
|
{
|
||||||
num: 1,
|
num: 1,
|
||||||
unit: 'B'
|
unit: 'B'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
num: 1,
|
num: 1,
|
||||||
unit: 'KiB'
|
unit: 'KiB'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
num: 1,
|
num: 1,
|
||||||
unit: 'MiB'
|
unit: 'MiB'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
num: 1,
|
num: 1,
|
||||||
unit: 'GiB'
|
unit: 'GiB'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
num: 1,
|
num: 1,
|
||||||
unit: 'TiB'
|
unit: 'TiB'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
var res = []
|
var res = []
|
||||||
for (var value in values) {
|
for (var value in values) {
|
||||||
res.push(fileSizeFormatService.fileSizeFormat(values[value]))
|
res.push(fileSizeFormatService.fileSizeFormat(values[value]))
|
||||||
}
|
}
|
||||||
expect(res).to.eql(expected)
|
expect(res).to.eql(expected)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const example = '<div class="status-content">@<a href="https://sealion.club/user/4" class="h-card mention" title="dewoo">dwmatiz</a> <a href="https://social.heldscal.la/file/3deb764ada10ce64a61b7a070b75dac45f86d2d5bf213bf18873da71d8714d86.png" title="https://social.heldscal.la/file/3deb764ada10ce64a61b7a070b75dac45f86d2d5bf213bf18873da71d8714d86.png" class="attachment" id="attachment-159853" rel="nofollow external">https://social.heldscal.la/attachment/159853</a></div>'
|
|
||||||
|
|
||||||
import { removeAttachmentLinks } from '../../../../../src/services/status_parser/status_parser.js'
|
import { removeAttachmentLinks } from '../../../../../src/services/status_parser/status_parser.js'
|
||||||
|
|
||||||
|
const example = '<div class="status-content">@<a href="https://sealion.club/user/4" class="h-card mention" title="dewoo">dwmatiz</a> <a href="https://social.heldscal.la/file/3deb764ada10ce64a61b7a070b75dac45f86d2d5bf213bf18873da71d8714d86.png" title="https://social.heldscal.la/file/3deb764ada10ce64a61b7a070b75dac45f86d2d5bf213bf18873da71d8714d86.png" class="attachment" id="attachment-159853" rel="nofollow external">https://social.heldscal.la/attachment/159853</a></div>'
|
||||||
|
|
||||||
describe('statusParser.removeAttachmentLinks', () => {
|
describe('statusParser.removeAttachmentLinks', () => {
|
||||||
const exampleWithoutAttachmentLinks = '<div class="status-content">@<a href="https://sealion.club/user/4" class="h-card mention" title="dewoo">dwmatiz</a> </div>'
|
const exampleWithoutAttachmentLinks = '<div class="status-content">@<a href="https://sealion.club/user/4" class="h-card mention" title="dewoo">dwmatiz</a> </div>'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user