mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-20 05:44:01 +00:00
[Glitch] Fix quickly switching notification filters resulting in empty or incorrect list
Port 55bef1e34f
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
43a1bfd05d
commit
d99f91bceb
|
@ -153,16 +153,23 @@ const excludeTypesFromFilter = filter => {
|
||||||
|
|
||||||
const noOp = () => {};
|
const noOp = () => {};
|
||||||
|
|
||||||
|
let expandNotificationsController = new AbortController();
|
||||||
|
|
||||||
export function expandNotifications({ maxId, forceLoad } = {}, done = noOp) {
|
export function expandNotifications({ maxId, forceLoad } = {}, done = noOp) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const activeFilter = getState().getIn(['settings', 'notifications', 'quickFilter', 'active']);
|
const activeFilter = getState().getIn(['settings', 'notifications', 'quickFilter', 'active']);
|
||||||
const notifications = getState().get('notifications');
|
const notifications = getState().get('notifications');
|
||||||
const isLoadingMore = !!maxId;
|
const isLoadingMore = !!maxId;
|
||||||
|
|
||||||
if (notifications.get('isLoading') && !forceLoad) {
|
if (notifications.get('isLoading')) {
|
||||||
|
if (forceLoad) {
|
||||||
|
expandNotificationsController.abort();
|
||||||
|
expandNotificationsController = new AbortController();
|
||||||
|
} else {
|
||||||
done();
|
done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
max_id: maxId,
|
max_id: maxId,
|
||||||
|
@ -186,7 +193,7 @@ export function expandNotifications({ maxId, forceLoad } = {}, done = noOp) {
|
||||||
|
|
||||||
dispatch(expandNotificationsRequest(isLoadingMore));
|
dispatch(expandNotificationsRequest(isLoadingMore));
|
||||||
|
|
||||||
api(getState).get('/api/v1/notifications', { params }).then(response => {
|
api(getState).get('/api/v1/notifications', { params, signal: expandNotificationsController.signal }).then(response => {
|
||||||
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
const next = getLinks(response).refs.find(link => link.rel === 'next');
|
||||||
|
|
||||||
dispatch(importFetchedAccounts(response.data.map(item => item.account)));
|
dispatch(importFetchedAccounts(response.data.map(item => item.account)));
|
||||||
|
@ -227,7 +234,7 @@ export function expandNotificationsFail(error, isLoadingMore) {
|
||||||
type: NOTIFICATIONS_EXPAND_FAIL,
|
type: NOTIFICATIONS_EXPAND_FAIL,
|
||||||
error,
|
error,
|
||||||
skipLoading: !isLoadingMore,
|
skipLoading: !isLoadingMore,
|
||||||
skipAlert: !isLoadingMore,
|
skipAlert: !isLoadingMore || error.name === 'AbortError',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue