mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2025-01-02 21:13:44 +01:00
Merge remote-tracking branch 'upstream/main' into develop
This commit is contained in:
commit
e333716df0
1 changed files with 11 additions and 7 deletions
|
@ -162,7 +162,9 @@ const deleteByStatus = (state, statusId) => {
|
||||||
|
|
||||||
const markForDelete = (state, notificationId, yes) => {
|
const markForDelete = (state, notificationId, yes) => {
|
||||||
return state.update('items', list => list.map(item => {
|
return state.update('items', list => list.map(item => {
|
||||||
if(item.get('id') === notificationId) {
|
if (item === null) {
|
||||||
|
return null;
|
||||||
|
} else if(item.get('id') === notificationId) {
|
||||||
return item.set('markedForDelete', yes);
|
return item.set('markedForDelete', yes);
|
||||||
} else {
|
} else {
|
||||||
return item;
|
return item;
|
||||||
|
@ -172,7 +174,9 @@ const markForDelete = (state, notificationId, yes) => {
|
||||||
|
|
||||||
const markAllForDelete = (state, yes) => {
|
const markAllForDelete = (state, yes) => {
|
||||||
return state.update('items', list => list.map(item => {
|
return state.update('items', list => list.map(item => {
|
||||||
if(yes !== null) {
|
if (item === null) {
|
||||||
|
return null;
|
||||||
|
} else if(yes !== null) {
|
||||||
return item.set('markedForDelete', yes);
|
return item.set('markedForDelete', yes);
|
||||||
} else {
|
} else {
|
||||||
return item.set('markedForDelete', !item.get('markedForDelete'));
|
return item.set('markedForDelete', !item.get('markedForDelete'));
|
||||||
|
@ -181,11 +185,11 @@ const markAllForDelete = (state, yes) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const unmarkAllForDelete = (state) => {
|
const unmarkAllForDelete = (state) => {
|
||||||
return state.update('items', list => list.map(item => item.set('markedForDelete', false)));
|
return state.update('items', list => list.map(item => item === null ? item : item.set('markedForDelete', false)));
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteMarkedNotifs = (state) => {
|
const deleteMarkedNotifs = (state) => {
|
||||||
return state.update('items', list => list.filterNot(item => item.get('markedForDelete')));
|
return state.update('items', list => list.filterNot(item => item === null ? item : item.get('markedForDelete')));
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateMounted = (state) => {
|
const updateMounted = (state) => {
|
||||||
|
@ -249,10 +253,10 @@ export default function notifications(state = initialState, action) {
|
||||||
return state.update('items', list => state.get('pendingItems').concat(list.take(40))).set('pendingItems', ImmutableList()).set('unread', 0);
|
return state.update('items', list => state.get('pendingItems').concat(list.take(40))).set('pendingItems', ImmutableList()).set('unread', 0);
|
||||||
case NOTIFICATIONS_EXPAND_REQUEST:
|
case NOTIFICATIONS_EXPAND_REQUEST:
|
||||||
case NOTIFICATIONS_DELETE_MARKED_REQUEST:
|
case NOTIFICATIONS_DELETE_MARKED_REQUEST:
|
||||||
return state.set('isLoading', (nbLoading) => nbLoading + 1);
|
return state.update('isLoading', (nbLoading) => nbLoading + 1);
|
||||||
case NOTIFICATIONS_DELETE_MARKED_FAIL:
|
case NOTIFICATIONS_DELETE_MARKED_FAIL:
|
||||||
case NOTIFICATIONS_EXPAND_FAIL:
|
case NOTIFICATIONS_EXPAND_FAIL:
|
||||||
return state.set('isLoading', (nbLoading) => nbLoading - 1);
|
return state.update('isLoading', (nbLoading) => nbLoading - 1);
|
||||||
case NOTIFICATIONS_FILTER_SET:
|
case NOTIFICATIONS_FILTER_SET:
|
||||||
return state.set('items', ImmutableList()).set('hasMore', true);
|
return state.set('items', ImmutableList()).set('hasMore', true);
|
||||||
case NOTIFICATIONS_SCROLL_TOP:
|
case NOTIFICATIONS_SCROLL_TOP:
|
||||||
|
@ -287,7 +291,7 @@ export default function notifications(state = initialState, action) {
|
||||||
return markForDelete(state, action.id, action.yes);
|
return markForDelete(state, action.id, action.yes);
|
||||||
|
|
||||||
case NOTIFICATIONS_DELETE_MARKED_SUCCESS:
|
case NOTIFICATIONS_DELETE_MARKED_SUCCESS:
|
||||||
return deleteMarkedNotifs(state).set('isLoading', (nbLoading) => nbLoading - 1);
|
return deleteMarkedNotifs(state).update('isLoading', (nbLoading) => nbLoading - 1);
|
||||||
|
|
||||||
case NOTIFICATIONS_ENTER_CLEARING_MODE:
|
case NOTIFICATIONS_ENTER_CLEARING_MODE:
|
||||||
st = state.set('cleaningMode', action.yes);
|
st = state.set('cleaningMode', action.yes);
|
||||||
|
|
Loading…
Reference in a new issue