From 2c9930bd5b5c1279e0890aeba673ad6b5ce2af18 Mon Sep 17 00:00:00 2001 From: NEETzsche Date: Thu, 9 Nov 2023 15:03:21 -0700 Subject: Display the latest scrobble under a user's name --- src/services/api/api.service.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/services/api/api.service.js') diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index c6bca10b..f45e3958 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -107,6 +107,7 @@ const PLEROMA_ANNOUNCEMENTS_URL = '/api/v1/pleroma/admin/announcements' const PLEROMA_POST_ANNOUNCEMENT_URL = '/api/v1/pleroma/admin/announcements' const PLEROMA_EDIT_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}` const PLEROMA_DELETE_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}` +const PLEROMA_SCROBBLES_URL = id => `/api/v1/pleroma/accounts/${id}/scrobbles` const PLEROMA_ADMIN_CONFIG_URL = '/api/pleroma/admin/config' const PLEROMA_ADMIN_DESCRIPTIONS_URL = '/api/pleroma/admin/config/descriptions' @@ -1765,6 +1766,23 @@ const installFrontend = ({ credentials, payload }) => { }) } +const fetchScrobbles = ({ accountId, limit = 1 }) => { + let url = PLEROMA_SCROBBLES_URL(accountId) + const params = [['limit', limit]] + const queryString = map(params, (param) => `${param[0]}=${param[1]}`).join('&') + url += `?${queryString}` + return fetch(url, {}) + .then((response) => { + if (response.ok) { + return response.json() + } else { + return { + error: response + } + } + }) +} + const apiService = { verifyCredentials, fetchTimeline, @@ -1878,6 +1896,7 @@ const apiService = { postAnnouncement, editAnnouncement, deleteAnnouncement, + fetchScrobbles, adminFetchAnnouncements, fetchInstanceDBConfig, fetchInstanceConfigDescriptions, -- cgit v1.2.3-70-g09d2 From e36548579fb179d0431591529158a65f85e5b134 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 21 Nov 2023 15:26:31 +0200 Subject: fix notifications not catching up with "read" status as intended --- changelog.d/unreads-sync.fix | 1 + src/services/api/api.service.js | 4 ++++ .../notifications_fetcher/notifications_fetcher.service.js | 8 +++++--- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 changelog.d/unreads-sync.fix (limited to 'src/services/api/api.service.js') diff --git a/changelog.d/unreads-sync.fix b/changelog.d/unreads-sync.fix new file mode 100644 index 00000000..1eac3364 --- /dev/null +++ b/changelog.d/unreads-sync.fix @@ -0,0 +1 @@ +unread notifications should now properly catch up (eventually) in polling mode diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index f45e3958..bde2e163 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -671,6 +671,7 @@ const fetchTimeline = ({ timeline, credentials, since = false, + minId = false, until = false, userId = false, listId = false, @@ -705,6 +706,9 @@ const fetchTimeline = ({ url = url(listId) } + if (minId) { + params.push(['min_id', minId]) + } if (since) { params.push(['since_id', since]) } diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index 3c280b74..21540845 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -49,9 +49,11 @@ const fetchAndUpdate = ({ store, credentials, older = false, since }) => { // The normal maxId-check does not tell if older notifications have changed const notifications = timelineData.data const readNotifsIds = notifications.filter(n => n.seen).map(n => n.id) - const numUnseenNotifs = notifications.length - readNotifsIds.length - if (numUnseenNotifs > 0 && readNotifsIds.length > 0) { - args.since = Math.max(...readNotifsIds) + const unreadNotifsIds = notifications.filter(n => !n.seen).map(n => n.id) + if (readNotifsIds.length > 0 && readNotifsIds.length > 0) { + const minId = Math.min(...unreadNotifsIds) // Oldest known unread notification + args.since = false // Don't use since_id since it sorta conflicts with min_id + args.minId = minId - 1 // go beyond fetchNotifications({ store, args, older }) } -- cgit v1.2.3-70-g09d2 From f9c85c0c491fa800054250a814978e6f8fcc439a Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Thu, 21 Dec 2023 00:16:16 +0300 Subject: Initial incomplete admin emoji settings implementation --- .../settings_modal/admin_tabs/emoji_tab.js | 62 ++++++++++++ .../settings_modal/admin_tabs/emoji_tab.scss | 24 +++++ .../settings_modal/admin_tabs/emoji_tab.vue | 93 ++++++++++++++++++ .../settings_modal/settings_modal_admin_content.js | 4 +- .../settings_modal_admin_content.vue | 8 ++ src/i18n/en.json | 7 +- src/services/api/api.service.js | 108 ++++++++++++++++++++- 7 files changed, 303 insertions(+), 3 deletions(-) create mode 100644 src/components/settings_modal/admin_tabs/emoji_tab.js create mode 100644 src/components/settings_modal/admin_tabs/emoji_tab.scss create mode 100644 src/components/settings_modal/admin_tabs/emoji_tab.vue (limited to 'src/services/api/api.service.js') diff --git a/src/components/settings_modal/admin_tabs/emoji_tab.js b/src/components/settings_modal/admin_tabs/emoji_tab.js new file mode 100644 index 00000000..f9d3b24e --- /dev/null +++ b/src/components/settings_modal/admin_tabs/emoji_tab.js @@ -0,0 +1,62 @@ +import TabSwitcher from 'src/components/tab_switcher/tab_switcher.jsx' +import StringSetting from '../helpers/string_setting.vue' +import Checkbox from 'components/checkbox/checkbox.vue' +import StillImage from 'components/still-image/still-image.vue' + +const EmojiTab = { + components: { + TabSwitcher, + StringSetting, + Checkbox, + StillImage + }, + + data () { + return { + knownPacks: { }, + editedParts: { } + } + }, + + methods: { + reloadEmoji () { + this.$store.state.api.backendInteractor.reloadEmoji() + }, + importFromFS () { + this.$store.state.api.backendInteractor.importEmojiFromFS() + }, + emojiAddr (packName, name) { + return `${this.$store.state.instance.server}/emoji/${encodeURIComponent(packName)}/${name}` + }, + editEmoji (packName, shortcode) { + if (this.editedParts[packName] === undefined) { this.editedParts[packName] = {} } + + this.editedParts[packName][shortcode] = { + shortcode, file: this.knownPacks[packName].files[shortcode] + } + }, + saveEditedEmoji (packName, shortcode) { + const edited = this.editedParts[packName][shortcode] + + this.$store.state.api.backendInteractor.updateEmojiFile( + { packName, shortcode, newShortcode: edited.shortcode, newFilename: edited.file, force: false } + ).then(resp => + resp.ok ? resp.json() : resp.text().then(respText => Promise.reject(respText)) + ).then(resp => { + this.knownPacks[packName].files = resp + delete this.editedParts[packName][shortcode] + }) + } + }, + + mounted () { + this.$store.state.api.backendInteractor.listEmojiPacks() + .then(data => data.json()) + .then(packData => { + this.knownPacks = packData.packs + console.log(this.knownPacks) + }) + } +} + +export default EmojiTab diff --git a/src/components/settings_modal/admin_tabs/emoji_tab.scss b/src/components/settings_modal/admin_tabs/emoji_tab.scss new file mode 100644 index 00000000..397580af --- /dev/null +++ b/src/components/settings_modal/admin_tabs/emoji_tab.scss @@ -0,0 +1,24 @@ +.emoji-tab { + .btn-group .btn { + margin-left: 0.5em; + } + + .pack-info-wrapper { + margin-top: 1em; + } + + .emoji-info-input { + width: 100%; + } + + .emoji-data-input { + width: 40%; + margin-left: 0.5em; + margin-right: 0.5em; + } + + .emoji { + width: 32px; + height: 32px; + } +} diff --git a/src/components/settings_modal/admin_tabs/emoji_tab.vue b/src/components/settings_modal/admin_tabs/emoji_tab.vue new file mode 100644 index 00000000..699e4afe --- /dev/null +++ b/src/components/settings_modal/admin_tabs/emoji_tab.vue @@ -0,0 +1,93 @@ +