Merge pull request #2467 from ClearlyClaire/glitch-soc/cleanup
Misc cleanup and backports
This commit is contained in:
commit
7a877ae3d8
|
@ -106,7 +106,6 @@ export function fetchAccount(id) {
|
||||||
|
|
||||||
api(getState).get(`/api/v1/accounts/${id}`).then(response => {
|
api(getState).get(`/api/v1/accounts/${id}`).then(response => {
|
||||||
dispatch(importFetchedAccount(response.data));
|
dispatch(importFetchedAccount(response.data));
|
||||||
}).then(() => {
|
|
||||||
dispatch(fetchAccountSuccess());
|
dispatch(fetchAccountSuccess());
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
dispatch(fetchAccountFail(id, error));
|
dispatch(fetchAccountFail(id, error));
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
import api from '../api';
|
|
||||||
|
|
||||||
export const IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST = 'IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST';
|
|
||||||
export const IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS = 'IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS';
|
|
||||||
export const IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL = 'IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL';
|
|
||||||
|
|
||||||
export const fetchAccountIdentityProofs = accountId => (dispatch, getState) => {
|
|
||||||
dispatch(fetchAccountIdentityProofsRequest(accountId));
|
|
||||||
|
|
||||||
api(getState).get(`/api/v1/accounts/${accountId}/identity_proofs`)
|
|
||||||
.then(({ data }) => dispatch(fetchAccountIdentityProofsSuccess(accountId, data)))
|
|
||||||
.catch(err => dispatch(fetchAccountIdentityProofsFail(accountId, err)));
|
|
||||||
};
|
|
||||||
|
|
||||||
export const fetchAccountIdentityProofsRequest = id => ({
|
|
||||||
type: IDENTITY_PROOFS_ACCOUNT_FETCH_REQUEST,
|
|
||||||
id,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const fetchAccountIdentityProofsSuccess = (accountId, identity_proofs) => ({
|
|
||||||
type: IDENTITY_PROOFS_ACCOUNT_FETCH_SUCCESS,
|
|
||||||
accountId,
|
|
||||||
identity_proofs,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const fetchAccountIdentityProofsFail = (accountId, err) => ({
|
|
||||||
type: IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL,
|
|
||||||
accountId,
|
|
||||||
err,
|
|
||||||
skipNotFound: true,
|
|
||||||
});
|
|
|
@ -83,6 +83,7 @@ export function reblogRequest(status) {
|
||||||
return {
|
return {
|
||||||
type: REBLOG_REQUEST,
|
type: REBLOG_REQUEST,
|
||||||
status: status,
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +91,7 @@ export function reblogSuccess(status) {
|
||||||
return {
|
return {
|
||||||
type: REBLOG_SUCCESS,
|
type: REBLOG_SUCCESS,
|
||||||
status: status,
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +100,7 @@ export function reblogFail(status, error) {
|
||||||
type: REBLOG_FAIL,
|
type: REBLOG_FAIL,
|
||||||
status: status,
|
status: status,
|
||||||
error: error,
|
error: error,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +108,7 @@ export function unreblogRequest(status) {
|
||||||
return {
|
return {
|
||||||
type: UNREBLOG_REQUEST,
|
type: UNREBLOG_REQUEST,
|
||||||
status: status,
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +116,7 @@ export function unreblogSuccess(status) {
|
||||||
return {
|
return {
|
||||||
type: UNREBLOG_SUCCESS,
|
type: UNREBLOG_SUCCESS,
|
||||||
status: status,
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +125,7 @@ export function unreblogFail(status, error) {
|
||||||
type: UNREBLOG_FAIL,
|
type: UNREBLOG_FAIL,
|
||||||
status: status,
|
status: status,
|
||||||
error: error,
|
error: error,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +159,7 @@ export function favouriteRequest(status) {
|
||||||
return {
|
return {
|
||||||
type: FAVOURITE_REQUEST,
|
type: FAVOURITE_REQUEST,
|
||||||
status: status,
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +167,7 @@ export function favouriteSuccess(status) {
|
||||||
return {
|
return {
|
||||||
type: FAVOURITE_SUCCESS,
|
type: FAVOURITE_SUCCESS,
|
||||||
status: status,
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +176,7 @@ export function favouriteFail(status, error) {
|
||||||
type: FAVOURITE_FAIL,
|
type: FAVOURITE_FAIL,
|
||||||
status: status,
|
status: status,
|
||||||
error: error,
|
error: error,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +184,7 @@ export function unfavouriteRequest(status) {
|
||||||
return {
|
return {
|
||||||
type: UNFAVOURITE_REQUEST,
|
type: UNFAVOURITE_REQUEST,
|
||||||
status: status,
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,6 +192,7 @@ export function unfavouriteSuccess(status) {
|
||||||
return {
|
return {
|
||||||
type: UNFAVOURITE_SUCCESS,
|
type: UNFAVOURITE_SUCCESS,
|
||||||
status: status,
|
status: status,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,6 +201,7 @@ export function unfavouriteFail(status, error) {
|
||||||
type: UNFAVOURITE_FAIL,
|
type: UNFAVOURITE_FAIL,
|
||||||
status: status,
|
status: status,
|
||||||
error: error,
|
error: error,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,6 +456,7 @@ export function pinRequest(status) {
|
||||||
return {
|
return {
|
||||||
type: PIN_REQUEST,
|
type: PIN_REQUEST,
|
||||||
status,
|
status,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,6 +464,7 @@ export function pinSuccess(status) {
|
||||||
return {
|
return {
|
||||||
type: PIN_SUCCESS,
|
type: PIN_SUCCESS,
|
||||||
status,
|
status,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,6 +473,7 @@ export function pinFail(status, error) {
|
||||||
type: PIN_FAIL,
|
type: PIN_FAIL,
|
||||||
status,
|
status,
|
||||||
error,
|
error,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,6 +494,7 @@ export function unpinRequest(status) {
|
||||||
return {
|
return {
|
||||||
type: UNPIN_REQUEST,
|
type: UNPIN_REQUEST,
|
||||||
status,
|
status,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,6 +502,7 @@ export function unpinSuccess(status) {
|
||||||
return {
|
return {
|
||||||
type: UNPIN_SUCCESS,
|
type: UNPIN_SUCCESS,
|
||||||
status,
|
status,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,5 +511,6 @@ export function unpinFail(status, error) {
|
||||||
type: UNPIN_FAIL,
|
type: UNPIN_FAIL,
|
||||||
status,
|
status,
|
||||||
error,
|
error,
|
||||||
|
skipLoading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ defineMessages({
|
||||||
const fetchRelatedRelationships = (dispatch, notifications) => {
|
const fetchRelatedRelationships = (dispatch, notifications) => {
|
||||||
const accountIds = notifications.filter(item => ['follow', 'follow_request', 'admin.sign_up'].indexOf(item.type) !== -1).map(item => item.account.id);
|
const accountIds = notifications.filter(item => ['follow', 'follow_request', 'admin.sign_up'].indexOf(item.type) !== -1).map(item => item.account.id);
|
||||||
|
|
||||||
if (accountIds > 0) {
|
if (accountIds.length > 0) {
|
||||||
dispatch(fetchRelationships(accountIds));
|
dispatch(fetchRelationships(accountIds));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -131,6 +131,7 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
|
||||||
const body = (notification.status && notification.status.spoiler_text.length > 0) ? notification.status.spoiler_text : unescapeHTML(notification.status ? notification.status.content : '');
|
const body = (notification.status && notification.status.spoiler_text.length > 0) ? notification.status.spoiler_text : unescapeHTML(notification.status ? notification.status.content : '');
|
||||||
|
|
||||||
const notify = new Notification(title, { body, icon: notification.account.avatar, tag: notification.id });
|
const notify = new Notification(title, { body, icon: notification.account.avatar, tag: notification.id });
|
||||||
|
|
||||||
notify.addEventListener('click', () => {
|
notify.addEventListener('click', () => {
|
||||||
window.focus();
|
window.focus();
|
||||||
notify.close();
|
notify.close();
|
||||||
|
@ -141,7 +142,6 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
|
||||||
|
|
||||||
const excludeTypesFromSettings = state => state.getIn(['settings', 'notifications', 'shows']).filter(enabled => !enabled).keySeq().toJS();
|
const excludeTypesFromSettings = state => state.getIn(['settings', 'notifications', 'shows']).filter(enabled => !enabled).keySeq().toJS();
|
||||||
|
|
||||||
|
|
||||||
const excludeTypesFromFilter = filter => {
|
const excludeTypesFromFilter = filter => {
|
||||||
const allTypes = ImmutableList([
|
const allTypes = ImmutableList([
|
||||||
'follow',
|
'follow',
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import api from '../../api';
|
import api from '../../api';
|
||||||
|
import { me } from '../../initial_state';
|
||||||
import { pushNotificationsSetting } from '../../settings';
|
import { pushNotificationsSetting } from '../../settings';
|
||||||
|
import { decode as decodeBase64 } from '../../utils/base64';
|
||||||
|
|
||||||
import { setBrowserSupport, setSubscription, clearSubscription } from './setter';
|
import { setBrowserSupport, setSubscription, clearSubscription } from './setter';
|
||||||
|
|
||||||
|
@ -10,13 +12,7 @@ const urlBase64ToUint8Array = (base64String) => {
|
||||||
.replace(/-/g, '+')
|
.replace(/-/g, '+')
|
||||||
.replace(/_/g, '/');
|
.replace(/_/g, '/');
|
||||||
|
|
||||||
const rawData = window.atob(base64);
|
return decodeBase64(base64);
|
||||||
const outputArray = new Uint8Array(rawData.length);
|
|
||||||
|
|
||||||
for (let i = 0; i < rawData.length; ++i) {
|
|
||||||
outputArray[i] = rawData.charCodeAt(i);
|
|
||||||
}
|
|
||||||
return outputArray;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getApplicationServerKey = () => document.querySelector('[name="applicationServerKey"]').getAttribute('content');
|
const getApplicationServerKey = () => document.querySelector('[name="applicationServerKey"]').getAttribute('content');
|
||||||
|
@ -36,7 +32,7 @@ const subscribe = (registration) =>
|
||||||
const unsubscribe = ({ registration, subscription }) =>
|
const unsubscribe = ({ registration, subscription }) =>
|
||||||
subscription ? subscription.unsubscribe().then(() => registration) : registration;
|
subscription ? subscription.unsubscribe().then(() => registration) : registration;
|
||||||
|
|
||||||
const sendSubscriptionToBackend = (getState, subscription, me) => {
|
const sendSubscriptionToBackend = (subscription) => {
|
||||||
const params = { subscription };
|
const params = { subscription };
|
||||||
|
|
||||||
if (me) {
|
if (me) {
|
||||||
|
@ -46,7 +42,7 @@ const sendSubscriptionToBackend = (getState, subscription, me) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return api(getState).post('/api/web/push_subscriptions', params).then(response => response.data);
|
return api().post('/api/web/push_subscriptions', params).then(response => response.data);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Last one checks for payload support: https://web-push-book.gauntface.com/chapter-06/01-non-standards-browsers/#no-payload
|
// Last one checks for payload support: https://web-push-book.gauntface.com/chapter-06/01-non-standards-browsers/#no-payload
|
||||||
|
@ -55,7 +51,6 @@ const supportsPushNotifications = ('serviceWorker' in navigator && 'PushManager'
|
||||||
export function register () {
|
export function register () {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch(setBrowserSupport(supportsPushNotifications));
|
dispatch(setBrowserSupport(supportsPushNotifications));
|
||||||
const me = getState().getIn(['meta', 'me']);
|
|
||||||
|
|
||||||
if (supportsPushNotifications) {
|
if (supportsPushNotifications) {
|
||||||
if (!getApplicationServerKey()) {
|
if (!getApplicationServerKey()) {
|
||||||
|
@ -79,13 +74,13 @@ export function register () {
|
||||||
} else {
|
} else {
|
||||||
// Something went wrong, try to subscribe again
|
// Something went wrong, try to subscribe again
|
||||||
return unsubscribe({ registration, subscription }).then(subscribe).then(
|
return unsubscribe({ registration, subscription }).then(subscribe).then(
|
||||||
subscription => sendSubscriptionToBackend(getState, subscription, me));
|
subscription => sendSubscriptionToBackend(subscription));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No subscription, try to subscribe
|
// No subscription, try to subscribe
|
||||||
return subscribe(registration).then(
|
return subscribe(registration).then(
|
||||||
subscription => sendSubscriptionToBackend(getState, subscription, me));
|
subscription => sendSubscriptionToBackend(subscription));
|
||||||
})
|
})
|
||||||
.then(subscription => {
|
.then(subscription => {
|
||||||
// If we got a PushSubscription (and not a subscription object from the backend)
|
// If we got a PushSubscription (and not a subscription object from the backend)
|
||||||
|
@ -128,10 +123,9 @@ export function saveSettings() {
|
||||||
const alerts = state.get('alerts');
|
const alerts = state.get('alerts');
|
||||||
const data = { alerts };
|
const data = { alerts };
|
||||||
|
|
||||||
api(getState).put(`/api/web/push_subscriptions/${subscription.get('id')}`, {
|
api().put(`/api/web/push_subscriptions/${subscription.get('id')}`, {
|
||||||
data,
|
data,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
const me = getState().getIn(['meta', 'me']);
|
|
||||||
if (me) {
|
if (me) {
|
||||||
pushNotificationsSetting.set(me, data);
|
pushNotificationsSetting.set(me, data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ const debouncedSave = debounce((dispatch, getState) => {
|
||||||
|
|
||||||
const data = getState().get('settings').filter((_, path) => path !== 'saved').toJS();
|
const data = getState().get('settings').filter((_, path) => path !== 'saved').toJS();
|
||||||
|
|
||||||
api(getState).put('/api/web/settings', { data })
|
api().put('/api/web/settings', { data })
|
||||||
.then(() => dispatch({ type: SETTING_SAVE }))
|
.then(() => dispatch({ type: SETTING_SAVE }))
|
||||||
.catch(error => dispatch(showAlertForError(error)));
|
.catch(error => dispatch(showAlertForError(error)));
|
||||||
}, 5000, { trailing: true });
|
}, 5000, { trailing: true });
|
||||||
|
|
|
@ -67,8 +67,8 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
if (pollingId) {
|
if (pollingId) {
|
||||||
clearTimeout(pollingId);
|
// @ts-ignore
|
||||||
pollingId = null;
|
clearTimeout(pollingId); pollingId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.fillGaps) {
|
if (options.fillGaps) {
|
||||||
|
|
|
@ -67,7 +67,8 @@ const deleteFromContexts = (immutableState, ids) => immutableState.withMutations
|
||||||
});
|
});
|
||||||
|
|
||||||
const filterContexts = (state, relationship, statuses) => {
|
const filterContexts = (state, relationship, statuses) => {
|
||||||
const ownedStatusIds = statuses.filter(status => status.get('account') === relationship.id)
|
const ownedStatusIds = statuses
|
||||||
|
.filter(status => status.get('account') === relationship.id)
|
||||||
.map(status => status.get('id'));
|
.map(status => status.get('id'));
|
||||||
|
|
||||||
return deleteFromContexts(state, ownedStatusIds);
|
return deleteFromContexts(state, ownedStatusIds);
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import { fromJS, Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
import { fromJS, Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
|
import { DOMAIN_BLOCK_SUCCESS } from 'flavours/glitch/actions/domain_blocks';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ACCOUNT_BLOCK_SUCCESS,
|
ACCOUNT_BLOCK_SUCCESS,
|
||||||
ACCOUNT_MUTE_SUCCESS,
|
ACCOUNT_MUTE_SUCCESS,
|
||||||
FOLLOW_REQUEST_AUTHORIZE_SUCCESS,
|
FOLLOW_REQUEST_AUTHORIZE_SUCCESS,
|
||||||
FOLLOW_REQUEST_REJECT_SUCCESS,
|
FOLLOW_REQUEST_REJECT_SUCCESS,
|
||||||
} from '../actions/accounts';
|
} from '../actions/accounts';
|
||||||
import { DOMAIN_BLOCK_SUCCESS } from '../actions/domain_blocks';
|
|
||||||
import {
|
import {
|
||||||
MARKERS_FETCH_SUCCESS,
|
MARKERS_FETCH_SUCCESS,
|
||||||
} from '../actions/markers';
|
} from '../actions/markers';
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
// NB: This function can still return unsafe HTML
|
||||||
export const unescapeHTML = (html) => {
|
export const unescapeHTML = (html) => {
|
||||||
const wrapper = document.createElement('div');
|
const wrapper = document.createElement('div');
|
||||||
wrapper.innerHTML = html.replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n').replace(/<[^>]*>/g, '');
|
wrapper.innerHTML = html.replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n').replace(/<[^>]*>/g, '');
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Copied from emoji-mart for consistency with emoji picker and since
|
||||||
|
// they don't export the icons in the package
|
||||||
export const loupeIcon = (
|
export const loupeIcon = (
|
||||||
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' width='13' height='13'>
|
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' width='13' height='13'>
|
||||||
<path d='M12.9 14.32a8 8 0 1 1 1.41-1.41l5.35 5.33-1.42 1.42-5.33-5.34zM8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12z' />
|
<path d='M12.9 14.32a8 8 0 1 1 1.41-1.41l5.35 5.33-1.42 1.42-5.33-5.34zM8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12z' />
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
const checkNotificationPromise = () => {
|
const checkNotificationPromise = () => {
|
||||||
try {
|
try {
|
||||||
// eslint-disable-next-line promise/catch-or-return, promise/valid-params
|
// eslint-disable-next-line promise/valid-params, promise/catch-or-return
|
||||||
Notification.requestPermission().then();
|
Notification.requestPermission().then();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { ValueOf } from 'flavours/glitch/types/util';
|
import type { ValueOf } from '../types/util';
|
||||||
|
|
||||||
export const DECIMAL_UNITS = Object.freeze({
|
export const DECIMAL_UNITS = Object.freeze({
|
||||||
ONE: 1,
|
ONE: 1,
|
||||||
|
|
Loading…
Reference in New Issue