aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/App.js6
-rw-r--r--src/App.vue2
-rw-r--r--src/components/attachment/attachment.vue2
-rw-r--r--src/components/interface_language_switcher/interface_language_switcher.vue38
-rw-r--r--src/components/notification/notification.vue11
-rw-r--r--src/components/notifications/notifications.js28
-rw-r--r--src/components/notifications/notifications.scss49
-rw-r--r--src/components/notifications/notifications.vue11
-rw-r--r--src/components/post_status_form/post_status_form.js6
-rw-r--r--src/components/post_status_form/post_status_form.vue5
-rw-r--r--src/components/settings/settings.js8
-rw-r--r--src/components/settings/settings.vue14
-rw-r--r--src/components/status/status.js58
-rw-r--r--src/components/status/status.vue8
-rw-r--r--src/components/user_card_content/user_card_content.vue10
-rw-r--r--src/components/who_to_follow_panel/who_to_follow_panel.js48
-rw-r--r--src/components/who_to_follow_panel/who_to_follow_panel.vue4
-rw-r--r--src/i18n/messages.js180
-rw-r--r--src/main.js13
-rw-r--r--src/modules/api.js3
-rw-r--r--src/modules/config.js6
-rw-r--r--src/modules/statuses.js145
-rw-r--r--src/modules/users.js2
-rw-r--r--src/services/api/api.service.js18
-rw-r--r--src/services/backend_interactor_service/backend_interactor_service.js11
-rw-r--r--src/services/notifications_fetcher/notifications_fetcher.service.js46
-rw-r--r--src/services/status_poster/status_poster.service.js4
-rw-r--r--src/services/timeline_fetcher/timeline_fetcher.service.js4
28 files changed, 553 insertions, 187 deletions
diff --git a/src/App.js b/src/App.js
index a052e058..a9a46fad 100644
--- a/src/App.js
+++ b/src/App.js
@@ -20,6 +20,10 @@ export default {
data: () => ({
mobileActivePanel: 'timeline'
}),
+ created () {
+ // Load the locale from the storage
+ this.$i18n.locale = this.$store.state.config.interfaceLanguage
+ },
computed: {
currentUser () { return this.$store.state.users.currentUser },
background () {
@@ -29,7 +33,7 @@ export default {
style () { return { 'background-image': `url(${this.background})` } },
sitename () { return this.$store.state.config.name },
chat () { return this.$store.state.chat.channel.state === 'joined' },
- showWhoToFollowPanel () { return this.$store.state.config.showWhoToFollowPanel },
+ suggestionsEnabled () { return this.$store.state.config.suggestionsEnabled },
showInstanceSpecificPanel () { return this.$store.state.config.showInstanceSpecificPanel }
},
methods: {
diff --git a/src/App.vue b/src/App.vue
index 923d411b..71e90289 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -24,7 +24,7 @@
<user-panel></user-panel>
<nav-panel></nav-panel>
<instance-specific-panel v-if="showInstanceSpecificPanel"></instance-specific-panel>
- <who-to-follow-panel v-if="currentUser && showWhoToFollowPanel"></who-to-follow-panel>
+ <who-to-follow-panel v-if="currentUser && suggestionsEnabled"></who-to-follow-panel>
<notifications v-if="currentUser"></notifications>
</div>
</div>
diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue
index d01c8566..bbb43679 100644
--- a/src/components/attachment/attachment.vue
+++ b/src/components/attachment/attachment.vue
@@ -10,7 +10,7 @@
<a href="#" @click.prevent="toggleHidden()">Hide</a>
</div>
- <a v-if="type === 'image' && !hidden" class="image-attachment" :href="attachment.url" target="_blank">
+ <a v-if="type === 'image' && !hidden" class="image-attachment" :href="attachment.url" target="_blank" :title="attachment.description">
<StillImage :class="{'small': isSmall}" referrerpolicy="no-referrer" :mimetype="attachment.mimetype" :src="attachment.large_thumb_url || attachment.url"/>
</a>
diff --git a/src/components/interface_language_switcher/interface_language_switcher.vue b/src/components/interface_language_switcher/interface_language_switcher.vue
new file mode 100644
index 00000000..4b541888
--- /dev/null
+++ b/src/components/interface_language_switcher/interface_language_switcher.vue
@@ -0,0 +1,38 @@
+<template>
+ <div>
+ <label for="interface-language-switcher" class='select'>
+ <select id="interface-language-switcher" v-model="language">
+ <option v-for="(langCode, i) in languageCodes" :value="langCode">
+ {{ languageNames[i] }}
+ </option>
+ </select>
+ <i class="icon-down-open"/>
+ </label>
+ </div>
+</template>
+
+<script>
+ import languagesObject from '../../i18n/messages'
+ import ISO6391 from 'iso-639-1'
+ import _ from 'lodash'
+
+ export default {
+ computed: {
+ languageCodes () {
+ return Object.keys(languagesObject)
+ },
+
+ languageNames () {
+ return _.map(this.languageCodes, ISO6391.getName)
+ },
+
+ language: {
+ get: function () { return this.$store.state.config.interfaceLanguage },
+ set: function (val) {
+ this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val })
+ this.$i18n.locale = val
+ }
+ }
+ }
+ }
+</script>
diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue
index bb76ddf8..72c1ca69 100644
--- a/src/components/notification/notification.vue
+++ b/src/components/notification/notification.vue
@@ -12,7 +12,7 @@
<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>
<span class="username" v-else :title="'@'+notification.action.user.screen_name">{{ notification.action.user.name }}</span>
- <span v-if="notification.type === 'favorite'">
+ <span v-if="notification.type === 'like'">
<i class="fa icon-star lit"></i>
<small>{{$t('notifications.favorited_you')}}</small>
</span>
@@ -25,12 +25,17 @@
<small>{{$t('notifications.followed_you')}}</small>
</span>
</div>
- <small class="timeago"><router-link :to="{ name: 'conversation', params: { id: notification.status.id } }"><timeago :since="notification.action.created_at" :auto-update="240"></timeago></router-link></small>
+ <small class="timeago"><router-link v-if="notification.status" :to="{ name: 'conversation', params: { id: notification.status.id } }"><timeago :since="notification.action.created_at" :auto-update="240"></timeago></router-link></small>
</span>
<div class="follow-text" v-if="notification.type === 'follow'">
<router-link :to="{ name: 'user-profile', params: { id: notification.action.user.id } }">@{{notification.action.user.screen_name}}</router-link>
</div>
- <status v-else class="faint" :compact="true" :statusoid="notification.status" :noHeading="true"></status>
+ <template v-else>
+ <status v-if="notification.status" class="faint" :compact="true" :statusoid="notification.status" :noHeading="true"></status>
+ <div class="broken-favorite" v-else>
+ {{$t('notifications.broken_favorite')}}
+ </div>
+ </template>
</div>
</div>
</template>
diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js
index f8314bfc..b24250b0 100644
--- a/src/components/notifications/notifications.js
+++ b/src/components/notifications/notifications.js
@@ -1,16 +1,21 @@
import Notification from '../notification/notification.vue'
+import notificationsFetcher from '../../services/notifications_fetcher/notifications_fetcher.service.js'
-import { sortBy, take, filter } from 'lodash'
+import { sortBy, filter } from 'lodash'
const Notifications = {
- data () {
- return {
- visibleNotificationCount: 20
- }
+ created () {
+ const store = this.$store
+ const credentials = store.state.users.currentUser.credentials
+
+ notificationsFetcher.startFetching({ store, credentials })
},
computed: {
notifications () {
- return this.$store.state.statuses.notifications
+ return this.$store.state.statuses.notifications.data
+ },
+ error () {
+ return this.$store.state.statuses.notifications.error
},
unseenNotifications () {
return filter(this.notifications, ({seen}) => !seen)
@@ -19,7 +24,7 @@ const Notifications = {
// Don't know why, but sortBy([seen, -action.id]) doesn't work.
let sortedNotifications = sortBy(this.notifications, ({action}) => -action.id)
sortedNotifications = sortBy(sortedNotifications, 'seen')
- return take(sortedNotifications, this.visibleNotificationCount)
+ return sortedNotifications
},
unseenCount () {
return this.unseenNotifications.length
@@ -40,6 +45,15 @@ const Notifications = {
methods: {
markAsSeen () {
this.$store.commit('markNotificationsAsSeen', this.visibleNotifications)
+ },
+ fetchOlderNotifications () {
+ const store = this.$store
+ const credentials = store.state.users.currentUser.credentials
+ notificationsFetcher.fetchAndUpdate({
+ store,
+ credentials,
+ older: true
+ })
}
}
}
diff --git a/src/components/notifications/notifications.scss b/src/components/notifications/notifications.scss
index 5853c68e..5b09685b 100644
--- a/src/components/notifications/notifications.scss
+++ b/src/components/notifications/notifications.scss
@@ -4,6 +4,10 @@
// a bit of a hack to allow scrolling below notifications
padding-bottom: 15em;
+ .title {
+ display: inline-block;
+ }
+
.panel {
background: $fallback--bg;
background: var(--bg, $fallback--bg)
@@ -22,6 +26,8 @@
background: var(--btn, $fallback--btn);
color: $fallback--fg;
color: var(--fg, $fallback--fg);
+ display: flex;
+ align-items: baseline;
.read-button {
position: absolute;
right: 0.7em;
@@ -44,6 +50,19 @@
line-height: 1.3em;
}
+ .loadmore-error {
+ position: absolute;
+ right: 0.6em;
+ font-size: 14px;
+ min-width: 6em;
+ font-family: sans-serif;
+ text-align: center;
+ padding: 0 0.25em 0 0.25em;
+ margin: 0;
+ color: $fallback--fg;
+ color: var(--fg, $fallback--fg);
+ }
+
.unseen {
box-shadow: inset 4px 0 0 var(--cRed, $fallback--cRed);
padding-left: 0;
@@ -56,6 +75,16 @@
border-bottom: 1px solid;
border-bottom-color: inherit;
+ .broken-favorite {
+ border-radius: $fallback--tooltipRadius;
+ border-radius: var(--tooltipRadius, $fallback--tooltipRadius);
+ color: $fallback--faint;
+ color: var(--faint, $fallback--faint);
+ background-color: $fallback--cAlertRed;
+ background-color: var(--cAlertRed, $fallback--cAlertRed);
+ padding: 2px .5em
+ }
+
.avatar-compact {
width: 32px;
height: 32px;
@@ -69,7 +98,7 @@
}
}
- &:hover .animated.avatar {
+ &:hover .animated.avatar-compact {
canvas {
display: none;
}
@@ -145,6 +174,13 @@
max-width: 100%;
text-overflow: ellipsis;
white-space: nowrap;
+
+ img {
+ width: 14px;
+ height: 14px;
+ vertical-align: middle;
+ object-fit: contain
+ }
}
.timeago {
float: right;
@@ -194,15 +230,4 @@
margin-bottom: 0.3em;
}
}
-
- // ugly as heck
- &:last-child {
- border-bottom: none;
- border-radius: 0 0 $fallback--panelRadius $fallback--panelRadius;
- border-radius: 0 0 var(--panelRadius, $fallback--panelRadius) var(--panelRadius, $fallback--panelRadius);
- .status-el {
- border-radius: 0 0 $fallback--panelRadius $fallback--panelRadius;
- border-radius: 0 0 var(--panelRadius, $fallback--panelRadius) var(--panelRadius, $fallback--panelRadius);
- }
- }
}
diff --git a/src/components/notifications/notifications.vue b/src/components/notifications/notifications.vue
index 4fa6e925..a0b0e5f5 100644
--- a/src/components/notifications/notifications.vue
+++ b/src/components/notifications/notifications.vue
@@ -3,7 +3,10 @@
<div class="panel panel-default">
<div class="panel-heading">
<span class="unseen-count" v-if="unseenCount">{{unseenCount}}</span>
- {{$t('notifications.notifications')}}
+ <div class="title"> {{$t('notifications.notifications')}}</div>
+ <div @click.prevent class="loadmore-error alert error" v-if="error">
+ {{$t('timeline.error_fetching')}}
+ </div>
<button v-if="unseenCount" @click.prevent="markAsSeen" class="read-button">{{$t('notifications.read')}}</button>
</div>
<div class="panel-body">
@@ -11,6 +14,12 @@
<notification :notification="notification"></notification>
</div>
</div>
+ <div class="panel-footer">
+ <a href="#" v-on:click.prevent='fetchOlderNotifications()' v-if="!notifications.loading">
+ <div class="new-status-notification text-center panel-footer">{{$t('notifications.load_older')}}</div>
+ </a>
+ <div class="new-status-notification text-center panel-footer" v-else>...</div>
+ </div>
</div>
</div>
</template>
diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js
index ff3bb906..7d40bc3c 100644
--- a/src/components/post_status_form/post_status_form.js
+++ b/src/components/post_status_form/post_status_form.js
@@ -24,7 +24,8 @@ const PostStatusForm = {
'replyTo',
'repliedUser',
'attentions',
- 'messageScope'
+ 'messageScope',
+ 'subject'
],
components: {
MediaUpload
@@ -52,7 +53,9 @@ const PostStatusForm = {
posting: false,
highlighted: 0,
newStatus: {
+ spoilerText: this.subject,
status: statusText,
+ nsfw: false,
files: [],
visibility: this.messageScope || this.$store.state.users.currentUser.default_scope
},
@@ -204,6 +207,7 @@ const PostStatusForm = {
status: newStatus.status,
spoilerText: newStatus.spoilerText || null,
visibility: newStatus.visibility,
+ sensitive: newStatus.nsfw,
media: newStatus.files,
store: this.$store,
inReplyToStatusId: this.replyTo
diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue
index 2b84758b..9f8b2661 100644
--- a/src/components/post_status_form/post_status_form.vue
+++ b/src/components/post_status_form/post_status_form.vue
@@ -75,6 +75,11 @@
</div>
</div>
</div>
+ <div class="upload_settings" v-if="newStatus.files.length > 0">
+ <input type="checkbox" id="filesSensitive" v-model="newStatus.nsfw">
+ <label for="filesSensitive" v-if="newStatus.nsfw">{{$t('post_status.attachments_sensitive')}}</label>
+ <label for="filesSensitive" v-else v-html="$t('post_status.attachments_not_sensitive')"></label>
+ </div>
</form>
</div>
</template>
diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js
index c85ef59f..f8eaad00 100644
--- a/src/components/settings/settings.js
+++ b/src/components/settings/settings.js
@@ -1,5 +1,6 @@
/* eslint-env browser */
import StyleSwitcher from '../style_switcher/style_switcher.vue'
+import InterfaceLanguageSwitcher from '../interface_language_switcher/interface_language_switcher.vue'
import { filter, trim } from 'lodash'
const settings = {
@@ -8,6 +9,7 @@ const settings = {
hideAttachmentsLocal: this.$store.state.config.hideAttachments,
hideAttachmentsInConvLocal: this.$store.state.config.hideAttachmentsInConv,
hideNsfwLocal: this.$store.state.config.hideNsfw,
+ replyVisibilityLocal: this.$store.state.config.replyVisibility,
loopVideoLocal: this.$store.state.config.loopVideo,
loopVideoSilentOnlyLocal: this.$store.state.config.loopVideoSilentOnly,
muteWordsString: this.$store.state.config.muteWords.join('\n'),
@@ -27,7 +29,8 @@ const settings = {
}
},
components: {
- StyleSwitcher
+ StyleSwitcher,
+ InterfaceLanguageSwitcher
},
computed: {
user () {
@@ -44,6 +47,9 @@ const settings = {
hideNsfwLocal (value) {
this.$store.dispatch('setOption', { name: 'hideNsfw', value })
},
+ replyVisibilityLocal (value) {
+ this.$store.dispatch('setOption', { name: 'replyVisibility', value })
+ },
loopVideoLocal (value) {
this.$store.dispatch('setOption', { name: 'loopVideo', value })
},
diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue
index 415317f0..f500a1b0 100644
--- a/src/components/settings/settings.vue
+++ b/src/components/settings/settings.vue
@@ -38,6 +38,16 @@
<input type="checkbox" id="hoverPreview" v-model="hoverPreviewLocal">
<label for="hoverPreview">{{$t('settings.reply_link_preview')}}</label>
</li>
+ <li>
+ <label for="replyVisibility" class="select">
+ <select id="replyVisibility" v-model="replyVisibilityLocal">
+ <option value="all" selected>{{$t('settings.reply_visibility_all')}}</option>
+ <option value="following">{{$t('settings.reply_visibility_following')}}</option>
+ <option value="self">{{$t('settings.reply_visibility_self')}}</option>
+ </select>
+ <i class="icon-down-open"/>
+ </label>
+ </li>
</ul>
</div>
<div class="setting-item">
@@ -74,6 +84,10 @@
</li>
</ul>
</div>
+ <div class="setting-item">
+ <h2>{{ $t('settings.interfaceLanguage') }}</h2>
+ <interface-language-switcher />
+ </div>
</div>
</div>
</template>
diff --git a/src/components/status/status.js b/src/components/status/status.js
index 9670f69d..a6c49f7c 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -83,7 +83,6 @@ const Status = {
return hits
},
muted () { return !this.unmuted && (this.status.user.muted || this.muteWordHits.length > 0) },
- isReply () { return !!this.status.in_reply_to_status_id },
isFocused () {
// retweet or root of an expanded conversation
if (this.focused) {
@@ -105,6 +104,48 @@ const Status = {
const lengthScore = this.status.statusnet_html.split(/<p|<br/).length + this.status.text.length / 80
return lengthScore > 20
},
+ isReply () {
+ if (this.status.in_reply_to_status_id) {
+ return true
+ }
+ // For private replies where we can't see the OP, in_reply_to_status_id will be null.
+ // So instead, check that the post starts with a @mention.
+ if (this.status.visibility === 'private') {
+ var textBody = this.status.text
+ if (this.status.summary !== null) {
+ textBody = textBody.substring(this.status.summary.length, textBody.length)
+ }
+ return textBody.startsWith('@')
+ }
+ return false
+ },
+ hideReply () {
+ if (this.$store.state.config.replyVisibility === 'all') {
+ return false
+ }
+ if (this.inlineExpanded || this.expanded || this.inConversation || !this.isReply) {
+ return false
+ }
+ if (this.status.user.id === this.$store.state.users.currentUser.id) {
+ return false
+ }
+ if (this.status.activity_type === 'repeat') {
+ return false
+ }
+ var checkFollowing = this.$store.state.config.replyVisibility === 'following'
+ for (var i = 0; i < this.status.attentions.length; ++i) {
+ if (this.status.user.id === this.status.attentions[i].id) {
+ continue
+ }
+ if (checkFollowing && this.status.attentions[i].following) {
+ return false
+ }
+ if (this.status.attentions[i].id === this.$store.state.users.currentUser.id) {
+ return false
+ }
+ }
+ return this.status.attentions.length > 0
+ },
hideSubjectStatus () {
if (this.tallStatus && !this.$store.state.config.collapseMessageWithSubject) {
return false
@@ -123,6 +164,21 @@ const Status = {
showingMore () {
return this.showingTall || (this.status.summary && this.expandingSubject)
},
+ nsfwClickthrough () {
+ if (!this.status.nsfw) {
+ return false
+ }
+ if (this.status.summary && this.$store.state.config.collapseMessageWithSubject) {
+ return false
+ }
+ return true
+ },
+ replySubject () {
+ if (this.status.summary && !this.status.summary.match(/^re[: ]/i)) {
+ return 're: '.concat(this.status.summary)
+ }
+ return this.status.summary
+ },
attachmentSize () {
if ((this.$store.state.config.hideAttachments && !this.inConversation) ||
(this.$store.state.config.hideAttachmentsInConv && this.inConversation)) {
diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index e7d5ed7a..123b0cc2 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -1,5 +1,5 @@
<template>
- <div class="status-el" :class="[{ 'status-el_focused': isFocused }, { 'status-conversation': inlineExpanded }]">
+ <div class="status-el" v-if="!hideReply" :class="[{ 'status-el_focused': isFocused }, { 'status-conversation': inlineExpanded }]">
<template v-if="muted && !noReplyLinks">
<div class="media status container muted">
<small><router-link :to="{ name: 'user-profile', params: { id: status.user.id } }">{{status.user.screen_name}}</router-link></small>
@@ -83,8 +83,8 @@
<a v-if="showingMore" href="#" class="status-unhider" @click.prevent="toggleShowMore">Show less</a>
</div>
- <div v-if='status.attachments' class='attachments media-body'>
- <attachment :size="attachmentSize" :status-id="status.id" :nsfw="status.nsfw" :attachment="attachment" v-for="attachment in status.attachments" :key="attachment.id">
+ <div v-if='status.attachments && !hideSubjectStatus' class='attachments media-body'>
+ <attachment :size="attachmentSize" :status-id="status.id" :nsfw="nsfwClickthrough" :attachment="attachment" v-for="attachment in status.attachments" :key="attachment.id">
</attachment>
</div>
@@ -102,7 +102,7 @@
</div>
<div class="container" v-if="replying">
<div class="reply-left"/>
- <post-status-form class="reply-body" :reply-to="status.id" :attentions="status.attentions" :repliedUser="status.user" :message-scope="status.visibility" v-on:posted="toggleReplying"/>
+ <post-status-form class="reply-body" :reply-to="status.id" :attentions="status.attentions" :repliedUser="status.user" :message-scope="status.visibility" :subject="replySubject" v-on:posted="toggleReplying"/>
</div>
</template>
</div>
diff --git a/src/components/user_card_content/user_card_content.vue b/src/components/user_card_content/user_card_content.vue
index 71222d15..59358040 100644
--- a/src/components/user_card_content/user_card_content.vue
+++ b/src/components/user_card_content/user_card_content.vue
@@ -105,8 +105,8 @@
<span>{{user.followers_count}}</span>
</div>
</div>
- <p v-if="!hideBio && user.description_html" v-html="user.description_html"></p>
- <p v-else-if="!hideBio">{{ user.description }}</p>
+ <p v-if="!hideBio && user.description_html" class="profile-bio" v-html="user.description_html"></p>
+ <p v-else-if="!hideBio" class="profile-bio">{{ user.description }}</p>
</div>
</div>
</template>
@@ -130,7 +130,11 @@
.profile-panel-body {
word-wrap: break-word;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0), $fallback--bg 80%);
- background: linear-gradient(to bottom, rgba(0, 0, 0, 0), var(--bg, $fallback--bg) 80%)
+ background: linear-gradient(to bottom, rgba(0, 0, 0, 0), var(--bg, $fallback--bg) 80%);
+
+ .profile-bio {
+ text-align: center;
+ }
}
.user-info {
diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.js b/src/components/who_to_follow_panel/who_to_follow_panel.js
index 51b9f469..6766e561 100644
--- a/src/components/who_to_follow_panel/who_to_follow_panel.js
+++ b/src/components/who_to_follow_panel/who_to_follow_panel.js
@@ -1,5 +1,7 @@
-function showWhoToFollow (panel, reply, aHost, aUser) {
- var users = reply.ids
+import apiService from '../../services/api/api.service.js'
+
+function showWhoToFollow (panel, reply) {
+ var users = reply
var cn
var index = 0
var random = Math.floor(Math.random() * 10)
@@ -7,12 +9,12 @@ function showWhoToFollow (panel, reply, aHost, aUser) {
var user
user = users[cn]
var img
- if (user.icon) {
- img = user.icon
+ if (user.avatar) {
+ img = user.avatar
} else {
img = '/images/avi.png'
}
- var name = user.to_id
+ var name = user.acct
if (index === 0) {
panel.img1 = img
panel.name1 = name
@@ -52,27 +54,15 @@ function showWhoToFollow (panel, reply, aHost, aUser) {
}
function getWhoToFollow (panel) {
- var user = panel.$store.state.users.currentUser.screen_name
- if (user) {
+ var credentials = panel.$store.state.users.currentUser.credentials
+ if (credentials) {
panel.name1 = 'Loading...'
panel.name2 = 'Loading...'
panel.name3 = 'Loading...'
- var host = window.location.hostname
- var whoToFollowProvider = panel.$store.state.config.whoToFollowProvider
- var url
- url = whoToFollowProvider.replace(/{{host}}/g, encodeURIComponent(host))
- url = url.replace(/{{user}}/g, encodeURIComponent(user))
- window.fetch(url, {mode: 'cors'}).then(function (response) {
- if (response.ok) {
- return response.json()
- } else {
- panel.name1 = ''
- panel.name2 = ''
- panel.name3 = ''
- }
- }).then(function (reply) {
- showWhoToFollow(panel, reply, host, user)
- })
+ apiService.suggestions({credentials: credentials})
+ .then((reply) => {
+ showWhoToFollow(panel, reply)
+ })
}
}
@@ -95,26 +85,26 @@ const WhoToFollowPanel = {
moreUrl: function () {
var host = window.location.hostname
var user = this.user
- var whoToFollowLink = this.$store.state.config.whoToFollowLink
+ var suggestionsWeb = this.$store.state.config.suggestionsWeb
var url
- url = whoToFollowLink.replace(/{{host}}/g, encodeURIComponent(host))
+ url = suggestionsWeb.replace(/{{host}}/g, encodeURIComponent(host))
url = url.replace(/{{user}}/g, encodeURIComponent(user))
return url
},
- showWhoToFollowPanel () {
- return this.$store.state.config.showWhoToFollowPanel
+ suggestionsEnabled () {
+ return this.$store.state.config.suggestionsEnabled
}
},
watch: {
user: function (user, oldUser) {
- if (this.showWhoToFollowPanel) {
+ if (this.suggestionsEnabled) {
getWhoToFollow(this)
}
}
},
mounted:
function () {
- if (this.showWhoToFollowPanel) {
+ if (this.suggestionsEnabled) {
getWhoToFollow(this)
}
}
diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.vue b/src/components/who_to_follow_panel/who_to_follow_panel.vue
index 5af6d0d5..8b3abe70 100644
--- a/src/components/who_to_follow_panel/who_to_follow_panel.vue
+++ b/src/components/who_to_follow_panel/who_to_follow_panel.vue
@@ -3,7 +3,7 @@
<div class="panel panel-default base01-background">
<div class="panel-heading timeline-heading base02-background base04">
<div class="title">
- Who to follow
+ {{$t('who_to_follow.who_to_follow')}}
</div>
</div>
<div class="panel-body who-to-follow">
@@ -11,7 +11,7 @@
<img v-bind:src="img1"/> <router-link :to="{ name: 'user-profile', params: { id: id1 } }">{{ name1 }}</router-link><br>
<img v-bind:src="img2"/> <router-link :to="{ name: 'user-profile', params: { id: id2 } }">{{ name2 }}</router-link><br>
<img v-bind:src="img3"/> <router-link :to="{ name: 'user-profile', params: { id: id3 } }">{{ name3 }}</router-link><br>
- <img v-bind:src="$store.state.config.logo"> <a v-bind:href="moreUrl" target="_blank">More</a>
+ <img v-bind:src="$store.state.config.logo"> <a v-bind:href="moreUrl" target="_blank">{{$t('who_to_follow.more')}}</a>
</p>
</div>
</div>
diff --git a/src/i18n/messages.js b/src/i18n/messages.js
index 2fa0f910..30055192 100644
--- a/src/i18n/messages.js
+++ b/src/i18n/messages.js
@@ -325,6 +325,9 @@ const en = {
loop_video: 'Loop videos',
loop_video_silent_only: 'Loop only videos without sound (i.e. Mastodon\'s "gifs")',
reply_link_preview: 'Enable reply-link preview on mouse hover',
+ reply_visibility_all: 'Show all replies',
+ reply_visibility_following: 'Only show replies directed at me or users I\'m following',
+ reply_visibility_self: 'Only show replies directed at me',
follow_import: 'Follow import',
import_followers_from_a_csv_file: 'Import follows from a csv file',
follows_imported: 'Follows imported! Processing them will take a while.',
@@ -347,14 +350,17 @@ const en = {
default_vis: 'Default visibility scope',
profile_tab: 'Profile',
security_tab: 'Security',
- data_import_export_tab: 'Data Import / Export'
+ data_import_export_tab: 'Data Import / Export',
+ interfaceLanguage: 'Interface language'
},
notifications: {
notifications: 'Notifications',
read: 'Read!',
followed_you: 'followed you',
favorited_you: 'favorited your status',
- repeated_you: 'repeated your status'
+ repeated_you: 'repeated your status',
+ broken_favorite: 'Unknown status, searching for it...',
+ load_older: 'Load older notifications'
},
login: {
login: 'Log in',
@@ -379,6 +385,8 @@ const en = {
account_not_locked_warning: 'Your account is not {0}. Anyone can follow you to view your follower-only posts.',
account_not_locked_warning_link: 'locked',
direct_warning: 'This post will only be visible to all the mentioned users.',
+ attachments_sensitive: 'Attachments marked sensitive',
+ attachments_not_sensitive: 'Attachments <strong>not</strong> marked sensitive',
scope: {
public: 'Public - Post to public timelines',
unlisted: 'Unlisted - Do not post to public timelines',
@@ -396,6 +404,10 @@ const en = {
},
user_profile: {
timeline_title: 'User Timeline'
+ },
+ who_to_follow: {
+ who_to_follow: 'Who to follow',
+ more: 'More'
}
}
@@ -779,115 +791,147 @@ const ja = {
chat: 'ローカルチャット',
timeline: 'タイムライン',
mentions: 'メンション',
- public_tl: '公開タイムライン',
- twkn: '接続しているすべてのネットワーク'
+ public_tl: 'パブリックタイムライン',
+ twkn: 'つながっているすべてのネットワーク',
+ friend_requests: 'Follow Requests'
},
user_card: {
follows_you: 'フォローされました!',
- following: 'フォロー中!',
+ following: 'フォローしています!',
follow: 'フォロー',
- blocked: 'ブロック済み!',
+ blocked: 'ブロックしています!',
block: 'ブロック',
- statuses: '投稿',
+ statuses: 'ステータス',
mute: 'ミュート',
- muted: 'ミュート済み',
+ muted: 'ミュートしています!',
followers: 'フォロワー',
followees: 'フォロー',
per_day: '/日',
- remote_follow: 'リモートフォロー'
+ remote_follow: 'リモートフォロー',
+ approve: 'Approve',
+ deny: 'Deny'
},
timeline: {
- show_new: '更新',
- error_fetching: '更新の取得中にエラーが発生しました。',
- up_to_date: '最新',
- load_older: '古い投稿を読み込む',
- conversation: '会話',
- collapse: '折り畳む',
+ show_new: 'よみこみ',
+ error_fetching: 'よみこみがエラーになりました。',
+ up_to_date: 'さいしん',
+ load_older: 'ふるいステータス',
+ conversation: 'スレッド',
+ collapse: 'たたむ',
repeated: 'リピート'
},
settings: {
- user_settings: 'ユーザー設定',
- name_bio: '名前とプロフィール',
- name: '名前',
+ user_settings: 'ユーザーせってい',
+ name_bio: 'なまえとプロフィール',
+ name: 'なまえ',
bio: 'プロフィール',
avatar: 'アバター',
- current_avatar: 'あなたの現在のアバター',
- set_new_avatar: '新しいアバターを設定する',
+ current_avatar: 'いまのアバター',
+ set_new_avatar: 'あたらしいアバターをせっていする',
profile_banner: 'プロフィールバナー',
- current_profile_banner: '現在のプロフィールバナー',
- set_new_profile_banner: '新しいプロフィールバナーを設定する',
- profile_background: 'プロフィールの背景',
- set_new_profile_background: '新しいプロフィールの背景を設定する',
- settings: '設定',
+ current_profile_banner: 'いまのプロフィールバナー',
+ set_new_profile_banner: 'あたらしいプロフィールバナーを設定する',
+ profile_background: 'プロフィールのバックグラウンド',
+ set_new_profile_background: 'あたらしいプロフィールのバックグラウンドをせっていする',
+ settings: 'せってい',
theme: 'テーマ',
presets: 'プリセット',
- theme_help: '16進数カラーコード (#aabbcc) を使用してカラーテーマをカスタマイズ出来ます。',
- radii_help: 'インターフェースの縁の丸さを設定する。',
- background: '背景',
- foreground: '前景',
- text: '文字',
+ theme_help: 'カラーテーマをカスタマイズできます。',
+ radii_help: 'インターフェースのまるさをせっていする。',
+ background: 'バックグラウンド',
+ foreground: 'フォアグラウンド',
+ text: 'もじ',
links: 'リンク',
- cBlue: '青 (返信, フォロー)',
- cRed: '赤 (キャンセル)',
- cOrange: 'オレンジ (お気に入り)',
- cGreen: '緑 (リツイート)',
+ cBlue: 'あお (リプライ, フォロー)',
+ cRed: 'あか (キャンセル)',
+ cOrange: 'オレンジ (おきにいり)',
+ cGreen: 'みどり (リピート)',
btnRadius: 'ボタン',
+ inputRadius: 'Input fields',
panelRadius: 'パネル',
avatarRadius: 'アバター',
- avatarAltRadius: 'アバター (通知)',
+ avatarAltRadius: 'アバター (つうち)',
tooltipRadius: 'ツールチップ/アラート',
attachmentRadius: 'ファイル',
filtering: 'フィルタリング',
- filtering_explanation: 'これらの単語を含むすべてのものがミュートされます。1行に1つの単語を入力してください。',
+ filtering_explanation: 'これらのことばをふくむすべてのものがミュートされます。1行に1つのことばをかいてください。',
attachments: 'ファイル',
- hide_attachments_in_tl: 'タイムラインのファイルを隠す。',
- hide_attachments_in_convo: '会話の中のファイルを隠す。',
- nsfw_clickthrough: 'NSFWファイルの非表示を有効にする。',
- stop_gifs: 'カーソルを重ねた時にGIFを再生する。',
- autoload: '下にスクロールした時に自動で読み込むようにする。',
- streaming: '上までスクロールした時に自動でストリーミングされるようにする。',
- reply_link_preview: 'マウスカーソルを重ねた時に返信のプレビューを表示するようにする。',
+ hide_attachments_in_tl: 'タイムラインのファイルをかくす。',
+ hide_attachments_in_convo: 'スレッドのファイルをかくす。',
+ nsfw_clickthrough: 'NSFWなファイルをかくす。',
+ stop_gifs: 'カーソルをかさねたとき、GIFをうごかす。',
+ autoload: 'したにスクロールしたとき、じどうてきによみこむ。',
+ streaming: 'うえまでスクロールしたとき、じどうてきにストリーミングする。',
+ reply_link_preview: 'カーソルをかさねたとき、リプライのプレビューをみる。',
follow_import: 'フォローインポート',
import_followers_from_a_csv_file: 'CSVファイルからフォローをインポートする。',
- follows_imported: 'フォローがインポートされました!処理に少し時間がかかるかもしれません。',
- follow_import_error: 'フォロワーのインポート中にエラーが発生しました。'
+ follows_imported: 'フォローがインポートされました! すこしじかんがかかるかもしれません。',
+ follow_import_error: 'フォローのインポートがエラーになりました。',
+ delete_account: 'アカウントをけす',
+ delete_account_description: 'あなたのアカウントとメッセージが、きえます。',
+ delete_account_instructions: 'ほんとうにアカウントをけしてもいいなら、パスワードをかいてください。',
+ delete_account_error: 'アカウントをけすことが、できなかったかもしれません。インスタンスのかんりしゃに、れんらくしてください。',
+ follow_export: 'フォローのエクスポート',
+ follow_export_processing: 'おまちください。まもなくファイルをダウンロードできます。',
+ follow_export_button: 'エクスポート',
+ change_password: 'パスワードをかえる',
+ current_password: 'いまのパスワード',
+ new_password: 'あたらしいパスワード',
+ confirm_new_password: 'あたらしいパスワードのかくにん',
+ changed_password: 'パスワードが、かわりました!',
+ change_password_error: 'パスワードをかえることが、できなかったかもしれません。',
+ lock_account_description: 'あなたがみとめたひとだけ、あなたのアカウントをフォローできます。'
},
notifications: {
- notifications: '通知',
- read: '読んだ!',
+ notifications: 'つうち',
+ read: 'よんだ!',
followed_you: 'フォローされました',
- favorited_you: 'あなたの投稿がお気に入りされました',
- repeated_you: 'あなたの投稿がリピートされました'
+ favorited_you: 'あなたのステータスがおきにいりされました',
+ repeated_you: 'あなたのステータスがリピートされました'
},
login: {
login: 'ログイン',
- username: 'ユーザー名',
- placeholder: '例えば lain',
+ username: 'ユーザーめい',
+ placeholder: 'れい: lain',
password: 'パスワード',
- register: '登録',
+ register: 'はじめる',
logout: 'ログアウト'
},
registration: {
- registration: '登録',
- fullname: '表示名',
+ registration: 'はじめる',
+ fullname: 'スクリーンネーム',
email: 'Eメール',
bio: 'プロフィール',
- password_confirm: 'パスワードの確認'
+ password_confirm: 'パスワードのかくにん'
},
post_status: {
- posting: '投稿',
- default: 'ちょうどL.A.に着陸しました。'
+ posting: 'とうこう',
+ content_warning: 'せつめい (かかなくてもよい)',
+ default: 'はねだくうこうに、つきました。',
+ account_not_locked_warning: 'あなたのアカウントは {0} ではありません。あなたをフォローすれば、だれでも、フォロワーげんていのステータスをよむことができます。',
+ account_not_locked_warning_link: 'ロックされたアカウント',
+ direct_warning: 'このステータスは、メンションされたユーザーだけが、よむことができます。',
+ scope: {
+ public: 'パブリック - パブリックタイムラインにとどきます。',
+ unlisted: 'アンリステッド - パブリックタイムラインにとどきません。',
+ private: 'フォロワーげんてい - フォロワーのみにとどきます。',
+ direct: 'ダイレクト - メンションされたユーザーのみにとどきます。'
+ }
},
finder: {
- find_user: 'ユーザー検索',
- error_fetching_user: 'ユーザー検索でエラーが発生しました'
+ find_user: 'ユーザーをさがす',
+ error_fetching_user: 'ユーザーけんさくがエラーになりました。'
},
general: {
- submit: '送信',
- apply: '適用'
+ submit: 'そうしん',
+ apply: 'てきよう'
},
user_profile: {
timeline_title: 'ユーザータイムライン'
+ },
+ who_to_follow: {
+ who_to_follow: 'おすすめユーザー',
+ more: 'くわしく'
}
}
@@ -1593,6 +1637,8 @@ const ru = {
set_new_profile_background: 'Загрузить новый фон профиля',
settings: 'Настройки',
theme: 'Тема',
+ export_theme: 'Экспортировать текущую тему',
+ import_theme: 'Загрузить сохранённую тему',
presets: 'Пресеты',
theme_help: 'Используйте шестнадцатеричные коды цветов (#rrggbb) для настройки темы.',
radii_help: 'Округление краёв элементов интерфейса (в пикселях)',
@@ -1641,14 +1687,22 @@ const ru = {
confirm_new_password: 'Подтверждение нового пароля',
changed_password: 'Пароль изменён успешно.',
change_password_error: 'Произошла ошибка при попытке изменить пароль.',
- limited_availability: 'Не доступно в вашем браузере'
+ lock_account_description: 'Аккаунт доступен только подтверждённым подписчикам',
+ limited_availability: 'Не доступно в вашем браузере',
+ profile_tab: 'Профиль',
+ security_tab: 'Безопасность',
+ data_import_export_tab: 'Импорт / Экспорт данных',
+ collapse_subject: 'Сворачивать посты с темой',
+ interfaceLanguage: 'Язык интерфейса'
},
notifications: {
notifications: 'Уведомления',
read: 'Прочесть',
followed_you: 'начал(а) читать вас',
favorited_you: 'нравится ваш статус',
- repeated_you: 'повторил(а) ваш статус'
+ repeated_you: 'повторил(а) ваш статус',
+ broken_favorite: 'Неизвестный статус, ищем...',
+ load_older: 'Загрузить старые уведомления'
},
login: {
login: 'Войти',
diff --git a/src/main.js b/src/main.js
index 48022c41..5258fbd9 100644
--- a/src/main.js
+++ b/src/main.js
@@ -49,6 +49,7 @@ const persistedStateOptions = {
'config.hideAttachments',
'config.hideAttachmentsInConv',
'config.hideNsfw',
+ 'config.replyVisibility',
'config.autoLoad',
'config.hoverPreview',
'config.streaming',
@@ -59,7 +60,9 @@ const persistedStateOptions = {
'config.loopVideoSilentOnly',
'config.pauseOnUnfocused',
'config.stopGifs',
- 'users.lastLoginName'
+ 'config.interfaceLanguage',
+ 'users.lastLoginName',
+ 'statuses.notifications.maxSavedId'
]
}
@@ -77,6 +80,7 @@ const store = new Vuex.Store({
})
const i18n = new VueI18n({
+ // By default, use the browser locale, we will update it if neccessary
locale: currentLocale,
fallbackLocale: 'en',
messages
@@ -206,3 +210,10 @@ window.fetch('/instance/panel.html')
store.dispatch('setOption', { name: 'instanceSpecificPanelContent', value: html })
})
+window.fetch('/nodeinfo/2.0.json')
+ .then((res) => res.json())
+ .then((data) => {
+ const suggestions = data.metadata.suggestions
+ store.dispatch('setOption', { name: 'suggestionsEnabled', value: suggestions.enabled })
+ store.dispatch('setOption', { name: 'suggestionsWeb', value: suggestions.web })
+ })
diff --git a/src/modules/api.js b/src/modules/api.js
index a61340c2..2f07a91e 100644
--- a/src/modules/api.js
+++ b/src/modules/api.js
@@ -46,6 +46,9 @@ const api = {
store.commit('addFetcher', {timeline, fetcher})
}
},
+ fetchOldPost (store, { postId }) {
+ store.state.backendInteractor.fetchOldPost({ store, postId })
+ },
stopFetching (store, timeline) {
const fetcher = store.state.fetchers[timeline]
window.clearInterval(fetcher)
diff --git a/src/modules/config.js b/src/modules/config.js
index 60210a95..ac163316 100644
--- a/src/modules/config.js
+++ b/src/modules/config.js
@@ -1,6 +1,8 @@
import { set, delete as del } from 'vue'
import StyleSetter from '../services/style_setter/style_setter.js'
+const browserLocale = (window.navigator.language || 'en').split('-')[0]
+
const defaultState = {
name: 'Pleroma FE',
colors: {},
@@ -15,8 +17,10 @@ const defaultState = {
hoverPreview: true,
pauseOnUnfocused: true,
stopGifs: false,
+ replyVisibility: 'all',
muteWords: [],
- highlight: {}
+ highlight: {},
+ interfaceLanguage: browserLocale
}
const config = {
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index 291ab53c..ff2cb098 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -1,4 +1,5 @@
import { includes, remove, slice, sortBy, toInteger, each, find, flatten, maxBy, minBy, merge, last, isArray } from 'lodash'
+import { set } from 'vue'
import apiService from '../services/api/api.service.js'
// import parse from '../services/status_parser/status_parser.js'
@@ -22,13 +23,22 @@ export const defaultState = {
allStatuses: [],
allStatusesObject: {},
maxId: 0,
- notifications: [],
+ notifications: {
+ desktopNotificationSilence: true,
+ maxId: 0,
+ maxSavedId: 0,
+ minId: Number.POSITIVE_INFINITY,
+ data: [],
+ error: false,
+ brokenFavorites: {}
+ },
favorites: new Set(),
error: false,
timelines: {
mentions: emptyTl(),
public: emptyTl(),
user: emptyTl(),
+ own: emptyTl(),
publicAndExternal: emptyTl(),
friends: emptyTl(),
tag: emptyTl()
@@ -134,11 +144,13 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
const result = mergeOrAdd(allStatuses, allStatusesObject, status)
status = result.item
- if (result.new) {
- if (statusType(status) === 'retweet' && status.retweeted_status.user.id === user.id) {
- addNotification({ type: 'repeat', status: status, action: status })
- }
+ const brokenFavorites = state.notifications.brokenFavorites[status.id] || []
+ brokenFavorites.forEach((fav) => {
+ fav.status = status
+ })
+ delete state.notifications.brokenFavorites[status.id]
+ if (result.new) {
// We are mentioned in a post
if (statusType(status) === 'status' && find(status.attentions, { id: user.id })) {
const mentions = state.timelines.mentions
@@ -150,10 +162,6 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
sortTimeline(mentions)
}
- // Don't add notification for self-mention
- if (status.user.id !== user.id) {
- addNotification({ type: 'mention', status, action: status })
- }
}
}
@@ -176,33 +184,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
return status
}
- const addNotification = ({type, status, action}) => {
- // Only add a new notification if we don't have one for the same action
- if (!find(state.notifications, (oldNotification) => oldNotification.action.id === action.id)) {
- state.notifications.push({ type, status, action, seen: false })
-
- if ('Notification' in window && window.Notification.permission === 'granted') {
- const title = action.user.name
- const result = {}
- result.icon = action.user.profile_image_url
- result.body = action.text // there's a problem that it doesn't put a space before links tho
-
- // Shows first attached non-nsfw image, if any. Should add configuration for this somehow...
- if (action.attachments && action.attachments.length > 0 && !action.nsfw &&
- action.attachments[0].mimetype.startsWith('image/')) {
- result.image = action.attachments[0].url
- }
-
- let notification = new window.Notification(title, result)
-
- // Chrome is known for not closing notifications automatically
- // according to MDN, anyway.
- setTimeout(notification.close.bind(notification), 5000)
- }
- }
- }
-
- const favoriteStatus = (favorite) => {
+ const favoriteStatus = (favorite, counter) => {
const status = find(allStatuses, { id: toInteger(favorite.in_reply_to_status_id) })
if (status) {
status.fave_num += 1
@@ -211,11 +193,6 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
if (favorite.user.id === user.id) {
status.favorited = true
}
-
- // Add a notification if the user's status is favorited
- if (status.user.id === user.id) {
- addNotification({type: 'favorite', status, action: favorite})
- }
}
return status
}
@@ -253,13 +230,6 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
favoriteStatus(favorite)
}
},
- 'follow': (status) => {
- let re = new RegExp(`started following ${user.name} \\(${user.statusnet_profile_url}\\)`)
- let repleroma = new RegExp(`started following ${user.screen_name}$`)
- if (status.text.match(re) || status.text.match(repleroma)) {
- addNotification({ type: 'follow', status: status, action: status })
- }
- },
'deletion': (deletion) => {
const uri = deletion.uri
@@ -269,7 +239,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
return
}
- remove(state.notifications, ({action: {id}}) => id === status.id)
+ remove(state.notifications.data, ({action: {id}}) => id === status.id)
remove(allStatuses, { uri })
if (timeline) {
@@ -298,8 +268,69 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
}
}
+const addNewNotifications = (state, { dispatch, notifications, older }) => {
+ const allStatuses = state.allStatuses
+ const allStatusesObject = state.allStatusesObject
+ each(notifications, (notification) => {
+ const result = mergeOrAdd(allStatuses, allStatusesObject, notification.notice)
+ const action = result.item
+ // Only add a new notification if we don't have one for the same action
+ if (!find(state.notifications.data, (oldNotification) => oldNotification.action.id === action.id)) {
+ state.notifications.maxId = Math.max(notification.id, state.notifications.maxId)
+ state.notifications.minId = Math.min(notification.id, state.notifications.minId)
+
+ const fresh = !older && !notification.is_seen && notification.id > state.notifications.maxSavedId
+ const status = notification.ntype === 'like'
+ ? find(allStatuses, { id: action.in_reply_to_status_id })
+ : action
+
+ const result = {
+ type: notification.ntype,
+ status,
+ action,
+ // Always assume older notifications as seen
+ seen: !fresh
+ }
+
+ if (notification.ntype === 'like' && !status) {
+ let broken = state.notifications.brokenFavorites[action.in_reply_to_status_id]
+ if (broken) {
+ broken.push(result)
+ } else {
+ dispatch('fetchOldPost', { postId: action.in_reply_to_status_id })
+ broken = [ result ]
+ state.notifications.brokenFavorites[action.in_reply_to_status_id] = broken
+ }
+ }
+
+ state.notifications.data.push(result)
+
+ if ('Notification' in window && window.Notification.permission === 'granted') {
+ const title = action.user.name
+ const result = {}
+ result.icon = action.user.profile_image_url
+ result.body = action.text // there's a problem that it doesn't put a space before links tho
+
+ // Shows first attached non-nsfw image, if any. Should add configuration for this somehow...
+ if (action.attachments && action.attachments.length > 0 && !action.nsfw &&
+ action.attachments[0].mimetype.startsWith('image/')) {
+ result.image = action.attachments[0].url
+ }
+
+ if (fresh && !state.notifications.desktopNotificationSilence) {
+ let notification = new window.Notification(title, result)
+ // Chrome is known for not closing notifications automatically
+ // according to MDN, anyway.
+ setTimeout(notification.close.bind(notification), 5000)
+ }
+ }
+ }
+ })
+}
+
export const mutations = {
addNewStatuses,
+ addNewNotifications,
showNewStatuses (state, { timeline }) {
const oldTimeline = (state.timelines[timeline])
@@ -334,6 +365,12 @@ export const mutations = {
setError (state, { value }) {
state.error = value
},
+ setNotificationsError (state, { value }) {
+ state.notifications.error = value
+ },
+ setNotificationsSilence (state, { value }) {
+ state.notifications.desktopNotificationSilence = value
+ },
setProfileView (state, { v }) {
// load followers / friends only when needed
state.timelines['user'].viewing = v
@@ -345,6 +382,7 @@ export const mutations = {
state.timelines['user'].followers = followers
},
markNotificationsAsSeen (state, notifications) {
+ set(state.notifications, 'maxSavedId', state.notifications.maxId)
each(notifications, (notification) => {
notification.seen = true
})
@@ -360,9 +398,18 @@ const statuses = {
addNewStatuses ({ rootState, commit }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false }) {
commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser })
},
+ addNewNotifications ({ rootState, commit, dispatch }, { notifications, older }) {
+ commit('addNewNotifications', { dispatch, notifications, older })
+ },
setError ({ rootState, commit }, { value }) {
commit('setError', { value })
},
+ setNotificationsError ({ rootState, commit }, { value }) {
+ commit('setNotificationsError', { value })
+ },
+ setNotificationsSilence ({ rootState, commit }, { value }) {
+ commit('setNotificationsSilence', { value })
+ },
addFriends ({ rootState, commit }, { friends }) {
commit('addFriends', { friends })
},
diff --git a/src/modules/users.js b/src/modules/users.js
index ba548765..c592fe4e 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -107,6 +107,8 @@ const users = {
// Start getting fresh tweets.
store.dispatch('startFetching', 'friends')
+ // Start getting our own posts, only really needed for mitigating broken favorites
+ store.dispatch('startFetching', ['own', user.id])
// Get user mutes and follower info
store.rootState.api.backendInteractor.fetchMutes().then((mutedUsers) => {
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index 13cc4796..efea86cf 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -27,6 +27,7 @@ const BANNER_UPDATE_URL = '/api/account/update_profile_banner.json'
const PROFILE_UPDATE_URL = '/api/account/update_profile.json'
const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json'
const QVITTER_USER_TIMELINE_URL = '/api/qvitter/statuses/user_timeline.json'
+const QVITTER_USER_NOTIFICATIONS_URL = '/api/qvitter/statuses/notifications.json'
const BLOCKING_URL = '/api/blocks/create.json'
const UNBLOCKING_URL = '/api/blocks/destroy.json'
const USER_URL = '/api/users/show.json'
@@ -36,6 +37,7 @@ const CHANGE_PASSWORD_URL = '/api/pleroma/change_password'
const FOLLOW_REQUESTS_URL = '/api/pleroma/friend_requests'
const APPROVE_USER_URL = '/api/pleroma/friendships/approve'
const DENY_USER_URL = '/api/pleroma/friendships/deny'
+const SUGGESTIONS_URL = '/api/v1/suggestions'
import { each, map } from 'lodash'
import 'whatwg-fetch'
@@ -302,8 +304,12 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false, use
public: PUBLIC_TIMELINE_URL,
friends: FRIENDS_TIMELINE_URL,
mentions: MENTIONS_URL,
+ notifications: QVITTER_USER_NOTIFICATIONS_URL,
'publicAndExternal': PUBLIC_AND_EXTERNAL_TIMELINE_URL,
user: QVITTER_USER_TIMELINE_URL,
+ // separate timeline for own posts, so it won't break due to user timeline bugs
+ // really needed only for broken favorites
+ own: QVITTER_USER_TIMELINE_URL,
tag: TAG_TIMELINE_URL
}
@@ -367,7 +373,7 @@ const unretweet = ({ id, credentials }) => {
})
}
-const postStatus = ({credentials, status, spoilerText, visibility, mediaIds, inReplyToStatusId}) => {
+const postStatus = ({credentials, status, spoilerText, visibility, sensitive, mediaIds, inReplyToStatusId}) => {
const idsText = mediaIds.join(',')
const form = new FormData()
@@ -375,6 +381,7 @@ const postStatus = ({credentials, status, spoilerText, visibility, mediaIds, inR
form.append('source', 'Pleroma FE')
if (spoilerText) form.append('spoiler_text', spoilerText)
if (visibility) form.append('visibility', visibility)
+ if (sensitive) form.append('sensitive', sensitive)
form.append('media_ids', idsText)
if (inReplyToStatusId) {
form.append('in_reply_to_status_id', inReplyToStatusId)
@@ -449,6 +456,12 @@ const fetchMutes = ({credentials}) => {
}).then((data) => data.json())
}
+const suggestions = ({credentials}) => {
+ return fetch(SUGGESTIONS_URL, {
+ headers: authHeaders(credentials)
+ }).then((data) => data.json())
+}
+
const apiService = {
verifyCredentials,
fetchTimeline,
@@ -482,7 +495,8 @@ const apiService = {
changePassword,
fetchFollowRequests,
approveUser,
- denyUser
+ denyUser,
+ suggestions
}
export default apiService
diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js
index dbfb54f9..c84373ac 100644
--- a/src/services/backend_interactor_service/backend_interactor_service.js
+++ b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -54,6 +54,16 @@ const backendInteractorService = (credentials) => {
return timelineFetcherService.startFetching({timeline, store, credentials, userId})
}
+ const fetchOldPost = ({store, postId}) => {
+ return timelineFetcherService.fetchAndUpdate({
+ store,
+ credentials,
+ timeline: 'own',
+ older: true,
+ until: postId + 1
+ })
+ }
+
const setUserMute = ({id, muted = true}) => {
return apiService.setUserMute({id, muted, credentials})
}
@@ -86,6 +96,7 @@ const backendInteractorService = (credentials) => {
fetchAllFollowing,
verifyCredentials: apiService.verifyCredentials,
startFetching,
+ fetchOldPost,
setUserMute,
fetchMutes,
register,
diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js
new file mode 100644
index 00000000..1480cded
--- /dev/null
+++ b/src/services/notifications_fetcher/notifications_fetcher.service.js
@@ -0,0 +1,46 @@
+import apiService from '../api/api.service.js'
+
+const update = ({store, notifications, older}) => {
+ store.dispatch('setNotificationsError', { value: false })
+
+ store.dispatch('addNewNotifications', { notifications, older })
+}
+
+const fetchAndUpdate = ({store, credentials, older = false}) => {
+ const args = { credentials }
+ const rootState = store.rootState || store.state
+ const timelineData = rootState.statuses.notifications
+
+ if (older) {
+ if (timelineData.minId !== Number.POSITIVE_INFINITY) {
+ args['until'] = timelineData.minId
+ }
+ } else {
+ args['since'] = timelineData.maxId
+ }
+
+ args['timeline'] = 'notifications'
+
+ return apiService.fetchTimeline(args)
+ .then((notifications) => {
+ update({store, notifications, older})
+ }, () => store.dispatch('setNotificationsError', { value: true }))
+ .catch(() => store.dispatch('setNotificationsError', { value: true }))
+}
+
+const startFetching = ({credentials, store}) => {
+ fetchAndUpdate({ credentials, store })
+ const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
+ // Initially there's set flag to silence all desktop notifications so
+ // that there won't spam of them when user just opened up the FE we
+ // reset that flag after a while to show new notifications once again.
+ setTimeout(() => store.dispatch('setNotificationsSilence', false), 10000)
+ return setInterval(boundFetchAndUpdate, 10000)
+}
+
+const notificationsFetcher = {
+ fetchAndUpdate,
+ startFetching
+}
+
+export default notificationsFetcher
diff --git a/src/services/status_poster/status_poster.service.js b/src/services/status_poster/status_poster.service.js
index 3381e9e2..c3bbbaa3 100644
--- a/src/services/status_poster/status_poster.service.js
+++ b/src/services/status_poster/status_poster.service.js
@@ -1,10 +1,10 @@
import { map } from 'lodash'
import apiService from '../api/api.service.js'
-const postStatus = ({ store, status, spoilerText, visibility, media = [], inReplyToStatusId = undefined }) => {
+const postStatus = ({ store, status, spoilerText, visibility, sensitive, media = [], inReplyToStatusId = undefined }) => {
const mediaIds = map(media, 'id')
- return apiService.postStatus({credentials: store.state.users.currentUser.credentials, status, spoilerText, visibility, mediaIds, inReplyToStatusId})
+ return apiService.postStatus({credentials: store.state.users.currentUser.credentials, status, spoilerText, visibility, sensitive, mediaIds, inReplyToStatusId})
.then((data) => data.json())
.then((data) => {
if (!data.error) {
diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js
index bb5fdc2e..0e3e32d2 100644
--- a/src/services/timeline_fetcher/timeline_fetcher.service.js
+++ b/src/services/timeline_fetcher/timeline_fetcher.service.js
@@ -14,13 +14,13 @@ const update = ({store, statuses, timeline, showImmediately}) => {
})
}
-const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false, userId = false, tag = false}) => {
+const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false, userId = false, tag = false, until}) => {
const args = { timeline, credentials }
const rootState = store.rootState || store.state
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
if (older) {
- args['until'] = timelineData.minVisibleId
+ args['until'] = until || timelineData.minVisibleId
} else {
args['since'] = timelineData.maxId
}