Merge remote-tracking branch 'parent/main' into upstream-20240906

This commit is contained in:
KMY 2024-09-06 08:42:24 +09:00
commit f18eabfe75
689 changed files with 4369 additions and 2434 deletions

View file

@ -283,8 +283,9 @@ function processNewNotification(
}
function trimNotifications(state: NotificationGroupsState) {
if (state.scrolledToTop) {
if (state.scrolledToTop && state.groups.length > NOTIFICATIONS_TRIM_LIMIT) {
state.groups.splice(NOTIFICATIONS_TRIM_LIMIT);
ensureTrailingGap(state.groups);
}
}
@ -435,6 +436,28 @@ function ensureLeadingGap(
}
}
// Ensure the groups list ends with a gap suitable for loading more, mutating it to append one if needed
function ensureTrailingGap(
groups: NotificationGroupsState['groups'],
): NotificationGap {
const groupOrGap = groups.at(-1);
if (groupOrGap?.type === 'gap') {
// We're expecting older notifications, so discard sinceId if it's set
groupOrGap.sinceId = undefined;
return groupOrGap;
} else {
const gap: NotificationGap = {
type: 'gap',
maxId: groupOrGap?.page_min_id,
};
groups.push(gap);
return gap;
}
}
export const notificationGroupsReducer = createReducer<NotificationGroupsState>(
initialState,
(builder) => {

View file

@ -5,8 +5,8 @@ import { BOOKMARK_CATEGORY_DELETE_SUCCESS, BOOKMARK_CATEGORY_FETCH_FAIL } from '
import { CIRCLE_DELETE_SUCCESS, CIRCLE_FETCH_FAIL } from 'mastodon/actions/circles';
import { COLUMN_ADD, COLUMN_REMOVE, COLUMN_MOVE, COLUMN_PARAMS_CHANGE } from '../actions/columns';
import { COMPOSE_LANGUAGE_CHANGE } from '../actions/compose';
import { EMOJI_USE } from '../actions/emojis';
import { LANGUAGE_USE } from '../actions/languages';
import { LIST_DELETE_SUCCESS, LIST_FETCH_FAIL } from '../actions/lists';
import { NOTIFICATIONS_FILTER_SET } from '../actions/notifications';
import { SETTING_CHANGE, SETTING_SAVE } from '../actions/settings';
@ -194,7 +194,7 @@ export default function settings(state = initialState, action) {
return changeColumnParams(state, action.uuid, action.path, action.value);
case EMOJI_USE:
return updateFrequentEmojis(state, action.emoji);
case LANGUAGE_USE:
case COMPOSE_LANGUAGE_CHANGE:
return updateFrequentLanguages(state, action.language);
case SETTING_SAVE:
return state.set('saved', true);