From 2f61b65b1ef721be58c481ef6e6de199a6d02f17 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 15 Nov 2023 12:20:22 +0100 Subject: [PATCH 1/9] Remove dead code --- .../glitch/actions/identity_proofs.js | 31 ------------------- 1 file changed, 31 deletions(-) delete mode 100644 app/javascript/flavours/glitch/actions/identity_proofs.js diff --git a/app/javascript/flavours/glitch/actions/identity_proofs.js b/app/javascript/flavours/glitch/actions/identity_proofs.js deleted file mode 100644 index 1039839566..0000000000 --- a/app/javascript/flavours/glitch/actions/identity_proofs.js +++ /dev/null @@ -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, -}); From 7b922c2d908af55789821bb3c8e0c9a552076da6 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 15 Nov 2023 12:24:59 +0100 Subject: [PATCH 2/9] Reduce unwarranted differences with upstream Ports part of 0758b00bfddf4a2c845d0d611e50717a268fd48a and 897199910fc29d17b4a019b6ee2473e138d777a2 --- .../actions/push_notifications/registerer.js | 22 +++++++------------ .../flavours/glitch/actions/settings.js | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/push_notifications/registerer.js b/app/javascript/flavours/glitch/actions/push_notifications/registerer.js index 336bbc6869..b3d3850e31 100644 --- a/app/javascript/flavours/glitch/actions/push_notifications/registerer.js +++ b/app/javascript/flavours/glitch/actions/push_notifications/registerer.js @@ -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'; @@ -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'); @@ -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) { @@ -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 @@ -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()) { @@ -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) @@ -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); } diff --git a/app/javascript/flavours/glitch/actions/settings.js b/app/javascript/flavours/glitch/actions/settings.js index 120ae133ed..3685b0684e 100644 --- a/app/javascript/flavours/glitch/actions/settings.js +++ b/app/javascript/flavours/glitch/actions/settings.js @@ -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 }); From 21653beb3060a4a5924f6c72d0243ec9c4b38848 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 15 Nov 2023 12:29:35 +0100 Subject: [PATCH 3/9] Reduce more unwarranted differences with upstream --- app/javascript/flavours/glitch/actions/accounts.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/javascript/flavours/glitch/actions/accounts.js b/app/javascript/flavours/glitch/actions/accounts.js index d4f18ff2d7..6d9544d651 100644 --- a/app/javascript/flavours/glitch/actions/accounts.js +++ b/app/javascript/flavours/glitch/actions/accounts.js @@ -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)); From 103c0ca4f771a128b508db0f838fdfdfda116717 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 13 Mar 2018 14:30:01 +0100 Subject: [PATCH 4/9] [Glitch] Hide loading bar on status interactions Port eb2425b53b08f71dca5a7f8fe020f720b122a448 to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/actions/interactions.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/javascript/flavours/glitch/actions/interactions.js b/app/javascript/flavours/glitch/actions/interactions.js index 095fb3155e..ebc7e8c50f 100644 --- a/app/javascript/flavours/glitch/actions/interactions.js +++ b/app/javascript/flavours/glitch/actions/interactions.js @@ -83,6 +83,7 @@ export function reblogRequest(status) { return { type: REBLOG_REQUEST, status: status, + skipLoading: true, }; } @@ -90,6 +91,7 @@ export function reblogSuccess(status) { return { type: REBLOG_SUCCESS, status: status, + skipLoading: true, }; } @@ -98,6 +100,7 @@ export function reblogFail(status, error) { type: REBLOG_FAIL, status: status, error: error, + skipLoading: true, }; } @@ -105,6 +108,7 @@ export function unreblogRequest(status) { return { type: UNREBLOG_REQUEST, status: status, + skipLoading: true, }; } @@ -112,6 +116,7 @@ export function unreblogSuccess(status) { return { type: UNREBLOG_SUCCESS, status: status, + skipLoading: true, }; } @@ -120,6 +125,7 @@ export function unreblogFail(status, error) { type: UNREBLOG_FAIL, status: status, error: error, + skipLoading: true, }; } @@ -153,6 +159,7 @@ export function favouriteRequest(status) { return { type: FAVOURITE_REQUEST, status: status, + skipLoading: true, }; } @@ -160,6 +167,7 @@ export function favouriteSuccess(status) { return { type: FAVOURITE_SUCCESS, status: status, + skipLoading: true, }; } @@ -168,6 +176,7 @@ export function favouriteFail(status, error) { type: FAVOURITE_FAIL, status: status, error: error, + skipLoading: true, }; } @@ -175,6 +184,7 @@ export function unfavouriteRequest(status) { return { type: UNFAVOURITE_REQUEST, status: status, + skipLoading: true, }; } @@ -182,6 +192,7 @@ export function unfavouriteSuccess(status) { return { type: UNFAVOURITE_SUCCESS, status: status, + skipLoading: true, }; } @@ -190,6 +201,7 @@ export function unfavouriteFail(status, error) { type: UNFAVOURITE_FAIL, status: status, error: error, + skipLoading: true, }; } @@ -444,6 +456,7 @@ export function pinRequest(status) { return { type: PIN_REQUEST, status, + skipLoading: true, }; } @@ -451,6 +464,7 @@ export function pinSuccess(status) { return { type: PIN_SUCCESS, status, + skipLoading: true, }; } @@ -459,6 +473,7 @@ export function pinFail(status, error) { type: PIN_FAIL, status, error, + skipLoading: true, }; } @@ -479,6 +494,7 @@ export function unpinRequest(status) { return { type: UNPIN_REQUEST, status, + skipLoading: true, }; } @@ -486,6 +502,7 @@ export function unpinSuccess(status) { return { type: UNPIN_SUCCESS, status, + skipLoading: true, }; } @@ -494,5 +511,6 @@ export function unpinFail(status, error) { type: UNPIN_FAIL, status, error, + skipLoading: true, }; } From 08ac91c40ba63b487674fb1a00197036580d7611 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 12 Mar 2018 03:20:56 +0100 Subject: [PATCH 5/9] [Glitch] Fix follow relationships not loading after notifications fetch Port 4f7f6b3922436e7fad352e5835f2ecdc44568d7b to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/actions/notifications.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/flavours/glitch/actions/notifications.js b/app/javascript/flavours/glitch/actions/notifications.js index 9a04b43408..c31ac520ac 100644 --- a/app/javascript/flavours/glitch/actions/notifications.js +++ b/app/javascript/flavours/glitch/actions/notifications.js @@ -65,7 +65,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)); } }; From b1f0457cb815b145763485ec681aa52bd910c2bc Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 15 Nov 2023 12:40:52 +0100 Subject: [PATCH 6/9] Fix whitespace and comment discrepancies --- app/javascript/flavours/glitch/actions/notifications.js | 2 +- app/javascript/flavours/glitch/actions/streaming.js | 8 ++++---- app/javascript/flavours/glitch/utils/html.js | 1 + app/javascript/flavours/glitch/utils/icons.jsx | 2 ++ app/javascript/flavours/glitch/utils/notifications.js | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/notifications.js b/app/javascript/flavours/glitch/actions/notifications.js index c31ac520ac..e98b843863 100644 --- a/app/javascript/flavours/glitch/actions/notifications.js +++ b/app/javascript/flavours/glitch/actions/notifications.js @@ -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 notify = new Notification(title, { body, icon: notification.account.avatar, tag: notification.id }); + notify.addEventListener('click', () => { window.focus(); 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 excludeTypesFromFilter = filter => { const allTypes = ImmutableList([ 'follow', diff --git a/app/javascript/flavours/glitch/actions/streaming.js b/app/javascript/flavours/glitch/actions/streaming.js index 9ae13a4716..d8341a5c16 100644 --- a/app/javascript/flavours/glitch/actions/streaming.js +++ b/app/javascript/flavours/glitch/actions/streaming.js @@ -67,8 +67,8 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti // @ts-expect-error if (pollingId) { - clearTimeout(pollingId); - pollingId = null; + // @ts-ignore + clearTimeout(pollingId); pollingId = null; } if (options.fillGaps) { @@ -85,8 +85,8 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti } }, - onReceive (data) { - switch(data.event) { + onReceive(data) { + switch (data.event) { case 'update': // @ts-expect-error dispatch(updateTimeline(timelineId, JSON.parse(data.payload), options.accept)); diff --git a/app/javascript/flavours/glitch/utils/html.js b/app/javascript/flavours/glitch/utils/html.js index 5159df9db7..247e98c88a 100644 --- a/app/javascript/flavours/glitch/utils/html.js +++ b/app/javascript/flavours/glitch/utils/html.js @@ -1,3 +1,4 @@ +// NB: This function can still return unsafe HTML export const unescapeHTML = (html) => { const wrapper = document.createElement('div'); wrapper.innerHTML = html.replace(//g, '\n').replace(/<\/p>

/g, '\n\n').replace(/<[^>]*>/g, ''); diff --git a/app/javascript/flavours/glitch/utils/icons.jsx b/app/javascript/flavours/glitch/utils/icons.jsx index 225345af68..be566032e0 100644 --- a/app/javascript/flavours/glitch/utils/icons.jsx +++ b/app/javascript/flavours/glitch/utils/icons.jsx @@ -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 = ( diff --git a/app/javascript/flavours/glitch/utils/notifications.js b/app/javascript/flavours/glitch/utils/notifications.js index 3cdf7caea0..42623ac7c6 100644 --- a/app/javascript/flavours/glitch/utils/notifications.js +++ b/app/javascript/flavours/glitch/utils/notifications.js @@ -3,7 +3,7 @@ const checkNotificationPromise = () => { 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(); } catch(e) { return false; From 8b24a9a507b19c931e9c4050b58e73a932a60a0d Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 15 Nov 2023 12:41:53 +0100 Subject: [PATCH 7/9] Fix missed relative import discrepancy --- app/javascript/flavours/glitch/utils/numbers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/flavours/glitch/utils/numbers.ts b/app/javascript/flavours/glitch/utils/numbers.ts index 7139bf8039..35bcde83e2 100644 --- a/app/javascript/flavours/glitch/utils/numbers.ts +++ b/app/javascript/flavours/glitch/utils/numbers.ts @@ -1,4 +1,4 @@ -import type { ValueOf } from 'flavours/glitch/types/util'; +import type { ValueOf } from '../types/util'; export const DECIMAL_UNITS = Object.freeze({ ONE: 1, From 542d95c2bc5df2edccb04fc8ddb838a5fca6dede Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 15 Nov 2023 12:45:45 +0100 Subject: [PATCH 8/9] Fix import style discrepancy --- app/javascript/flavours/glitch/reducers/notifications.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/javascript/flavours/glitch/reducers/notifications.js b/app/javascript/flavours/glitch/reducers/notifications.js index 4415c778bb..7bb11459ca 100644 --- a/app/javascript/flavours/glitch/reducers/notifications.js +++ b/app/javascript/flavours/glitch/reducers/notifications.js @@ -1,12 +1,13 @@ import { fromJS, Map as ImmutableMap, List as ImmutableList } from 'immutable'; +import { DOMAIN_BLOCK_SUCCESS } from 'flavours/glitch/actions/domain_blocks'; + import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS, FOLLOW_REQUEST_AUTHORIZE_SUCCESS, FOLLOW_REQUEST_REJECT_SUCCESS, } from '../actions/accounts'; -import { DOMAIN_BLOCK_SUCCESS } from '../actions/domain_blocks'; import { MARKERS_FETCH_SUCCESS, } from '../actions/markers'; From 3b210e093ad4c40dc14dca9f49116f0b4fea2ce2 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 15 Nov 2023 12:52:50 +0100 Subject: [PATCH 9/9] Fix more code style discrepancies --- app/javascript/flavours/glitch/reducers/contexts.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/javascript/flavours/glitch/reducers/contexts.js b/app/javascript/flavours/glitch/reducers/contexts.js index 73c13db918..32e194dd42 100644 --- a/app/javascript/flavours/glitch/reducers/contexts.js +++ b/app/javascript/flavours/glitch/reducers/contexts.js @@ -67,7 +67,8 @@ const deleteFromContexts = (immutableState, ids) => immutableState.withMutations }); 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')); return deleteFromContexts(state, ownedStatusIds);