diff options
Diffstat (limited to 'src')
41 files changed, 1094 insertions, 304 deletions
diff --git a/src/App.scss b/src/App.scss index 244b3474..ae068e4f 100644 --- a/src/App.scss +++ b/src/App.scss @@ -767,3 +767,54 @@ nav { .btn.btn-default { min-height: 28px; } + +.autocomplete { + &-panel { + position: relative; + + &-body { + margin: 0 0.5em 0 0.5em; + border-radius: $fallback--tooltipRadius; + border-radius: var(--tooltipRadius, $fallback--tooltipRadius); + position: absolute; + z-index: 1; + box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.5); + // this doesn't match original but i don't care, making it uniform. + box-shadow: var(--popupShadow); + min-width: 75%; + background: $fallback--bg; + background: var(--bg, $fallback--bg); + color: $fallback--lightText; + color: var(--lightText, $fallback--lightText); + } + } + + &-item { + cursor: pointer; + padding: 0.2em 0.4em 0.2em 0.4em; + border-bottom: 1px solid rgba(0, 0, 0, 0.4); + display: flex; + + img { + width: 24px; + height: 24px; + object-fit: contain; + } + + span { + line-height: 24px; + margin: 0 0.1em 0 0.2em; + } + + small { + margin-left: .5em; + color: $fallback--faint; + color: var(--faint, $fallback--faint); + } + + &.highlighted { + background-color: $fallback--fg; + background-color: var(--lightBg, $fallback--fg); + } + } +}
\ No newline at end of file diff --git a/src/boot/after_store.js b/src/boot/after_store.js index f5add8ad..b6d292dc 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -95,7 +95,7 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => { copyInstanceOption('redirectRootNoLogin') copyInstanceOption('redirectRootLogin') copyInstanceOption('showInstanceSpecificPanel') - copyInstanceOption('scopeOptionsEnabled') + copyInstanceOption('minimalScopesMode') copyInstanceOption('formattingOptionsEnabled') copyInstanceOption('hideMutedPosts') copyInstanceOption('collapseMessageWithSubject') @@ -219,6 +219,28 @@ const getNodeInfo = async ({ store }) => { } } +const setConfig = async ({ store }) => { + // apiConfig, staticConfig + const configInfos = await Promise.all([getStatusnetConfig({ store }), getStaticConfig()]) + const apiConfig = configInfos[0] + const staticConfig = configInfos[1] + + await setSettings({ store, apiConfig, staticConfig }) +} + +const checkOAuthToken = async ({ store }) => { + return new Promise(async (resolve, reject) => { + if (store.state.oauth.token) { + try { + await store.dispatch('loginUser', store.state.oauth.token) + } catch (e) { + console.log(e) + } + } + resolve() + }) +} + const afterStoreSetup = async ({ store, i18n }) => { if (store.state.config.customTheme) { // This is a hack to deal with async loading of config.json and themes @@ -230,19 +252,16 @@ const afterStoreSetup = async ({ store, i18n }) => { }) } - const apiConfig = await getStatusnetConfig({ store }) - const staticConfig = await getStaticConfig() - await setSettings({ store, apiConfig, staticConfig }) - await getTOS({ store }) - await getInstancePanel({ store }) - await getStaticEmoji({ store }) - await getCustomEmoji({ store }) - await getNodeInfo({ store }) - - // Now we have the server settings and can try logging in - if (store.state.oauth.token) { - await store.dispatch('loginUser', store.state.oauth.token) - } + // Now we can try getting the server settings and logging in + await Promise.all([ + checkOAuthToken({ store }), + setConfig({ store }), + getTOS({ store }), + getInstancePanel({ store }), + getStaticEmoji({ store }), + getCustomEmoji({ store }), + getNodeInfo({ store }) + ]) const router = new VueRouter({ mode: 'history', diff --git a/src/components/conversation-page/conversation-page.vue b/src/components/conversation-page/conversation-page.vue index b03eea28..9e322cf5 100644 --- a/src/components/conversation-page/conversation-page.vue +++ b/src/components/conversation-page/conversation-page.vue @@ -1,5 +1,9 @@ <template> - <conversation :collapsable="false" :statusoid="statusoid"></conversation> + <conversation + :collapsable="false" + isPage="true" + :statusoid="statusoid" + ></conversation> </template> <script src="./conversation-page.js"></script> diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index e806be8e..69058bf6 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -1,10 +1,12 @@ -import { reduce, filter } from 'lodash' +import { reduce, filter, findIndex } from 'lodash' import { set } from 'vue' import Status from '../status/status.vue' const sortById = (a, b) => { - const seqA = Number(a.id) - const seqB = Number(b.id) + const idA = a.type === 'retweet' ? a.retweeted_status.id : a.id + const idB = b.type === 'retweet' ? b.retweeted_status.id : b.id + const seqA = Number(idA) + const seqB = Number(idB) const isSeqA = !Number.isNaN(seqA) const isSeqB = !Number.isNaN(seqB) if (isSeqA && isSeqB) { @@ -14,12 +16,19 @@ const sortById = (a, b) => { } else if (!isSeqA && isSeqB) { return 1 } else { - return a.id < b.id ? -1 : 1 + return idA < idB ? -1 : 1 } } -const sortAndFilterConversation = (conversation) => { - conversation = filter(conversation, (status) => status.type !== 'retweet') +const sortAndFilterConversation = (conversation, statusoid) => { + if (statusoid.type === 'retweet') { + conversation = filter( + conversation, + (status) => (status.type === 'retweet' || status.id !== statusoid.retweeted_status.id) + ) + } else { + conversation = filter(conversation, (status) => status.type !== 'retweet') + } return conversation.filter(_ => _).sort(sortById) } @@ -27,13 +36,20 @@ const conversation = { data () { return { highlight: null, + expanded: false, converationStatusIds: [] } }, props: [ 'statusoid', - 'collapsable' + 'collapsable', + 'isPage' ], + created () { + if (this.isPage) { + this.fetchConversation() + } + }, computed: { status () { return this.statusoid @@ -59,12 +75,22 @@ const conversation = { return [] } + if (!this.isExpanded) { + return [this.status] + } + const statusesObject = this.$store.state.statuses.allStatusesObject const conversation = this.idsToShow.reduce((acc, id) => { acc.push(statusesObject[id]) return acc }, []) - return sortAndFilterConversation(conversation) + + const statusIndex = findIndex(conversation, { id: this.statusId }) + if (statusIndex !== -1) { + conversation[statusIndex] = this.status + } + + return sortAndFilterConversation(conversation, this.status) }, replies () { let i = 1 @@ -82,16 +108,21 @@ const conversation = { i++ return result }, {}) + }, + isExpanded () { + return this.expanded || this.isPage } }, components: { Status }, - created () { - this.fetchConversation() - }, watch: { - '$route': 'fetchConversation' + '$route': 'fetchConversation', + expanded (value) { + if (value) { + this.fetchConversation() + } + } }, methods: { fetchConversation () { @@ -101,9 +132,9 @@ const conversation = { this.$store.dispatch('addNewStatuses', { statuses: ancestors }) this.$store.dispatch('addNewStatuses', { statuses: descendants }) set(this, 'converationStatusIds', [].concat( - ancestors.map(_ => _.id), + ancestors.map(_ => _.id).filter(_ => _ !== this.statusId), this.statusId, - descendants.map(_ => _.id))) + descendants.map(_ => _.id).filter(_ => _ !== this.statusId))) }) .then(() => this.setHighlight(this.statusId)) } else { @@ -117,10 +148,19 @@ const conversation = { return this.replies[id] || [] }, focused (id) { - return id === this.statusId + return (this.isExpanded) && id === this.status.id }, setHighlight (id) { this.highlight = id + }, + getHighlight () { + return this.isExpanded ? this.highlight : null + }, + toggleExpanded () { + this.expanded = !this.expanded + if (!this.expanded) { + this.setHighlight(null) + } } } } diff --git a/src/components/conversation/conversation.vue b/src/components/conversation/conversation.vue index 5528fef6..c39a3ed9 100644 --- a/src/components/conversation/conversation.vue +++ b/src/components/conversation/conversation.vue @@ -1,26 +1,42 @@ <template> - <div class="timeline panel panel-default"> - <div class="panel-heading conversation-heading"> + <div class="timeline panel-default" :class="[isExpanded ? 'panel' : 'panel-disabled']"> + <div v-if="isExpanded" class="panel-heading conversation-heading"> <span class="title"> {{ $t('timeline.conversation') }} </span> <span v-if="collapsable"> - <a href="#" @click.prevent="$emit('toggleExpanded')">{{ $t('timeline.collapse') }}</a> + <a href="#" @click.prevent="toggleExpanded">{{ $t('timeline.collapse') }}</a> </span> </div> - <div class="panel-body"> - <div class="timeline"> - <status - v-for="status in conversation" - @goto="setHighlight" :key="status.id" - :inlineExpanded="collapsable" :statusoid="status" - :expandable='false' :focused="focused(status.id)" - :inConversation='true' - :highlight="highlight" - :replies="getReplies(status.id)" - class="status-fadein"> - </status> - </div> - </div> + <status + v-for="status in conversation" + @goto="setHighlight" + @toggleExpanded="toggleExpanded" + :key="status.id" + :inlineExpanded="collapsable" + :statusoid="status" + :expandable='!expanded' + :focused="focused(status.id)" + :inConversation="isExpanded" + :highlight="getHighlight()" + :replies="getReplies(status.id)" + class="status-fadein panel-body" + /> </div> </template> <script src="./conversation.js"></script> + +<style lang="scss"> +@import '../../_variables.scss'; + +.timeline { + .panel-disabled { + .status-el { + border-left: none; + border-bottom-width: 1px; + border-bottom-style: solid; + border-color: var(--border, $fallback--border); + border-radius: 0; + } + } +} +</style> diff --git a/src/components/emoji-input/emoji-input.js b/src/components/emoji-input/emoji-input.js new file mode 100644 index 00000000..a5bb6eaf --- /dev/null +++ b/src/components/emoji-input/emoji-input.js @@ -0,0 +1,107 @@ +import Completion from '../../services/completion/completion.js' +import { take, filter, map } from 'lodash' + +const EmojiInput = { + props: [ + 'value', + 'placeholder', + 'type', + 'classname' + ], + data () { + return { + highlighted: 0, + caret: 0 + } + }, + computed: { + suggestions () { + const firstchar = this.textAtCaret.charAt(0) + if (firstchar === ':') { + if (this.textAtCaret === ':') { return } + const matchedEmoji = filter(this.emoji.concat(this.customEmoji), (emoji) => emoji.shortcode.startsWith(this.textAtCaret.slice(1))) + if (matchedEmoji.length <= 0) { + return false + } + return map(take(matchedEmoji, 5), ({shortcode, image_url, utf}, index) => ({ + shortcode: `:${shortcode}:`, + utf: utf || '', + // eslint-disable-next-line camelcase + img: utf ? '' : this.$store.state.instance.server + image_url, + highlighted: index === this.highlighted + })) + } else { + return false + } + }, + textAtCaret () { + return (this.wordAtCaret || {}).word || '' + }, + wordAtCaret () { + const word = Completion.wordAtPosition(this.value, this.caret - 1) || {} + return word + }, + emoji () { + return this.$store.state.instance.emoji || [] + }, + customEmoji () { + return this.$store.state.instance.customEmoji || [] + } + }, + methods: { + replace (replacement) { + const newValue = Completion.replaceWord(this.value, this.wordAtCaret, replacement) + this.$emit('input', newValue) + this.caret = 0 + }, + replaceEmoji (e) { + const len = this.suggestions.length || 0 + if (this.textAtCaret === ':' || e.ctrlKey) { return } + if (len > 0) { + e.preventDefault() + const emoji = this.suggestions[this.highlighted] + const replacement = emoji.utf || (emoji.shortcode + ' ') + const newValue = Completion.replaceWord(this.value, this.wordAtCaret, replacement) + this.$emit('input', newValue) + this.caret = 0 + this.highlighted = 0 + } + }, + cycleBackward (e) { + const len = this.suggestions.length || 0 + if (len > 0) { + e.preventDefault() + this.highlighted -= 1 + if (this.highlighted < 0) { + this.highlighted = this.suggestions.length - 1 + } + } else { + this.highlighted = 0 + } + }, + cycleForward (e) { + const len = this.suggestions.length || 0 + if (len > 0) { + if (e.shiftKey) { return } + e.preventDefault() + this.highlighted += 1 + if (this.highlighted >= len) { + this.highlighted = 0 + } + } else { + this.highlighted = 0 + } + }, + onKeydown (e) { + e.stopPropagation() + }, + onInput (e) { + this.$emit('input', e.target.value) + }, + setCaret ({target: {selectionStart}}) { + this.caret = selectionStart + } + } +} + +export default EmojiInput diff --git a/src/components/emoji-input/emoji-input.vue b/src/components/emoji-input/emoji-input.vue new file mode 100644 index 00000000..338b77cd --- /dev/null +++ b/src/components/emoji-input/emoji-input.vue @@ -0,0 +1,64 @@ +<template> + <div class="emoji-input"> + <input + v-if="type !== 'textarea'" + :class="classname" + :type="type" + :value="value" + :placeholder="placeholder" + @input="onInput" + @click="setCaret" + @keyup="setCaret" + @keydown="onKeydown" + @keydown.down="cycleForward" + @keydown.up="cycleBackward" + @keydown.shift.tab="cycleBackward" + @keydown.tab="cycleForward" + @keydown.enter="replaceEmoji" + /> + <textarea + v-else + :class="classname" + :value="value" + :placeholder="placeholder" + @input="onInput" + @click="setCaret" + @keyup="setCaret" + @keydown="onKeydown" + @keydown.down="cycleForward" + @keydown.up="cycleBackward" + @keydown.shift.tab="cycleBackward" + @keydown.tab="cycleForward" + @keydown.enter="replaceEmoji" + ></textarea> + <div class="autocomplete-panel" v-if="suggestions"> + <div class="autocomplete-panel-body"> + <div + v-for="(emoji, index) in suggestions" + :key="index" + @click="replace(emoji.utf || (emoji.shortcode + ' '))" + class="autocomplete-item" + :class="{ highlighted: emoji.highlighted }" + > + <span v-if="emoji.img"> + <img :src="emoji.img" /> + </span> + <span v-else>{{emoji.utf}}</span> + <span>{{emoji.shortcode}}</span> + </div> + </div> + </div> + </div> +</template> + +<script src="./emoji-input.js"></script> + +<style lang="scss"> +@import '../../_variables.scss'; + +.emoji-input { + .form-control { + width: 100%; + } +} +</style> diff --git a/src/components/features_panel/features_panel.js b/src/components/features_panel/features_panel.js index e0b7a118..5f0b7b25 100644 --- a/src/components/features_panel/features_panel.js +++ b/src/components/features_panel/features_panel.js @@ -6,7 +6,7 @@ const FeaturesPanel = { gopher: function () { return this.$store.state.instance.gopherAvailable }, whoToFollow: function () { return this.$store.state.instance.suggestionsEnabled }, mediaProxy: function () { return this.$store.state.instance.mediaProxyAvailable }, - scopeOptions: function () { return this.$store.state.instance.scopeOptionsEnabled }, + minimalScopesMode: function () { return this.$store.state.instance.minimalScopesMode }, textlimit: function () { return this.$store.state.instance.textlimit } } } diff --git a/src/components/features_panel/features_panel.vue b/src/components/features_panel/features_panel.vue index 445143e9..7a263e01 100644 --- a/src/components/features_panel/features_panel.vue +++ b/src/components/features_panel/features_panel.vue @@ -12,7 +12,7 @@ <li v-if="gopher">{{$t('features_panel.gopher')}}</li> <li v-if="whoToFollow">{{$t('features_panel.who_to_follow')}}</li> <li v-if="mediaProxy">{{$t('features_panel.media_proxy')}}</li> - <li v-if="scopeOptions">{{$t('features_panel.scope_options')}}</li> + <li>{{$t('features_panel.scope_options')}}</li> <li>{{$t('features_panel.text_limit')}} = {{textlimit}}</li> </ul> </div> diff --git a/src/components/notification/notification.js b/src/components/notification/notification.js index fe5b7018..42a48f3f 100644 --- a/src/components/notification/notification.js +++ b/src/components/notification/notification.js @@ -31,6 +31,15 @@ const Notification = { const highlight = this.$store.state.config.highlight const user = this.notification.action.user return highlightStyle(highlight[user.screen_name]) + }, + userInStore () { + return this.$store.getters.findUser(this.notification.action.user.id) + }, + user () { + if (this.userInStore) { + return this.userInStore + } + return {} } } } diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue index 5e9cef97..8f532747 100644 --- a/src/components/notification/notification.vue +++ b/src/components/notification/notification.vue @@ -1,11 +1,11 @@ <template> <status v-if="notification.type === 'mention'" :compact="true" :statusoid="notification.status"></status> - <div class="non-mention" :class="[userClass, { highlighted: userStyle }]" :style="[ userStyle ]"v-else> + <div class="non-mention" :class="[userClass, { highlighted: userStyle }]" :style="[ userStyle ]" v-else> <a class='avatar-container' :href="notification.action.user.statusnet_profile_url" @click.stop.prevent.capture="toggleUserExpanded"> <UserAvatar :compact="true" :betterShadow="betterShadow" :src="notification.action.user.profile_image_url_original"/> </a> <div class='notification-right'> - <UserCard :user="notification.action.user" :rounded="true" :bordered="true" v-if="userExpanded"/> + <UserCard :user="user" :rounded="true" :bordered="true" v-if="userExpanded"/> <span class="notification-details"> <div class="name-and-action"> <span class="username" v-if="!!notification.action.user.name_html" :title="'@'+notification.action.user.screen_name" v-html="notification.action.user.name_html"></span> diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index c5f30ca6..40e2610e 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -1,5 +1,7 @@ import statusPoster from '../../services/status_poster/status_poster.service.js' import MediaUpload from '../media_upload/media_upload.vue' +import ScopeSelector from '../scope_selector/scope_selector.vue' +import EmojiInput from '../emoji-input/emoji-input.vue' import fileTypeService from '../../services/file_type/file_type.service.js' import Completion from '../../services/completion/completion.js' import { take, filter, reject, map, uniqBy } from 'lodash' @@ -28,7 +30,9 @@ const PostStatusForm = { 'subject' ], components: { - MediaUpload + MediaUpload, + ScopeSelector, + EmojiInput }, mounted () { this.resize(this.$refs.textarea) @@ -78,14 +82,6 @@ const PostStatusForm = { } }, computed: { - vis () { - return { - public: { selected: this.newStatus.visibility === 'public' }, - unlisted: { selected: this.newStatus.visibility === 'unlisted' }, - private: { selected: this.newStatus.visibility === 'private' }, - direct: { selected: this.newStatus.visibility === 'direct' } - } - }, candidates () { const firstchar = this.textAtCaret.charAt(0) if (firstchar === '@') { @@ -133,6 +129,15 @@ const PostStatusForm = { users () { return this.$store.state.users.users }, + userDefaultScope () { + return this.$store.state.users.currentUser.default_scope + }, + showAllScopes () { + const minimalScopesMode = typeof this.$store.state.config.minimalScopesMode === 'undefined' + ? this.$store.state.instance.minimalScopesMode + : this.$store.state.config.minimalScopesMode + return !minimalScopesMode + }, emoji () { return this.$store.state.instance.emoji || [] }, @@ -157,8 +162,8 @@ const PostStatusForm = { isOverLengthLimit () { return this.hasStatusLengthLimit && (this.charactersLeft < 0) }, - scopeOptionsEnabled () { - return this.$store.state.instance.scopeOptionsEnabled + minimalScopesMode () { + return this.$store.state.instance.minimalScopesMode }, alwaysShowSubject () { if (typeof this.$store.state.config.alwaysShowSubjectInput !== 'undefined') { @@ -166,7 +171,7 @@ const PostStatusForm = { } else if (typeof this.$store.state.instance.alwaysShowSubjectInput !== 'undefined') { return this.$store.state.instance.alwaysShowSubjectInput } else { - return this.$store.state.instance.scopeOptionsEnabled + return true } }, formattingOptionsEnabled () { diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 612f87c1..3d3a1082 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -10,12 +10,13 @@ <router-link :to="{ name: 'user-settings' }">{{ $t('post_status.account_not_locked_warning_link') }}</router-link> </i18n> <p v-if="this.newStatus.visibility == 'direct'" class="visibility-notice">{{ $t('post_status.direct_warning') }}</p> - <input + <EmojiInput v-if="newStatus.spoilerText || alwaysShowSubject" type="text" :placeholder="$t('post_status.content_warning')" v-model="newStatus.spoilerText" - class="form-cw"> + classname="form-control" + /> <textarea ref="textarea" @click="setCaret" @@ -47,22 +48,26 @@ </label> </span> - <div v-if="scopeOptionsEnabled"> - <i v-on:click="changeVis('direct')" class="icon-mail-alt" :class="vis.direct" :title="$t('post_status.scope.direct')"></i> - <i v-on:click="changeVis('private')" class="icon-lock" :class="vis.private" :title="$t('post_status.scope.private')"></i> - <i v-on:click="changeVis('unlisted')" class="icon-lock-open-alt" :class="vis.unlisted" :title="$t('post_status.scope.unlisted')"></i> - <i v-on:click="changeVis('public')" class="icon-globe" :class="vis.public" :title="$t('post_status.scope.public')"></i> - </div> + <scope-selector + :showAll="showAllScopes" + :userDefault="userDefaultScope" + :originalScope="copyMessageScope" + :initialScope="newStatus.visibility" + :onScopeChange="changeVis"/> </div> </div> - <div style="position:relative;" v-if="candidates"> - <div class="autocomplete-panel"> - <div v-for="candidate in candidates" @click="replace(candidate.utf || (candidate.screen_name + ' '))"> - <div class="autocomplete" :class="{ highlighted: candidate.highlighted }"> - <span v-if="candidate.img"><img :src="candidate.img"></img></span> - <span v-else>{{candidate.utf}}</span> - <span>{{candidate.screen_name}}<small>{{candidate.name}}</small></span> - </div> + <div class="autocomplete-panel" v-if="candidates"> + <div class="autocomplete-panel-body"> + <div + v-for="(candidate, index) in candidates" + :key="index" + @click="replace(candidate.utf || (candidate.screen_name + ' '))" + class="autocomplete-item" + :class="{ highlighted: candidate.highlighted }" + > + <span v-if="candidate.img"><img :src="candidate.img" /></span> + <span v-else>{{candidate.utf}}</span> + <span>{{candidate.screen_name}}<small>{{candidate.name}}</small></span> </div> </div> </div> @@ -261,50 +266,5 @@ cursor: pointer; z-index: 4; } - - .autocomplete-panel { - margin: 0 0.5em 0 0.5em; - border-radius: $fallback--tooltipRadius; - border-radius: var(--tooltipRadius, $fallback--tooltipRadius); - position: absolute; - z-index: 1; - box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.5); - // this doesn't match original but i don't care, making it uniform. - box-shadow: var(--popupShadow); - min-width: 75%; - background: $fallback--bg; - background: var(--bg, $fallback--bg); - color: $fallback--lightText; - color: var(--lightText, $fallback--lightText); - } - - .autocomplete { - cursor: pointer; - padding: 0.2em 0.4em 0.2em 0.4em; - border-bottom: 1px solid rgba(0, 0, 0, 0.4); - display: flex; - - img { - width: 24px; - height: 24px; - object-fit: contain; - } - - span { - line-height: 24px; - margin: 0 0.1em 0 0.2em; - } - - small { - margin-left: .5em; - color: $fallback--faint; - color: var(--faint, $fallback--faint); - } - - &.highlighted { - background-color: $fallback--fg; - background-color: var(--lightBg, $fallback--fg); - } - } } </style> diff --git a/src/components/scope_selector/scope_selector.js b/src/components/scope_selector/scope_selector.js new file mode 100644 index 00000000..8a42ee7b --- /dev/null +++ b/src/components/scope_selector/scope_selector.js @@ -0,0 +1,54 @@ +const ScopeSelector = { + props: [ + 'showAll', + 'userDefault', + 'originalScope', + 'initialScope', + 'onScopeChange' + ], + data () { + return { + currentScope: this.initialScope + } + }, + computed: { + showNothing () { + return !this.showPublic && !this.showUnlisted && !this.showPrivate && !this.showDirect + }, + showPublic () { + return this.originalScope !== 'direct' && this.shouldShow('public') + }, + showUnlisted () { + return this.originalScope !== 'direct' && this.shouldShow('unlisted') + }, + showPrivate () { + return this.originalScope !== 'direct' && this.shouldShow('private') + }, + showDirect () { + return this.shouldShow('direct') + }, + css () { + return { + public: {selected: this.currentScope === 'public'}, + unlisted: {selected: this.currentScope === 'unlisted'}, + private: {selected: this.currentScope === 'private'}, + direct: {selected: this.currentScope === 'direct'} + } + } + }, + methods: { + shouldShow (scope) { + return this.showAll || + this.currentScope === scope || + this.originalScope === scope || + this.userDefault === scope || + scope === 'direct' + }, + changeVis (scope) { + this.currentScope = scope + this.onScopeChange && this.onScopeChange(scope) + } + } +} + +export default ScopeSelector diff --git a/src/components/scope_selector/scope_selector.vue b/src/components/scope_selector/scope_selector.vue new file mode 100644 index 00000000..33ea488f --- /dev/null +++ b/src/components/scope_selector/scope_selector.vue @@ -0,0 +1,30 @@ +<template> +<div v-if="!showNothing"> + <i class="icon-mail-alt" + :class="css.direct" + :title="$t('post_status.scope.direct')" + v-if="showDirect" + @click="changeVis('direct')"> + </i> + <i class="icon-lock" + :class="css.private" + :title="$t('post_status.scope.private')" + v-if="showPrivate" + v-on:click="changeVis('private')"> + </i> + <i class="icon-lock-open-alt" + :class="css.unlisted" + :title="$t('post_status.scope.unlisted')" + v-if="showUnlisted" + @click="changeVis('unlisted')"> + </i> + <i class="icon-globe" + :class="css.public" + :title="$t('post_status.scope.public')" + v-if="showPublic" + @click="changeVis('public')"> + </i> +</div> +</template> + +<script src="./scope_selector.js"></script> diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index 1d5f75ed..a85ab674 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -70,13 +70,18 @@ const settings = { alwaysShowSubjectInputLocal: typeof user.alwaysShowSubjectInput === 'undefined' ? instance.alwaysShowSubjectInput : user.alwaysShowSubjectInput, - alwaysShowSubjectInputDefault: instance.alwaysShowSubjectInput, + alwaysShowSubjectInputDefault: this.$t('settings.values.' + instance.alwaysShowSubjectInput), scopeCopyLocal: typeof user.scopeCopy === 'undefined' ? instance.scopeCopy : user.scopeCopy, scopeCopyDefault: this.$t('settings.values.' + instance.scopeCopy), + minimalScopesModeLocal: typeof user.minimalScopesMode === 'undefined' + ? instance.minimalScopesMode + : user.minimalScopesMode, + minimalScopesModeDefault: this.$t('settings.values.' + instance.minimalScopesMode), + stopGifs: user.stopGifs, webPushNotificationsLocal: user.webPushNotifications, loopVideoSilentOnlyLocal: user.loopVideosSilentOnly, @@ -200,6 +205,9 @@ const settings = { postContentTypeLocal (value) { this.$store.dispatch('setOption', { name: 'postContentType', value }) }, + minimalScopesModeLocal (value) { + this.$store.dispatch('setOption', { name: 'minimalScopesMode', value }) + }, stopGifs (value) { this.$store.dispatch('setOption', { name: 'stopGifs', value }) }, diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue index 33dad549..6ee103c7 100644 --- a/src/components/settings/settings.vue +++ b/src/components/settings/settings.vue @@ -118,6 +118,12 @@ </label> </div> </li> + <li> + <input type="checkbox" id="minimalScopesMode" v-model="minimalScopesModeLocal"> + <label for="minimalScopesMode"> + {{$t('settings.minimal_scopes_mode')}} {{$t('settings.instance_default', { value: minimalScopesModeDefault })}} + </label> + </li> </ul> </div> diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js index ad3738d1..567d2e5e 100644 --- a/src/components/side_drawer/side_drawer.js +++ b/src/components/side_drawer/side_drawer.js @@ -1,17 +1,16 @@ import UserCard from '../user_card/user_card.vue' import { unseenNotificationsFromStore } from '../../services/notification_utils/notification_utils' - -// TODO: separate touch gesture stuff into their own utils if more components want them -const deltaCoord = (oldCoord, newCoord) => [newCoord[0] - oldCoord[0], newCoord[1] - oldCoord[1]] - -const touchEventCoord = e => ([e.touches[0].screenX, e.touches[0].screenY]) +import GestureService from '../../services/gesture_service/gesture_service' const SideDrawer = { props: [ 'logout' ], data: () => ({ closed: true, - touchCoord: [0, 0] + closeGesture: undefined }), + created () { + this.closeGesture = GestureService.swipeGesture(GestureService.DIRECTION_LEFT, this.toggleDrawer) + }, components: { UserCard }, computed: { currentUser () { @@ -46,13 +45,10 @@ const SideDrawer = { this.toggleDrawer() }, touchStart (e) { - this.touchCoord = touchEventCoord(e) + GestureService.beginSwipe(e, this.closeGesture) }, touchMove (e) { - const delta = deltaCoord(this.touchCoord, touchEventCoord(e)) - if (delta[0] < -30 && Math.abs(delta[1]) < Math.abs(delta[0]) && !this.closed) { - this.toggleDrawer() - } + GestureService.updateSwipe(e, this.closeGesture) } } } diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index 95ee21b4..e5046496 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -2,6 +2,7 @@ <div class="side-drawer-container" :class="{ 'side-drawer-container-closed': closed, 'side-drawer-container-open': !closed }" > + <div class="side-drawer-darken" :class="{ 'side-drawer-darken-closed': closed}" /> <div class="side-drawer" :class="{'side-drawer-closed': closed}" @touchstart="touchStart" @@ -111,16 +112,32 @@ height: 100%; display: flex; align-items: stretch; + transition-duration: 0s; + transition-property: transform; } .side-drawer-container-open { + transform: translate(0%); +} + +.side-drawer-container-closed { + transition-delay: 0.35s; + transform: translate(-100%); +} + +.side-drawer-darken { + top: 0; + left: 0; + width: 100vw; + height: 100vh; + position: fixed; + z-index: -1; transition: 0.35s; transition-property: background-color; background-color: rgba(0, 0, 0, 0.5); } -.side-drawer-container-closed { - left: -100%; +.side-drawer-darken-closed { background-color: rgba(0, 0, 0, 0); } @@ -130,8 +147,9 @@ .side-drawer { overflow-x: hidden; - transition: 0.35s; transition-timing-function: cubic-bezier(0, 1, 0.5, 1); + transition: 0.35s; + transition-property: transform; margin: 0 0 0 -100px; padding: 0 0 1em 100px; width: 80%; diff --git a/src/components/status/status.js b/src/components/status/status.js index c90da6d4..0295cd04 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -251,6 +251,12 @@ const Status = { }, maxThumbnails () { return this.$store.state.config.maxThumbnails + }, + contentHtml () { + if (!this.status.summary_html) { + return this.status.statusnet_html + } + return this.status.summary_html + '<br />' + this.status.statusnet_html } }, components: { @@ -310,7 +316,6 @@ const Status = { this.replying = !this.replying }, gotoOriginal (id) { - // only handled by conversation, not status_or_conversation if (this.inConversation) { this.$emit('goto', id) } diff --git a/src/components/status/status.vue b/src/components/status/status.vue index 1f6d0325..690e8318 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -12,7 +12,7 @@ </div> </template> <template v-else> - <div v-if="retweet && !noHeading" :class="[repeaterClass, { highlighted: repeaterStyle }]" :style="[repeaterStyle]" class="media container retweet-info"> + <div v-if="retweet && !noHeading && !inConversation" :class="[repeaterClass, { highlighted: repeaterStyle }]" :style="[repeaterStyle]" class="media container retweet-info"> <UserAvatar class="media-left" v-if="retweet" :betterShadow="betterShadow" :src="statusoid.user.profile_image_url_original"/> <div class="media-body faint"> <span class="user-name"> @@ -24,7 +24,7 @@ </div> </div> - <div :class="[userClass, { highlighted: userStyle, 'is-retweet': retweet }]" :style="[ userStyle ]" class="media status"> + <div :class="[userClass, { highlighted: userStyle, 'is-retweet': retweet && !inConversation }]" :style="[ userStyle ]" class="media status"> <div v-if="!noHeading" class="media-left"> <router-link :to="userProfileLink" @click.stop.prevent.capture.native="toggleUserExpanded"> <UserAvatar :compact="compact" :betterShadow="betterShadow" :src="status.user.profile_image_url_original"/> @@ -98,16 +98,16 @@ </div> <div class="status-content-wrapper" :class="{ 'tall-status': !showingLongSubject }" v-if="longSubject"> - <a class="tall-status-hider" :class="{ 'tall-status-hider_focused': isFocused }" v-if="!showingLongSubject" href="#" @click.prevent="showingLongSubject=true">Show more</a> - <div @click.prevent="linkClicked" class="status-content media-body" v-html="status.statusnet_html"></div> - <a v-if="showingLongSubject" href="#" class="status-unhider" @click.prevent="showingLongSubject=false">Show less</a> + <a class="tall-status-hider" :class="{ 'tall-status-hider_focused': isFocused }" v-if="!showingLongSubject" href="#" @click.prevent="showingLongSubject=true">{{$t("general.show_more")}}</a> + <div @click.prevent="linkClicked" class="status-content media-body" v-html="contentHtml"></div> + <a v-if="showingLongSubject" href="#" class="status-unhider" @click.prevent="showingLongSubject=false">{{$t("general.show_less")}}</a> </div> <div :class="{'tall-status': hideTallStatus}" class="status-content-wrapper" v-else> - <a class="tall-status-hider" :class="{ 'tall-status-hider_focused': isFocused }" v-if="hideTallStatus" href="#" @click.prevent="toggleShowMore">Show more</a> - <div @click.prevent="linkClicked" class="status-content media-body" v-html="status.statusnet_html" v-if="!hideSubjectStatus"></div> + <a class="tall-status-hider" :class="{ 'tall-status-hider_focused': isFocused }" v-if="hideTallStatus" href="#" @click.prevent="toggleShowMore">{{$t("general.show_more")}}</a> + <div @click.prevent="linkClicked" class="status-content media-body" v-html="contentHtml" v-if="!hideSubjectStatus"></div> <div @click.prevent="linkClicked" class="status-content media-body" v-html="status.summary_html" v-else></div> - <a v-if="hideSubjectStatus" href="#" class="cw-status-hider" @click.prevent="toggleShowMore">Show more</a> - <a v-if="showingMore" href="#" class="status-unhider" @click.prevent="toggleShowMore">Show less</a> + <a v-if="hideSubjectStatus" href="#" class="cw-status-hider" @click.prevent="toggleShowMore">{{$t("general.show_more")}}</a> + <a v-if="showingMore" href="#" class="status-unhider" @click.prevent="toggleShowMore">{{$t("general.show_less")}}</a> </div> <div v-if="status.attachments && (!hideSubjectStatus || showingLongSubject)" class="attachments media-body"> @@ -135,9 +135,8 @@ <div v-if="!noHeading && !isPreview" class='status-actions media-body'> <div v-if="loggedIn"> - <a href="#" v-on:click.prevent="toggleReplying" :title="$t('tool_tip.reply')"> - <i class="button-icon icon-reply" :class="{'icon-reply-active': replying}"></i> - </a> + <i class="button-icon icon-reply" v-on:click.prevent="toggleReplying" :title="$t('tool_tip.reply')" :class="{'icon-reply-active': replying}"></i> + <span v-if="status.replies_count > 0">{{status.replies_count}}</span> </div> <retweet-button :visibility='status.visibility' :loggedIn='loggedIn' :status='status'></retweet-button> <favorite-button :loggedIn='loggedIn' :status='status'></favorite-button> @@ -551,6 +550,7 @@ $status-margin: 0.75em; .icon-reply:hover { color: $fallback--cBlue; color: var(--cBlue, $fallback--cBlue); + cursor: pointer; } .icon-reply.icon-reply-active { diff --git a/src/components/status_or_conversation/status_or_conversation.js b/src/components/status_or_conversation/status_or_conversation.js deleted file mode 100644 index 441552ca..00000000 --- a/src/components/status_or_conversation/status_or_conversation.js +++ /dev/null @@ -1,22 +0,0 @@ -import Status from '../status/status.vue' -import Conversation from '../conversation/conversation.vue' - -const statusOrConversation = { - props: ['statusoid'], - data () { - return { - expanded: false - } - }, - components: { - Status, - Conversation - }, - methods: { - toggleExpanded () { - this.expanded = !this.expanded - } - } -} - -export default statusOrConversation diff --git a/src/components/status_or_conversation/status_or_conversation.vue b/src/components/status_or_conversation/status_or_conversation.vue deleted file mode 100644 index 9647d5eb..00000000 --- a/src/components/status_or_conversation/status_or_conversation.vue +++ /dev/null @@ -1,14 +0,0 @@ -<template> - <div> - <conversation v-if="expanded" @toggleExpanded="toggleExpanded" :collapsable="true" :statusoid="statusoid"></conversation> - <status v-if="!expanded" @toggleExpanded="toggleExpanded" :expandable="true" :inConversation="false" :focused="false" :statusoid="statusoid"></status> - </div> -</template> - -<script src="./status_or_conversation.js"></script> - -<style lang="scss"> - .spacer { - height: 1em - } -</style> diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index c45f8947..1da7d5cc 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -1,6 +1,6 @@ import Status from '../status/status.vue' import timelineFetcher from '../../services/timeline_fetcher/timeline_fetcher.service.js' -import StatusOrConversation from '../status_or_conversation/status_or_conversation.vue' +import Conversation from '../conversation/conversation.vue' import { throttle } from 'lodash' const Timeline = { @@ -43,7 +43,7 @@ const Timeline = { }, components: { Status, - StatusOrConversation + Conversation }, created () { const store = this.$store diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue index 8f28d65c..e0a34bd1 100644 --- a/src/components/timeline/timeline.vue +++ b/src/components/timeline/timeline.vue @@ -16,7 +16,13 @@ </div> <div :class="classes.body"> <div class="timeline"> - <status-or-conversation v-for="status in timeline.visibleStatuses" :key="status.id" v-bind:statusoid="status" class="status-fadein"></status-or-conversation> + <conversation + v-for="status in timeline.visibleStatuses" + class="status-fadein" + :key="status.id" + :statusoid="status" + :collapsable="true" + /> </div> </div> <div :class="classes.footer"> diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 82df4510..1df06fe6 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -72,9 +72,6 @@ const UserProfile = { return this.$store.getters.findUser(this.fetchedUserId || routeParams.name || routeParams.id) }, user () { - if (this.timeline.statuses[0]) { - return this.timeline.statuses[0].user - } if (this.userInStore) { return this.userInStore } diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 72e7bb53..b6a0479d 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -4,9 +4,11 @@ import get from 'lodash/get' import TabSwitcher from '../tab_switcher/tab_switcher.js' import ImageCropper from '../image_cropper/image_cropper.vue' import StyleSwitcher from '../style_switcher/style_switcher.vue' +import ScopeSelector from '../scope_selector/scope_selector.vue' import fileSizeFormatService from '../../services/file_size_format/file_size_format.js' import BlockCard from '../block_card/block_card.vue' import MuteCard from '../mute_card/mute_card.vue' +import EmojiInput from '../emoji-input/emoji-input.vue' import withSubscription from '../../hocs/with_subscription/with_subscription' import withList from '../../hocs/with_list/with_list' @@ -66,10 +68,12 @@ const UserSettings = { }, components: { StyleSwitcher, + ScopeSelector, TabSwitcher, ImageCropper, BlockList, - MuteList + MuteList, + EmojiInput }, computed: { user () { @@ -78,8 +82,8 @@ const UserSettings = { pleromaBackend () { return this.$store.state.instance.pleromaBackend }, - scopeOptionsEnabled () { - return this.$store.state.instance.scopeOptionsEnabled + minimalScopesMode () { + return this.$store.state.instance.minimalScopesMode }, vis () { return { diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue index c9e68808..c08698dc 100644 --- a/src/components/user_settings/user_settings.vue +++ b/src/components/user_settings/user_settings.vue @@ -22,20 +22,29 @@ <div class="setting-item" > <h2>{{$t('settings.name_bio')}}</h2> <p>{{$t('settings.name')}}</p> - <input class='name-changer' id='username' v-model="newName"></input> + <EmojiInput + type="text" + v-model="newName" + id="username" + classname="name-changer" + /> <p>{{$t('settings.bio')}}</p> - <textarea class="bio" v-model="newBio"></textarea> + <EmojiInput + type="textarea" + v-model="newBio" + classname="bio" + /> <p> <input type="checkbox" v-model="newLocked" id="account-locked"> <label for="account-locked">{{$t('settings.lock_account_description')}}</label> </p> - <div v-if="scopeOptionsEnabled"> + <div> <label for="default-vis">{{$t('settings.default_vis')}}</label> <div id="default-vis" class="visibility-tray"> - <i v-on:click="changeVis('direct')" class="icon-mail-alt" :class="vis.direct" :title="$t('post_status.scope.direct')" ></i> - <i v-on:click="changeVis('private')" class="icon-lock" :class="vis.private" :title="$t('post_status.scope.private')"></i> - <i v-on:click="changeVis('unlisted')" class="icon-lock-open-alt" :class="vis.unlisted" :title="$t('post_status.scope.unlisted')"></i> - <i v-on:click="changeVis('public')" class="icon-globe" :class="vis.public" :title="$t('post_status.scope.public')"></i> + <scope-selector + :showAll="true" + :userDefault="newDefaultScope" + :onScopeChange="changeVis"/> </div> </div> <p> @@ -61,7 +70,7 @@ <h2>{{$t('settings.avatar')}}</h2> <p class="visibility-notice">{{$t('settings.avatar_size_instruction')}}</p> <p>{{$t('settings.current_avatar')}}</p> - <img :src="user.profile_image_url_original" class="current-avatar"></img> + <img :src="user.profile_image_url_original" class="current-avatar" /> <p>{{$t('settings.set_new_avatar')}}</p> <button class="btn" type="button" id="pick-avatar" v-show="pickAvatarBtnVisible">{{$t('settings.upload_a_photo')}}</button> <image-cropper trigger="#pick-avatar" :submitHandler="submitAvatar" @open="pickAvatarBtnVisible=false" @close="pickAvatarBtnVisible=true" /> @@ -69,12 +78,11 @@ <div class="setting-item"> <h2>{{$t('settings.profile_banner')}}</h2> <p>{{$t('settings.current_profile_banner')}}</p> - <img :src="user.cover_photo" class="banner"></img> + <img :src="user.cover_photo" class="banner" /> <p>{{$t('settings.set_new_profile_banner')}}</p> - <img class="banner" v-bind:src="bannerPreview" v-if="bannerPreview"> - </img> + <img class="banner" v-bind:src="bannerPreview" v-if="bannerPreview" /> <div> - <input type="file" @change="uploadFile('banner', $event)" ></input> + <input type="file" @change="uploadFile('banner', $event)" /> </div> <i class=" icon-spin4 animate-spin uploading" v-if="bannerUploading"></i> <button class="btn btn-default" v-else-if="bannerPreview" @click="submitBanner">{{$t('general.submit')}}</button> @@ -86,10 +94,9 @@ <div class="setting-item"> <h2>{{$t('settings.profile_background')}}</h2> <p>{{$t('settings.set_new_profile_background')}}</p> - <img class="bg" v-bind:src="backgroundPreview" v-if="backgroundPreview"> - </img> + <img class="bg" v-bind:src="backgroundPreview" v-if="backgroundPreview" /> <div> - <input type="file" @change="uploadFile('background', $event)" ></input> + <input type="file" @change="uploadFile('background', $event)" /> </div> <i class=" icon-spin4 animate-spin uploading" v-if="backgroundUploading"></i> <button class="btn btn-default" v-else-if="backgroundPreview" @click="submitBg">{{$t('general.submit')}}</button> @@ -165,7 +172,7 @@ <h2>{{$t('settings.follow_import')}}</h2> <p>{{$t('settings.import_followers_from_a_csv_file')}}</p> <form> - <input type="file" ref="followlist" v-on:change="followListChange"></input> + <input type="file" ref="followlist" v-on:change="followListChange" /> </form> <i class=" icon-spin4 animate-spin uploading" v-if="followListUploading"></i> <button class="btn btn-default" v-else @click="importFollows">{{$t('general.submit')}}</button> diff --git a/src/i18n/en.json b/src/i18n/en.json index c501c6a7..026546cc 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -20,7 +20,9 @@ "submit": "Submit", "more": "More", "generic_error": "An error occured", - "optional": "optional" + "optional": "optional", + "show_more": "Show more", + "show_less": "Show less" }, "image_cropper": { "crop_picture": "Crop picture", @@ -215,6 +217,7 @@ "saving_ok": "Settings saved", "security_tab": "Security", "scope_copy": "Copy scope when replying (DMs are always copied)", + "minimal_scopes_mode": "Minimize post scope selection options", "set_new_avatar": "Set new avatar", "set_new_profile_background": "Set new profile background", "set_new_profile_banner": "Set new profile banner", diff --git a/src/i18n/pl.json b/src/i18n/pl.json index 2e1d7488..8efce168 100644 --- a/src/i18n/pl.json +++ b/src/i18n/pl.json @@ -2,48 +2,114 @@ "chat": { "title": "Czat" }, + "features_panel": { + "chat": "Czat", + "gopher": "Gopher", + "media_proxy": "Proxy mediów", + "scope_options": "Ustawienia zakresu", + "text_limit": "Limit tekstu", + "title": "Funkcje", + "who_to_follow": "Propozycje obserwacji" + }, "finder": { "error_fetching_user": "Błąd przy pobieraniu profilu", "find_user": "Znajdź użytkownika" }, "general": { "apply": "Zastosuj", - "submit": "Wyślij" + "submit": "Wyślij", + "more": "Więcej", + "generic_error": "Wystąpił błąd", + "optional": "nieobowiązkowe" + }, + "image_cropper": { + "crop_picture": "Przytnij obrazek", + "save": "Zapisz", + "save_without_cropping": "Zapisz bez przycinania", + "cancel": "Anuluj" }, "login": { "login": "Zaloguj", + "description": "Zaloguj używając OAuth", "logout": "Wyloguj", "password": "Hasło", "placeholder": "n.p. lain", "register": "Zarejestruj", - "username": "Użytkownik" + "username": "Użytkownik", + "hint": "Zaloguj się, aby dołączyć do dyskusji" + }, + "media_modal": { + "previous": "Poprzednie", + "next": "Następne" }, "nav": { + "about": "O nas", + "back": "Wróć", "chat": "Lokalny czat", + "friend_requests": "Prośby o możliwość obserwacji", "mentions": "Wzmianki", + "dms": "Wiadomości prywatne", "public_tl": "Publiczna oś czasu", "timeline": "Oś czasu", - "twkn": "Cała znana sieć" + "twkn": "Cała znana sieć", + "user_search": "Wyszukiwanie użytkowników", + "who_to_follow": "Sugestie obserwacji", + "preferences": "Preferencje" }, "notifications": { - "favorited_you": "dodał twój status do ulubionych", + "broken_favorite": "Nieznany status, szukam go…", + "favorited_you": "dodał(-a) twój status do ulubionych", "followed_you": "obserwuje cię", + "load_older": "Załaduj starsze powiadomienia", "notifications": "Powiadomienia", "read": "Przeczytane!", - "repeated_you": "powtórzył twój status" + "repeated_you": "powtórzył(-a) twój status", + "no_more_notifications": "Nie masz więcej powiadomień" }, "post_status": { + "new_status": "Dodaj nowy status", + "account_not_locked_warning": "Twoje konto nie jest {0}. Każdy może cię zaobserwować aby zobaczyć wpisy tylko dla obserwujących.", + "account_not_locked_warning_link": "zablokowane", + "attachments_sensitive": "Oznacz załączniki jako wrażliwe", + "content_type": { + "text/plain": "Czysty tekst", + "text/html": "HTML", + "text/markdown": "Markdown" + }, + "content_warning": "Temat (nieobowiązkowy)", "default": "Właśnie wróciłem z kościoła", - "posting": "Wysyłanie" + "direct_warning": "Ten wpis zobaczą tylko osoby, o których wspomniałeś(-aś).", + "posting": "Wysyłanie", + "scope": { + "direct": "Bezpośredni – Tylko dla wspomnianych użytkowników", + "private": "Tylko dla obserwujących – Umieść dla osób, które cię obserwują", + "public": "Publiczny – Umieść na publicznych osiach czasu", + "unlisted": "Niewidoczny – Nie umieszczaj na publicznych osiach czasu" + } }, "registration": { "bio": "Bio", - "email": "Email", + "email": "E-mail", "fullname": "Wyświetlana nazwa profilu", "password_confirm": "Potwierdzenie hasła", - "registration": "Rejestracja" + "registration": "Rejestracja", + "token": "Token zaproszenia", + "captcha": "CAPTCHA", + "new_captcha": "Naciśnij na obrazek, aby dostać nowy kod captcha", + "username_placeholder": "np. lain", + "fullname_placeholder": "np. Lain Iwakura", + "bio_placeholder": "e.g.\nCześć, jestem Lain.\nJestem dziewczynką z anime żyjącą na peryferiach Japonii. Możesz znać mnie z Wired.", + "validations": { + "username_required": "nie może być pusta", + "fullname_required": "nie może być pusta", + "email_required": "nie może być pusty", + "password_required": "nie może być puste", + "password_confirmation_required": "nie może być puste", + "password_confirmation_match": "musi być takie jak hasło" + } }, "settings": { + "app_name": "Nazwa aplikacji", "attachmentRadius": "Załączniki", "attachments": "Załączniki", "autoload": "Włącz automatyczne ładowanie po przewinięciu do końca strony", @@ -52,6 +118,7 @@ "avatarRadius": "Awatary", "background": "Tło", "bio": "Bio", + "blocks_tab": "Bloki", "btnRadius": "Przyciski", "cBlue": "Niebieski (odpowiedz, obserwuj)", "cGreen": "Zielony (powtórzenia)", @@ -59,15 +126,21 @@ "cRed": "Czerwony (anuluj)", "change_password": "Zmień hasło", "change_password_error": "Podczas zmiany hasła wystąpił problem.", - "changed_password": "Hasło zmienione poprawnie!", + "changed_password": "Pomyślnie zmieniono hasło!", + "collapse_subject": "Zwijaj posty z tematami", + "composing": "Pisanie", "confirm_new_password": "Potwierdź nowe hasło", "current_avatar": "Twój obecny awatar", "current_password": "Obecne hasło", "current_profile_banner": "Twój obecny banner profilu", + "data_import_export_tab": "Import/eksport danych", + "default_vis": "Domyślny zakres widoczności", "delete_account": "Usuń konto", "delete_account_description": "Trwale usuń konto i wszystkie posty.", "delete_account_error": "Wystąpił problem z usuwaniem twojego konta. Jeżeli problem powtarza się, poinformuj administratora swojej instancji.", "delete_account_instructions": "Wprowadź swoje hasło w poniższe pole aby potwierdzić usunięcie konta.", + "avatar_size_instruction": "Zalecany minimalny rozmiar awatarów to 150x150 pikseli.", + "export_theme": "Zapisz motyw", "filtering": "Filtrowanie", "filtering_explanation": "Wszystkie statusy zawierające te słowa będą wyciszone. Jedno słowo na linijkę.", "follow_export": "Eksport obserwowanych", @@ -77,14 +150,49 @@ "follow_import_error": "Błąd przy importowaniu obserwowanych", "follows_imported": "Obserwowani zaimportowani! Przetwarzanie może trochę potrwać.", "foreground": "Pierwszy plan", - "hide_attachments_in_convo": "Ukryj załączniki w rozmowach", - "hide_attachments_in_tl": "Ukryj załączniki w osi czasu", + "general": "Ogólne", + "hide_attachments_in_convo": "Ukrywaj załączniki w rozmowach", + "hide_attachments_in_tl": "Ukrywaj załączniki w osi czasu", + "hide_muted_posts": "Ukrywaj wpisy wyciszonych użytkowników", + "max_thumbnails": "Maksymalna liczba miniatur w poście", + "hide_isp": "Ukryj panel informacji o instancji", + "preload_images": "Ładuj wstępnie obrazy", + "use_one_click_nsfw": "Otwieraj załączniki NSFW jednym kliknięciem", + "hide_post_stats": "Ukrywaj statysyki postów (np. liczbę polubień)", + "hide_user_stats": "Ukrywaj statysyki użytkowników (np. liczbę obserwujących)", + "hide_filtered_statuses": "Ukrywaj filtrowane statusy", "import_followers_from_a_csv_file": "Importuj obserwowanych z pliku CSV", + "import_theme": "Załaduj motyw", "inputRadius": "Pola tekstowe", + "checkboxRadius": "Pola wyboru", + "instance_default": "(domyślny: {value})", + "instance_default_simple": "(domyślny)", + "interface": "Interfejs", + "interfaceLanguage": "Język interfejsu", + "invalid_theme_imported": "Wybrany plik nie jest obsługiwanym motywem Pleromy. Nie dokonano zmian w twoim motywie.", + "limited_availability": "Niedostępne w twojej przeglądarce", "links": "Łącza", + "lock_account_description": "Ogranicz swoje konto dla zatwierdzonych obserwowanych", + "loop_video": "Zapętlaj filmy", + "loop_video_silent_only": "Zapętlaj tylko filmy bez dźwięku (np. mastodonowe „gify”)", + "mutes_tab": "Wyciszenia", + "play_videos_in_modal": "Odtwarzaj filmy bezpośrednio w przeglądarce mediów", + "use_contain_fit": "Nie przycinaj załączników na miniaturach", "name": "Imię", "name_bio": "Imię i bio", "new_password": "Nowe hasło", + "notification_visibility": "Rodzaje powiadomień do wyświetlania", + "notification_visibility_follows": "Obserwacje", + "notification_visibility_likes": "Ulubione", + "notification_visibility_mentions": "Wzmianki", + "notification_visibility_repeats": "Powtórzenia", + "no_rich_text_description": "Usuwaj formatowanie ze wszystkich postów", + "no_blocks": "Bez blokad", + "no_mutes": "Bez wyciszeń", + "hide_follows_description": "Nie pokazuj kogo obserwuję", + "hide_followers_description": "Nie pokazuj kto mnie obserwuje", + "show_admin_badge": "Pokazuj odznakę Administrator na moim profilu", + "show_moderator_badge": "Pokazuj odznakę Moderator na moim profilu", "nsfw_clickthrough": "Włącz domyślne ukrywanie załączników o treści nieprzyzwoitej (NSFW)", "oauth_tokens": "Tokeny OAuth", "token": "Token", @@ -92,47 +200,235 @@ "valid_until": "Ważne do", "revoke_token": "Odwołać", "panelRadius": "Panele", + "pause_on_unfocused": "Wstrzymuj strumieniowanie kiedy karta nie jest aktywna", "presets": "Gotowe motywy", "profile_background": "Tło profilu", "profile_banner": "Banner profilu", + "profile_tab": "Profil", "radii_help": "Ustaw zaokrąglenie krawędzi interfejsu (w pikselach)", + "replies_in_timeline": "Odpowiedzi na osi czasu", "reply_link_preview": "Włącz dymek z podglądem postu po najechaniu na znak odpowiedzi", + "reply_visibility_all": "Pokazuj wszystkie odpowiedzi", + "reply_visibility_following": "Pokazuj tylko odpowiedzi skierowane do mnie i osób które obserwuję", + "reply_visibility_self": "Pokazuj tylko odpowiedzi skierowane do mnie", + "saving_err": "Nie udało się zapisać ustawień", + "saving_ok": "Zapisano ustawienia", + "security_tab": "Bezpieczeństwo", + "scope_copy": "Kopiuj zakres podczas odpowiadania (DM-y zawsze są kopiowane)", "set_new_avatar": "Ustaw nowy awatar", "set_new_profile_background": "Ustaw nowe tło profilu", "set_new_profile_banner": "Ustaw nowy banner profilu", "settings": "Ustawienia", + "subject_input_always_show": "Zawsze pokazuj pole tematu", + "subject_line_behavior": "Kopiuj temat podczas odpowiedzi", + "subject_line_email": "Jak w mailach – „re: temat”", + "subject_line_mastodon": "Jak na Mastodonie – po prostu kopiuj", + "subject_line_noop": "Nie kopiuj", + "post_status_content_type": "Post status content type", "stop_gifs": "Odtwarzaj GIFy po najechaniu kursorem", - "streaming": "Włącz automatycznie strumieniowanie nowych postów gdy na początku strony", + "streaming": "Włącz automatycznie strumieniowanie nowych postów gdy jesteś na początku strony", "text": "Tekst", "theme": "Motyw", "theme_help": "Użyj kolorów w notacji szesnastkowej (#rrggbb), by stworzyć swój motyw.", + "theme_help_v2_1": "Możesz też zastąpić kolory i widoczność poszczególnych komponentów przełączając pola wyboru, użyj „Wyczyść wszystko” aby usunąć wszystkie zastąpienia.", + "theme_help_v2_2": "Ikony pod niektórych wpisami są wskaźnikami kontrastu pomiędzy tłem a tekstem, po najechaniu na nie otrzymasz szczegółowe informacje. Zapamiętaj, że jeżeli używasz przezroczystości, wskaźniki pokazują najgorszy możliwy przypadek.", "tooltipRadius": "Etykiety/alerty", - "user_settings": "Ustawienia użytkownika" + "upload_a_photo": "Wyślij zdjęcie", + "user_settings": "Ustawienia użytkownika", + "values": { + "false": "nie", + "true": "tak" + }, + "notifications": "Powiadomienia", + "enable_web_push_notifications": "Włącz powiadomienia push", + "style": { + "switcher": { + "keep_color": "Zachowaj kolory", + "keep_shadows": "Zachowaj cienie", + "keep_opacity": "Zachowaj widoczność", + "keep_roundness": "Zachowaj zaokrąglenie", + "keep_fonts": "Zachowaj czcionki", + "save_load_hint": "Opcje „zachowaj” pozwalają na pozostanie przy obecnych opcjach po wybraniu lub załadowaniu motywu, jak i przechowywanie ich podczas eksportowania motywu. Jeżeli wszystkie są odznaczone, eksportowanie motywu spowoduje zapisanie wszystkiego.", + "reset": "Wyzeruj", + "clear_all": "Wyczyść wszystko", + "clear_opacity": "Wyczyść widoczność" + }, + "common": { + "color": "Kolor", + "opacity": "Widoczność", + "contrast": { + "hint": "Współczynnik kontrastu wynosi {ratio}, {level} {context}", + "level": { + "aa": "spełnia wymogi poziomu AA (minimalne)", + "aaa": "spełnia wymogi poziomu AAA (zalecane)", + "bad": "nie spełnia żadnych wymogów dostępności" + }, + "context": { + "18pt": "dla dużego tekstu (18pt+)", + "text": "dla tekstu" + } + } + }, + "common_colors": { + "_tab_label": "Ogólne", + "main": "Ogólne kolory", + "foreground_hint": "Zajrzyj do karty „Zaawansowane”, aby uzyskać dokładniejszą kontrolę", + "rgbo": "Ikony, wyróżnienia, odznaki" + }, + "advanced_colors": { + "_tab_label": "Zaawansowane", + "alert": "Tło alertu", + "alert_error": "Błąd", + "badge": "Tło odznaki", + "badge_notification": "Powiadomienie", + "panel_header": "Nagłówek panelu", + "top_bar": "Górny pasek", + "borders": "Granice", + "buttons": "Przyciski", + "inputs": "Pola wejścia", + "faint_text": "Zanikający tekst" + }, + "radii": { + "_tab_label": "Zaokrąglenie" + }, + "shadows": { + "_tab_label": "Cień i podświetlenie", + "component": "Komponent", + "override": "Zastąp", + "shadow_id": "Cień #{value}", + "blur": "Rozmycie", + "spread": "Szerokość", + "inset": "Inset", + "hint": "Możesz też używać --zmiennych jako kolorów, aby wykorzystać zmienne CSS3. Pamiętaj, że ustawienie widoczności nie będzie wtedy działać.", + "filter_hint": { + "always_drop_shadow": "Ostrzeżenie, ten cień zawsze używa {0} jeżeli to obsługiwane przez przeglądarkę.", + "drop_shadow_syntax": "{0} nie obsługuje parametru {1} i słowa kluczowego {2}.", + "avatar_inset": "Pamiętaj że użycie jednocześnie cieni inset i nie inset na awatarach może daćnieoczekiwane wyniki z przezroczystymi awatarami.", + "spread_zero": "Cienie o ujemnej szerokości będą widoczne tak, jakby wynosiła ona zero", + "inset_classic": "Cienie inset będą używały {0}" + }, + "components": { + "panel": "Panel", + "panelHeader": "Nagłówek panelu", + "topBar": "Górny pasek", + "avatar": "Awatar użytkownika (w widoku profilu)", + "avatarStatus": "Awatar użytkownika (w widoku wpisu)", + "popup": "Wyskakujące okna i podpowiedzi", + "button": "Przycisk", + "buttonHover": "Przycisk (po najechaniu)", + "buttonPressed": "Przycisk (naciśnięty)", + "buttonPressedHover": "Przycisk(naciśnięty+najechany)", + "input": "Pole wejścia" + } + }, + "fonts": { + "_tab_label": "Czcionki", + "help": "Wybierz czcionkę używaną przez elementy UI. Jeżeli wybierzesz niestandardową, musisz wpisać dokładnie tę nazwę, pod którą pojawia się w systemie.", + "components": { + "interface": "Interfejs", + "input": "Pola wejścia", + "post": "Tekst postu", + "postCode": "Tekst o stałej szerokości znaków w sformatowanym poście" + }, + "family": "Nazwa czcionki", + "size": "Rozmiar (w pikselach)", + "weight": "Grubość", + "custom": "Niestandardowa" + }, + "preview": { + "header": "Podgląd", + "content": "Zawartość", + "error": "Przykładowy błąd", + "button": "Przycisk", + "text": "Trochę więcej {0} i {1}", + "mono": "treści", + "input": "Właśnie wróciłem z kościoła", + "faint_link": "pomocny podręcznik", + "fine_print": "Przeczytaj nasz {0}, aby nie nauczyć się niczego przydatnego!", + "header_faint": "W porządku", + "checkbox": "Przeleciałem przez zasady użytkowania", + "link": "i fajny mały odnośnik" + } + }, + "version": { + "title": "Wersja", + "backend_version": "Wersja back-endu", + "frontend_version": "Wersja front-endu" + } }, "timeline": { "collapse": "Zwiń", "conversation": "Rozmowa", "error_fetching": "Błąd pobierania", "load_older": "Załaduj starsze statusy", + "no_retweet_hint": "Wpis oznaczony jako tylko dla obserwujących lub bezpośredni nie może zostać powtórzony", "repeated": "powtórzono", "show_new": "Pokaż nowe", - "up_to_date": "Na bieżąco" + "up_to_date": "Na bieżąco", + "no_more_statuses": "Brak kolejnych statusów", + "no_statuses": "Brak statusów" + }, + "status": { + "reply_to": "Odpowiedź dla", + "replies_list": "Odpowiedzi:" }, "user_card": { + "approve": "Przyjmij", "block": "Zablokuj", "blocked": "Zablokowany!", + "deny": "Odrzuć", + "favorites": "Ulubione", "follow": "Obserwuj", + "follow_sent": "Wysłano prośbę!", + "follow_progress": "Wysyłam prośbę…", + "follow_again": "Wysłać prośbę ponownie?", + "follow_unfollow": "Przestań obserwować", "followees": "Obserwowani", "followers": "Obserwujący", "following": "Obserwowany!", "follows_you": "Obserwuje cię!", + "its_you": "To ty!", + "media": "Media", "mute": "Wycisz", - "muted": "Wyciszony", + "muted": "Wyciszony(-a)", "per_day": "dziennie", "remote_follow": "Zdalna obserwacja", - "statuses": "Statusy" + "statuses": "Statusy", + "unblock": "Odblokuj", + "unblock_progress": "Odblokowuję…", + "block_progress": "Blokuję…", + "unmute": "Cofnij wyciszenie", + "unmute_progress": "Cofam wyciszenie…", + "mute_progress": "Wyciszam…" }, "user_profile": { - "timeline_title": "Oś czasu użytkownika" + "timeline_title": "Oś czasu użytkownika", + "profile_does_not_exist": "Przepraszamy, ten profil nie istnieje.", + "profile_loading_error": "Przepraszamy, wystąpił błąd podczas ładowania tego profilu." + }, + "who_to_follow": { + "more": "Więcej", + "who_to_follow": "Propozycje obserwacji" + }, + "tool_tip": { + "media_upload": "Wyślij media", + "repeat": "Powtórz", + "reply": "Odpowiedz", + "favorite": "Dodaj do ulubionych", + "user_settings": "Ustawienia użytkownika" + }, + "upload":{ + "error": { + "base": "Wysyłanie nie powiodło się.", + "file_too_big": "Zbyt duży plik [{filesize}{filesizeunit} / {allowedsize}{allowedsizeunit}]", + "default": "Spróbuj ponownie później" + }, + "file_size_units": { + "B": "B", + "KiB": "KiB", + "MiB": "MiB", + "GiB": "GiB", + "TiB": "TiB" + } } -} +}
\ No newline at end of file diff --git a/src/i18n/ru.json b/src/i18n/ru.json index 6799cc96..89aa43f4 100644 --- a/src/i18n/ru.json +++ b/src/i18n/ru.json @@ -111,6 +111,8 @@ "import_theme": "Загрузить Тему", "inputRadius": "Поля ввода", "checkboxRadius": "Чекбоксы", + "instance_default": "(по умолчанию: {value})", + "instance_default_simple": "(по умолчанию)", "interface": "Интерфейс", "interfaceLanguage": "Язык интерфейса", "limited_availability": "Не доступно в вашем браузере", @@ -149,7 +151,11 @@ "reply_visibility_all": "Показывать все ответы", "reply_visibility_following": "Показывать только ответы мне и тех на кого я подписан", "reply_visibility_self": "Показывать только ответы мне", + "saving_err": "Не удалось сохранить настройки", + "saving_ok": "Сохранено", "security_tab": "Безопасность", + "scope_copy": "Копировать видимость поста при ответе (всегда включено для Личных Сообщений)", + "minimal_scopes_mode": "Минимизировать набор опций видимости поста", "set_new_avatar": "Загрузить новый аватар", "set_new_profile_background": "Загрузить новый фон профиля", "set_new_profile_banner": "Загрузить новый баннер профиля", @@ -164,6 +170,10 @@ "theme_help_v2_2": "Под некоторыми полями ввода это идикаторы контрастности, наведите на них мышью чтобы узнать больше. Приспользовании прозрачности контраст расчитывается для наихудшего варианта.", "tooltipRadius": "Всплывающие подсказки/уведомления", "user_settings": "Настройки пользователя", + "values": { + "false": "нет", + "true": "да" + }, "style": { "switcher": { "keep_color": "Оставить цвета", diff --git a/src/modules/config.js b/src/modules/config.js index c5491c01..1666a2c5 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -33,7 +33,8 @@ const defaultState = { scopeCopy: undefined, // instance default subjectLineBehavior: undefined, // instance default alwaysShowSubjectInput: undefined, // instance default - postContentType: undefined // instance default + postContentType: undefined, // instance default + minimalScopesMode: undefined // instance default } const config = { diff --git a/src/modules/instance.js b/src/modules/instance.js index f778ac4d..3a559ba0 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -15,7 +15,6 @@ const defaultState = { redirectRootNoLogin: '/main/all', redirectRootLogin: '/main/friends', showInstanceSpecificPanel: false, - scopeOptionsEnabled: true, formattingOptionsEnabled: false, alwaysShowSubjectInput: true, hideMutedPosts: false, @@ -32,6 +31,7 @@ const defaultState = { vapidPublicKey: undefined, noAttachmentLinks: false, showFeaturesPanel: true, + minimalScopesMode: false, // Nasty stuff pleromaBackend: true, diff --git a/src/modules/statuses.js b/src/modules/statuses.js index a16342e0..8e0203e3 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -123,7 +123,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us const maxNew = statuses.length > 0 ? maxBy(statuses, 'id').id : 0 const minNew = statuses.length > 0 ? minBy(statuses, 'id').id : 0 - const newer = timeline && maxNew > timelineObject.maxId && statuses.length > 0 + const newer = timeline && (maxNew > timelineObject.maxId || timelineObject.maxId === 0) && statuses.length > 0 const older = timeline && (minNew < timelineObject.minId || timelineObject.minId === 0) && statuses.length > 0 if (!noIdUpdate && newer) { @@ -363,6 +363,15 @@ export const mutations = { }, setRetweeted (state, { status, value }) { const newStatus = state.allStatusesObject[status.id] + + if (newStatus.repeated !== value) { + if (value) { + newStatus.repeat_num++ + } else { + newStatus.repeat_num-- + } + } + newStatus.repeated = value }, setDeleted (state, { status }) { @@ -433,13 +442,6 @@ const statuses = { // Optimistic favoriting... commit('setFavorited', { status, value: true }) apiService.favorite({ id: status.id, credentials: rootState.users.currentUser.credentials }) - .then(response => { - if (response.ok) { - return response.json() - } else { - return {} - } - }) .then(status => { commit('setFavoritedConfirm', { status }) }) @@ -448,13 +450,6 @@ const statuses = { // Optimistic favoriting... commit('setFavorited', { status, value: false }) apiService.unfavorite({ id: status.id, credentials: rootState.users.currentUser.credentials }) - .then(response => { - if (response.ok) { - return response.json() - } else { - return {} - } - }) .then(status => { commit('setFavoritedConfirm', { status }) }) diff --git a/src/modules/users.js b/src/modules/users.js index 5cfa128e..1a507d31 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -1,5 +1,5 @@ import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js' -import { compact, map, each, merge, find } from 'lodash' +import { compact, map, each, merge, find, last } from 'lodash' import { set } from 'vue' import { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js' import oauthApi from '../services/new_api/oauth' @@ -52,23 +52,23 @@ export const mutations = { state.loggingIn = false }, // TODO Clean after ourselves? - addFriends (state, { id, friends, page }) { + addFriends (state, { id, friends }) { const user = state.usersObject[id] each(friends, friend => { if (!find(user.friends, { id: friend.id })) { user.friends.push(friend) } }) - user.friendsPage = page + 1 + user.lastFriendId = last(friends).id }, - addFollowers (state, { id, followers, page }) { + addFollowers (state, { id, followers }) { const user = state.usersObject[id] each(followers, follower => { if (!find(user.followers, { id: follower.id })) { user.followers.push(follower) } }) - user.followersPage = page + 1 + user.lastFollowerId = last(followers).id }, // Because frontend doesn't have a reason to keep these stuff in memory // outside of viewing someones user profile. @@ -78,7 +78,7 @@ export const mutations = { return } user.friends = [] - user.friendsPage = 0 + user.lastFriendId = null }, clearFollowers (state, userId) { const user = state.usersObject[userId] @@ -86,7 +86,7 @@ export const mutations = { return } user.followers = [] - user.followersPage = 0 + user.lastFollowerId = null }, addNewUsers (state, users) { each(users, (user) => mergeOrAdd(state.users, state.usersObject, user)) @@ -219,10 +219,10 @@ const users = { addFriends ({ rootState, commit }, fetchBy) { return new Promise((resolve, reject) => { const user = rootState.users.usersObject[fetchBy] - const page = user.friendsPage || 1 - rootState.api.backendInteractor.fetchFriends({ id: user.id, page }) + const maxId = user.lastFriendId + rootState.api.backendInteractor.fetchFriends({ id: user.id, maxId }) .then((friends) => { - commit('addFriends', { id: user.id, friends, page }) + commit('addFriends', { id: user.id, friends }) resolve(friends) }).catch(() => { reject() @@ -231,10 +231,10 @@ const users = { }, addFollowers ({ rootState, commit }, fetchBy) { const user = rootState.users.usersObject[fetchBy] - const page = user.followersPage || 1 - return rootState.api.backendInteractor.fetchFollowers({ id: user.id, page }) + const maxId = user.lastFollowerId + return rootState.api.backendInteractor.fetchFollowers({ id: user.id, maxId }) .then((followers) => { - commit('addFollowers', { id: user.id, followers, page }) + commit('addFollowers', { id: user.id, followers }) return followers }) }, diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 8d7f9e5d..030c2f5e 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -1,19 +1,7 @@ /* eslint-env browser */ const LOGIN_URL = '/api/account/verify_credentials.json' -const FRIENDS_TIMELINE_URL = '/api/statuses/friends_timeline.json' const ALL_FOLLOWING_URL = '/api/qvitter/allfollowing' -const TAG_TIMELINE_URL = '/api/statusnet/tags/timeline' -const FAVORITE_URL = '/api/favorites/create' -const UNFAVORITE_URL = '/api/favorites/destroy' -const RETWEET_URL = '/api/statuses/retweet' -const UNRETWEET_URL = '/api/statuses/unretweet' -const STATUS_DELETE_URL = '/api/statuses/destroy' const MENTIONS_URL = '/api/statuses/mentions.json' -const DM_TIMELINE_URL = '/api/statuses/dm_timeline.json' -const FOLLOWERS_URL = '/api/statuses/followers.json' -const FRIENDS_URL = '/api/statuses/friends.json' -const FOLLOWING_URL = '/api/friendships/create.json' -const UNFOLLOWING_URL = '/api/friendships/destroy.json' const REGISTRATION_URL = '/api/account/register.json' const AVATAR_UPDATE_URL = '/api/qvitter/update_avatar.json' const BG_UPDATE_URL = '/api/qvitter/update_background_image.json' @@ -31,12 +19,24 @@ const DENY_USER_URL = '/api/pleroma/friendships/deny' const SUGGESTIONS_URL = '/api/v1/suggestions' const MASTODON_USER_FAVORITES_TIMELINE_URL = '/api/v1/favourites' +const MASTODON_FAVORITE_URL = id => `/api/v1/statuses/${id}/favourite` +const MASTODON_UNFAVORITE_URL = id => `/api/v1/statuses/${id}/unfavourite` +const MASTODON_RETWEET_URL = id => `/api/v1/statuses/${id}/reblog` +const MASTODON_UNRETWEET_URL = id => `/api/v1/statuses/${id}/unreblog` +const MASTODON_DELETE_URL = id => `/api/v1/statuses/${id}` +const MASTODON_FOLLOW_URL = id => `/api/v1/accounts/${id}/follow` +const MASTODON_UNFOLLOW_URL = id => `/api/v1/accounts/${id}/unfollow` +const MASTODON_FOLLOWING_URL = id => `/api/v1/accounts/${id}/following` +const MASTODON_FOLLOWERS_URL = id => `/api/v1/accounts/${id}/followers` +const MASTODON_DIRECT_MESSAGES_TIMELINE_URL = '/api/v1/timelines/direct' const MASTODON_PUBLIC_TIMELINE = '/api/v1/timelines/public' +const MASTODON_USER_HOME_TIMELINE_URL = '/api/v1/timelines/home' const MASTODON_STATUS_URL = id => `/api/v1/statuses/${id}` const MASTODON_STATUS_CONTEXT_URL = id => `/api/v1/statuses/${id}/context` const MASTODON_USER_URL = '/api/v1/accounts' const MASTODON_USER_RELATIONSHIPS_URL = '/api/v1/accounts/relationships' const MASTODON_USER_TIMELINE_URL = id => `/api/v1/accounts/${id}/statuses` +const MASTODON_TAG_TIMELINE_URL = tag => `/api/v1/timelines/tag/${tag}` const MASTODON_USER_BLOCKS_URL = '/api/v1/blocks/' const MASTODON_USER_MUTES_URL = '/api/v1/mutes/' const MASTODON_BLOCK_USER_URL = id => `/api/v1/accounts/${id}/block` @@ -210,7 +210,7 @@ const externalProfile = ({profileUrl, credentials}) => { } const followUser = ({id, credentials}) => { - let url = `${FOLLOWING_URL}?user_id=${id}` + let url = MASTODON_FOLLOW_URL(id) return fetch(url, { headers: authHeaders(credentials), method: 'POST' @@ -218,7 +218,7 @@ const followUser = ({id, credentials}) => { } const unfollowUser = ({id, credentials}) => { - let url = `${UNFOLLOWING_URL}?user_id=${id}` + let url = MASTODON_UNFOLLOW_URL(id) return fetch(url, { headers: authHeaders(credentials), method: 'POST' @@ -275,28 +275,36 @@ const fetchUserRelationship = ({id, credentials}) => { }) } -const fetchFriends = ({id, page, credentials}) => { - let url = `${FRIENDS_URL}?user_id=${id}` - if (page) { - url = url + `&page=${page}` - } +const fetchFriends = ({id, maxId, sinceId, limit = 20, credentials}) => { + let url = MASTODON_FOLLOWING_URL(id) + const args = [ + maxId && `max_id=${maxId}`, + sinceId && `since_id=${sinceId}`, + limit && `limit=${limit}` + ].filter(_ => _).join('&') + + url = url + (args ? '?' + args : '') return fetch(url, { headers: authHeaders(credentials) }) .then((data) => data.json()) .then((data) => data.map(parseUser)) } const exportFriends = ({id, credentials}) => { - let url = `${FRIENDS_URL}?user_id=${id}&all=true` + let url = MASTODON_FOLLOWING_URL(id) + `?all=true` return fetch(url, { headers: authHeaders(credentials) }) .then((data) => data.json()) .then((data) => data.map(parseUser)) } -const fetchFollowers = ({id, page, credentials}) => { - let url = `${FOLLOWERS_URL}?user_id=${id}` - if (page) { - url = url + `&page=${page}` - } +const fetchFollowers = ({id, maxId, sinceId, limit = 20, credentials}) => { + let url = MASTODON_FOLLOWERS_URL(id) + const args = [ + maxId && `max_id=${maxId}`, + sinceId && `since_id=${sinceId}`, + limit && `limit=${limit}` + ].filter(_ => _).join('&') + + url += args ? '?' + args : '' return fetch(url, { headers: authHeaders(credentials) }) .then((data) => data.json()) .then((data) => data.map(parseUser)) @@ -347,15 +355,15 @@ const fetchStatus = ({id, credentials}) => { const fetchTimeline = ({timeline, credentials, since = false, until = false, userId = false, tag = false, withMuted = false}) => { const timelineUrls = { public: MASTODON_PUBLIC_TIMELINE, - friends: FRIENDS_TIMELINE_URL, + friends: MASTODON_USER_HOME_TIMELINE_URL, mentions: MENTIONS_URL, - dms: DM_TIMELINE_URL, + dms: MASTODON_DIRECT_MESSAGES_TIMELINE_URL, notifications: QVITTER_USER_NOTIFICATIONS_URL, 'publicAndExternal': MASTODON_PUBLIC_TIMELINE, user: MASTODON_USER_TIMELINE_URL, media: MASTODON_USER_TIMELINE_URL, favorites: MASTODON_USER_FAVORITES_TIMELINE_URL, - tag: TAG_TIMELINE_URL + tag: MASTODON_TAG_TIMELINE_URL } const isNotifications = timeline === 'notifications' const params = [] @@ -373,7 +381,7 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false, use params.push(['max_id', until]) } if (tag) { - url += `/${tag}.json` + url = url(tag) } if (timeline === 'media') { params.push(['only_media', 1]) @@ -420,31 +428,63 @@ const verifyCredentials = (user) => { } const favorite = ({ id, credentials }) => { - return fetch(`${FAVORITE_URL}/${id}.json`, { + return fetch(MASTODON_FAVORITE_URL(id), { headers: authHeaders(credentials), method: 'POST' }) + .then(response => { + if (response.ok) { + return response.json() + } else { + throw new Error('Error favoriting post') + } + }) + .then((data) => parseStatus(data)) } const unfavorite = ({ id, credentials }) => { - return fetch(`${UNFAVORITE_URL}/${id}.json`, { + return fetch(MASTODON_UNFAVORITE_URL(id), { headers: authHeaders(credentials), method: 'POST' }) + .then(response => { + if (response.ok) { + return response.json() + } else { + throw new Error('Error removing favorite') + } + }) + .then((data) => parseStatus(data)) } const retweet = ({ id, credentials }) => { - return fetch(`${RETWEET_URL}/${id}.json`, { + return fetch(MASTODON_RETWEET_URL(id), { headers: authHeaders(credentials), method: 'POST' }) + .then(response => { + if (response.ok) { + return response.json() + } else { + throw new Error('Error repeating post') + } + }) + .then((data) => parseStatus(data)) } const unretweet = ({ id, credentials }) => { - return fetch(`${UNRETWEET_URL}/${id}.json`, { + return fetch(MASTODON_UNRETWEET_URL(id), { headers: authHeaders(credentials), method: 'POST' }) + .then(response => { + if (response.ok) { + return response.json() + } else { + throw new Error('Error removing repeat') + } + }) + .then((data) => parseStatus(data)) } const postStatus = ({credentials, status, spoilerText, visibility, sensitive, mediaIds = [], inReplyToStatusId, contentType}) => { @@ -481,9 +521,9 @@ const postStatus = ({credentials, status, spoilerText, visibility, sensitive, me } const deleteStatus = ({ id, credentials }) => { - return fetch(`${STATUS_DELETE_URL}/${id}.json`, { + return fetch(MASTODON_DELETE_URL(id), { headers: authHeaders(credentials), - method: 'POST' + method: 'DELETE' }) } diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index 0f0bcddc..71e78d2f 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -10,16 +10,16 @@ const backendInteractorService = (credentials) => { return apiService.fetchConversation({id, credentials}) } - const fetchFriends = ({id, page}) => { - return apiService.fetchFriends({id, page, credentials}) + const fetchFriends = ({id, maxId, sinceId, limit}) => { + return apiService.fetchFriends({id, maxId, sinceId, limit, credentials}) } const exportFriends = ({id}) => { return apiService.exportFriends({id, credentials}) } - const fetchFollowers = ({id, page}) => { - return apiService.fetchFollowers({id, page, credentials}) + const fetchFollowers = ({id, maxId, sinceId, limit}) => { + return apiService.fetchFollowers({id, maxId, sinceId, limit, credentials}) } const fetchAllFollowing = ({username}) => { diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 5cac3463..ea57e6b2 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -177,6 +177,7 @@ export const parseStatus = (data) => { output.in_reply_to_status_id = data.in_reply_to_id output.in_reply_to_user_id = data.in_reply_to_account_id + output.replies_count = data.replies_count // Missing!! fix in UI? // output.in_reply_to_screen_name = ??? diff --git a/src/services/follow_manipulate/follow_manipulate.js b/src/services/follow_manipulate/follow_manipulate.js index 1e9bd679..51dafe84 100644 --- a/src/services/follow_manipulate/follow_manipulate.js +++ b/src/services/follow_manipulate/follow_manipulate.js @@ -19,7 +19,7 @@ const fetchUser = (attempt, user, store) => new Promise((resolve, reject) => { export const requestFollow = (user, store) => new Promise((resolve, reject) => { store.state.api.backendInteractor.followUser(user.id) .then((updated) => { - store.commit('addNewUsers', [updated]) + store.commit('updateUserRelationship', [updated]) // For locked users we just mark it that we sent the follow request if (updated.locked) { @@ -66,7 +66,7 @@ export const requestFollow = (user, store) => new Promise((resolve, reject) => { export const requestUnfollow = (user, store) => new Promise((resolve, reject) => { store.state.api.backendInteractor.unfollowUser(user.id) .then((updated) => { - store.commit('addNewUsers', [updated]) + store.commit('updateUserRelationship', [updated]) resolve({ updated }) diff --git a/src/services/gesture_service/gesture_service.js b/src/services/gesture_service/gesture_service.js new file mode 100644 index 00000000..88a328f3 --- /dev/null +++ b/src/services/gesture_service/gesture_service.js @@ -0,0 +1,74 @@ + +const DIRECTION_LEFT = [-1, 0] +const DIRECTION_RIGHT = [1, 0] +const DIRECTION_UP = [0, -1] +const DIRECTION_DOWN = [0, 1] + +const deltaCoord = (oldCoord, newCoord) => [newCoord[0] - oldCoord[0], newCoord[1] - oldCoord[1]] + +const touchEventCoord = e => ([e.touches[0].screenX, e.touches[0].screenY]) + +const vectorLength = v => Math.sqrt(v[0] * v[0] + v[1] * v[1]) + +const perpendicular = v => [v[1], -v[0]] + +const dotProduct = (v1, v2) => v1[0] * v2[0] + v1[1] * v2[1] + +const project = (v1, v2) => { + const scalar = (dotProduct(v1, v2) / dotProduct(v2, v2)) + return [scalar * v2[0], scalar * v2[1]] +} + +// direction: either use the constants above or an arbitrary 2d vector. +// threshold: how many Px to move from touch origin before checking if the +// callback should be called. +// divergentTolerance: a scalar for much of divergent direction we tolerate when +// above threshold. for example, with 1.0 we only call the callback if +// divergent component of delta is < 1.0 * direction component of delta. +const swipeGesture = (direction, onSwipe, threshold = 30, perpendicularTolerance = 1.0) => { + return { + direction, + onSwipe, + threshold, + perpendicularTolerance, + _startPos: [0, 0], + _swiping: false + } +} + +const beginSwipe = (event, gesture) => { + gesture._startPos = touchEventCoord(event) + gesture._swiping = true +} + +const updateSwipe = (event, gesture) => { + if (!gesture._swiping) return + // movement too small + const delta = deltaCoord(gesture._startPos, touchEventCoord(event)) + if (vectorLength(delta) < gesture.threshold) return + // movement is opposite from direction + if (dotProduct(delta, gesture.direction) < 0) return + // movement perpendicular to direction is too much + const towardsDir = project(delta, gesture.direction) + const perpendicularDir = perpendicular(gesture.direction) + const towardsPerpendicular = project(delta, perpendicularDir) + if ( + vectorLength(towardsDir) * gesture.perpendicularTolerance < + vectorLength(towardsPerpendicular) + ) return + + gesture.onSwipe() + gesture._swiping = false +} + +const GestureService = { + DIRECTION_LEFT, + DIRECTION_RIGHT, + DIRECTION_UP, + DIRECTION_DOWN, + swipeGesture, + beginSwipe, + updateSwipe +} + +export default GestureService diff --git a/src/services/user_profile_link_generator/user_profile_link_generator.js b/src/services/user_profile_link_generator/user_profile_link_generator.js index a214ca48..16f1531d 100644 --- a/src/services/user_profile_link_generator/user_profile_link_generator.js +++ b/src/services/user_profile_link_generator/user_profile_link_generator.js @@ -1,7 +1,7 @@ import { includes } from 'lodash' const generateProfileLink = (id, screenName, restrictedNicknames) => { - const complicated = (isExternal(screenName) || includes(restrictedNicknames, screenName)) + const complicated = !screenName || (isExternal(screenName) || includes(restrictedNicknames, screenName)) return { name: (complicated ? 'external-user-profile' : 'user-profile'), params: (complicated ? { id } : { name: screenName }) |
