Skip to content

Commit

Permalink
Merge latest upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
Ember committed Nov 20, 2023
2 parents ac0d471 + c34a3a8 commit 6a62caa
Show file tree
Hide file tree
Showing 191 changed files with 1,275 additions and 694 deletions.
1 change: 0 additions & 1 deletion app/javascript/flavours/glitch/actions/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export function fetchAccount(id) {

api(getState).get(`/api/v1/accounts/${id}`).then(response => {
dispatch(importFetchedAccount(response.data));
}).then(() => {
dispatch(fetchAccountSuccess());
}).catch(error => {
dispatch(fetchAccountFail(id, error));
Expand Down
31 changes: 0 additions & 31 deletions app/javascript/flavours/glitch/actions/identity_proofs.js

This file was deleted.

6 changes: 3 additions & 3 deletions app/javascript/flavours/glitch/actions/importer/normalizer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import escapeTextContentForBrowser from 'escape-html';

import emojify from 'flavours/glitch/features/emoji/emoji';
import { autoHideCW } from 'flavours/glitch/utils/content_warning';
import { unescapeHTML } from 'flavours/glitch/utils/html';
import emojify from '../../features/emoji/emoji';
import { autoHideCW } from '../../utils/content_warning';
import { unescapeHTML } from '../../utils/html';

const domParser = new DOMParser();

Expand Down
28 changes: 24 additions & 4 deletions app/javascript/flavours/glitch/actions/interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ export function reblogRequest(status) {
return {
type: REBLOG_REQUEST,
status: status,
skipLoading: true,
};
}

export function reblogSuccess(status) {
return {
type: REBLOG_SUCCESS,
status: status,
skipLoading: true,
};
}

Expand All @@ -108,20 +110,23 @@ export function reblogFail(status, error) {
type: REBLOG_FAIL,
status: status,
error: error,
skipLoading: true,
};
}

export function unreblogRequest(status) {
return {
type: UNREBLOG_REQUEST,
status: status,
skipLoading: true,
};
}

export function unreblogSuccess(status) {
return {
type: UNREBLOG_SUCCESS,
status: status,
skipLoading: true,
};
}

Expand All @@ -130,6 +135,7 @@ export function unreblogFail(status, error) {
type: UNREBLOG_FAIL,
status: status,
error: error,
skipLoading: true,
};
}

Expand Down Expand Up @@ -163,13 +169,15 @@ export function favouriteRequest(status) {
return {
type: FAVOURITE_REQUEST,
status: status,
skipLoading: true,
};
}

export function favouriteSuccess(status) {
return {
type: FAVOURITE_SUCCESS,
status: status,
skipLoading: true,
};
}

Expand All @@ -178,20 +186,23 @@ export function favouriteFail(status, error) {
type: FAVOURITE_FAIL,
status: status,
error: error,
skipLoading: true,
};
}

export function unfavouriteRequest(status) {
return {
type: UNFAVOURITE_REQUEST,
status: status,
skipLoading: true,
};
}

export function unfavouriteSuccess(status) {
return {
type: UNFAVOURITE_SUCCESS,
status: status,
skipLoading: true,
};
}

Expand All @@ -200,6 +211,7 @@ export function unfavouriteFail(status, error) {
type: UNFAVOURITE_FAIL,
status: status,
error: error,
skipLoading: true,
};
}

Expand All @@ -209,7 +221,7 @@ export function bookmark(status) {

api(getState).post(`/api/v1/statuses/${status.get('id')}/bookmark`).then(function (response) {
dispatch(importFetchedStatus(response.data));
dispatch(bookmarkSuccess(status));
dispatch(bookmarkSuccess(status, response.data));
}).catch(function (error) {
dispatch(bookmarkFail(status, error));
});
Expand All @@ -222,7 +234,7 @@ export function unbookmark(status) {

api(getState).post(`/api/v1/statuses/${status.get('id')}/unbookmark`).then(response => {
dispatch(importFetchedStatus(response.data));
dispatch(unbookmarkSuccess(status));
dispatch(unbookmarkSuccess(status, response.data));
}).catch(error => {
dispatch(unbookmarkFail(status, error));
});
Expand All @@ -236,10 +248,11 @@ export function bookmarkRequest(status) {
};
}

export function bookmarkSuccess(status) {
export function bookmarkSuccess(status, response) {
return {
type: BOOKMARK_SUCCESS,
status: status,
response: response,
};
}

Expand All @@ -258,10 +271,11 @@ export function unbookmarkRequest(status) {
};
}

export function unbookmarkSuccess(status) {
export function unbookmarkSuccess(status, response) {
return {
type: UNBOOKMARK_SUCCESS,
status: status,
response: response,
};
}

Expand Down Expand Up @@ -454,13 +468,15 @@ export function pinRequest(status) {
return {
type: PIN_REQUEST,
status,
skipLoading: true,
};
}

export function pinSuccess(status) {
return {
type: PIN_SUCCESS,
status,
skipLoading: true,
};
}

Expand All @@ -469,6 +485,7 @@ export function pinFail(status, error) {
type: PIN_FAIL,
status,
error,
skipLoading: true,
};
}

Expand All @@ -489,13 +506,15 @@ export function unpinRequest(status) {
return {
type: UNPIN_REQUEST,
status,
skipLoading: true,
};
}

export function unpinSuccess(status) {
return {
type: UNPIN_SUCCESS,
status,
skipLoading: true,
};
}

Expand All @@ -504,6 +523,7 @@ export function unpinFail(status, error) {
type: UNPIN_FAIL,
status,
error,
skipLoading: true,
};
}

Expand Down
3 changes: 1 addition & 2 deletions app/javascript/flavours/glitch/actions/mutes.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { openModal } from 'flavours/glitch/actions/modal';

import api, { getLinks } from '../api';

import { fetchRelationships } from './accounts';
import { importFetchedAccounts } from './importer';
import { openModal } from './modal';

export const MUTES_FETCH_REQUEST = 'MUTES_FETCH_REQUEST';
export const MUTES_FETCH_SUCCESS = 'MUTES_FETCH_SUCCESS';
Expand Down
13 changes: 5 additions & 8 deletions app/javascript/flavours/glitch/actions/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { List as ImmutableList } from 'immutable';

import { compareId } from 'flavours/glitch/compare_id';
import { usePendingItems as preferPendingItems } from 'flavours/glitch/initial_state';
import { unescapeHTML } from 'flavours/glitch/utils/html';
import { requestNotificationPermission } from 'flavours/glitch/utils/notifications';

import api, { getLinks } from '../api';
import { unescapeHTML } from '../utils/html';
import { requestNotificationPermission } from '../utils/notifications';

import { fetchFollowRequests, fetchRelationships } from './accounts';
import {
Expand All @@ -21,10 +21,7 @@ import { submitMarkers } from './markers';
import { register as registerPushNotifications } from './push_notifications';
import { saveSettings } from './settings';




export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';

// tracking the notif cleaning request
Expand Down Expand Up @@ -65,7 +62,7 @@ defineMessages({
const fetchRelatedRelationships = (dispatch, notifications) => {
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));
}
};
Expand Down Expand Up @@ -131,6 +128,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 notify = new Notification(title, { body, icon: notification.account.avatar, tag: notification.id });

notify.addEventListener('click', () => {
window.focus();
notify.close();
Expand All @@ -141,7 +139,6 @@ export function updateNotifications(notification, intlMessages, intlLocale) {

const excludeTypesFromSettings = state => state.getIn(['settings', 'notifications', 'shows']).filter(enabled => !enabled).keySeq().toJS();


const excludeTypesFromFilter = filter => {
const allTypes = ImmutableList([
'follow',
Expand Down
4 changes: 1 addition & 3 deletions app/javascript/flavours/glitch/actions/pin_statuses.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { me } from 'flavours/glitch/initial_state';

import api from '../api';
import { me } from '../initial_state';

import { importFetchedStatuses } from './importer';


export const PINNED_STATUSES_FETCH_REQUEST = 'PINNED_STATUSES_FETCH_REQUEST';
export const PINNED_STATUSES_FETCH_SUCCESS = 'PINNED_STATUSES_FETCH_SUCCESS';
export const PINNED_STATUSES_FETCH_FAIL = 'PINNED_STATUSES_FETCH_FAIL';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import api from '../../api';
import { me } from '../../initial_state';
import { pushNotificationsSetting } from '../../settings';
import { decode as decodeBase64 } from '../../utils/base64';

import { setBrowserSupport, setSubscription, clearSubscription } from './setter';

Expand All @@ -10,13 +12,7 @@ const urlBase64ToUint8Array = (base64String) => {
.replace(/-/g, '+')
.replace(/_/g, '/');

const rawData = window.atob(base64);
const outputArray = new Uint8Array(rawData.length);

for (let i = 0; i < rawData.length; ++i) {
outputArray[i] = rawData.charCodeAt(i);
}
return outputArray;
return decodeBase64(base64);
};

const getApplicationServerKey = () => document.querySelector('[name="applicationServerKey"]').getAttribute('content');
Expand All @@ -36,7 +32,7 @@ const subscribe = (registration) =>
const unsubscribe = ({ registration, subscription }) =>
subscription ? subscription.unsubscribe().then(() => registration) : registration;

const sendSubscriptionToBackend = (getState, subscription, me) => {
const sendSubscriptionToBackend = (subscription) => {
const params = { subscription };

if (me) {
Expand All @@ -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
Expand All @@ -55,7 +51,6 @@ const supportsPushNotifications = ('serviceWorker' in navigator && 'PushManager'
export function register () {
return (dispatch, getState) => {
dispatch(setBrowserSupport(supportsPushNotifications));
const me = getState().getIn(['meta', 'me']);

if (supportsPushNotifications) {
if (!getApplicationServerKey()) {
Expand All @@ -79,13 +74,13 @@ export function register () {
} else {
// Something went wrong, try to subscribe again
return unsubscribe({ registration, subscription }).then(subscribe).then(
subscription => sendSubscriptionToBackend(getState, subscription, me));
subscription => sendSubscriptionToBackend(subscription));
}
}

// No subscription, try to subscribe
return subscribe(registration).then(
subscription => sendSubscriptionToBackend(getState, subscription, me));
subscription => sendSubscriptionToBackend(subscription));
})
.then(subscription => {
// If we got a PushSubscription (and not a subscription object from the backend)
Expand Down Expand Up @@ -128,10 +123,9 @@ export function saveSettings() {
const alerts = state.get('alerts');
const data = { alerts };

api(getState).put(`/api/web/push_subscriptions/${subscription.get('id')}`, {
api().put(`/api/web/push_subscriptions/${subscription.get('id')}`, {
data,
}).then(() => {
const me = getState().getIn(['meta', 'me']);
if (me) {
pushNotificationsSetting.set(me, data);
}
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/flavours/glitch/actions/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const debouncedSave = debounce((dispatch, getState) => {

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 }))
.catch(error => dispatch(showAlertForError(error)));
}, 5000, { trailing: true });
Expand Down
Loading

0 comments on commit 6a62caa

Please sign in to comment.