kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Pleroma: mark notifications read in case Markers don't work
rodzic
dbf410e34c
commit
e04a488ea4
|
@ -19,6 +19,7 @@ import {
|
||||||
import { unescapeHTML } from '../utils/html';
|
import { unescapeHTML } from '../utils/html';
|
||||||
import { getFilters, regexFromFilters } from '../selectors';
|
import { getFilters, regexFromFilters } from '../selectors';
|
||||||
import { isLoggedIn } from 'soapbox/utils/auth';
|
import { isLoggedIn } from 'soapbox/utils/auth';
|
||||||
|
import { parseVersion, PLEROMA } from 'soapbox/utils/features';
|
||||||
|
|
||||||
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
|
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
|
||||||
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';
|
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';
|
||||||
|
@ -284,13 +285,23 @@ export function setFilter(filterType) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Of course Markers don't work properly in Pleroma.
|
||||||
|
// https://git.pleroma.social/pleroma/pleroma/-/issues/2769
|
||||||
|
export function markReadPleroma(max_id) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
return api(getState).post('/api/v1/pleroma/notifications/read', { max_id });
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function markReadNotifications() {
|
export function markReadNotifications() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
if (!isLoggedIn(getState)) return;
|
if (!isLoggedIn(getState)) return;
|
||||||
|
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
const instance = state.get('instance');
|
||||||
const topNotificationId = state.getIn(['notifications', 'items'], ImmutableOrderedMap()).first(ImmutableMap()).get('id');
|
const topNotificationId = state.getIn(['notifications', 'items'], ImmutableOrderedMap()).first(ImmutableMap()).get('id');
|
||||||
const lastReadId = state.getIn(['notifications', 'lastRead']);
|
const lastReadId = state.getIn(['notifications', 'lastRead']);
|
||||||
|
const v = parseVersion(instance.get('version'));
|
||||||
|
|
||||||
if (!(topNotificationId && topNotificationId > lastReadId)) return;
|
if (!(topNotificationId && topNotificationId > lastReadId)) return;
|
||||||
|
|
||||||
|
@ -301,5 +312,9 @@ export function markReadNotifications() {
|
||||||
};
|
};
|
||||||
|
|
||||||
dispatch(saveMarker(marker));
|
dispatch(saveMarker(marker));
|
||||||
|
|
||||||
|
if (v.software === PLEROMA) {
|
||||||
|
dispatch(markReadPleroma(topNotificationId));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import { createSelector } from 'reselect';
|
||||||
const any = arr => arr.some(Boolean);
|
const any = arr => arr.some(Boolean);
|
||||||
|
|
||||||
// For uglification
|
// For uglification
|
||||||
const MASTODON = 'Mastodon';
|
export const MASTODON = 'Mastodon';
|
||||||
const PLEROMA = 'Pleroma';
|
export const PLEROMA = 'Pleroma';
|
||||||
|
|
||||||
export const getFeatures = createSelector([
|
export const getFeatures = createSelector([
|
||||||
instance => parseVersion(instance.get('version')),
|
instance => parseVersion(instance.get('version')),
|
||||||
|
|
Ładowanie…
Reference in New Issue