Skip to content

Commit

Permalink
Merge pull request #2811 from ClearlyClaire/glitch-soc/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream changes up to b42661b
  • Loading branch information
ClearlyClaire authored Aug 12, 2024
2 parents 9edf98c + 8426c20 commit 115fb0a
Show file tree
Hide file tree
Showing 28 changed files with 259 additions and 38 deletions.
27 changes: 26 additions & 1 deletion app/javascript/flavours/glitch/actions/notification_groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type { NotificationGap } from 'flavours/glitch/reducers/notification_grou
import {
selectSettingsNotificationsExcludedTypes,
selectSettingsNotificationsQuickFilterActive,
selectSettingsNotificationsShows,
} from 'flavours/glitch/selectors/settings';
import type { AppDispatch } from 'flavours/glitch/store';
import {
Expand Down Expand Up @@ -104,7 +105,31 @@ export const fetchNotificationsGap = createDataLoadingThunk(

export const processNewNotificationForGroups = createAppAsyncThunk(
'notificationGroups/processNew',
(notification: ApiNotificationJSON, { dispatch }) => {
(notification: ApiNotificationJSON, { dispatch, getState }) => {
const state = getState();
const activeFilter = selectSettingsNotificationsQuickFilterActive(state);
const notificationShows = selectSettingsNotificationsShows(state);

const showInColumn =
activeFilter === 'all'
? notificationShows[notification.type]
: activeFilter === notification.type;

if (!showInColumn) return;

if (
(notification.type === 'mention' || notification.type === 'update') &&
notification.status.filtered
) {
const filters = notification.status.filtered.filter((result) =>
result.filter.context.includes('notifications'),
);

if (filters.some((result) => result.filter.filter_action === 'hide')) {
return;
}
}

dispatchAssociatedRecords(dispatch, [notification]);

return notification;
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/flavours/glitch/actions/streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
const notificationJSON = JSON.parse(data.payload);
dispatch(updateNotifications(notificationJSON, messages, locale));
// TODO: remove this once the groups feature replaces the previous one
if(getState().notificationGroups.groups.length > 0) {
if(getState().settings.getIn(['notifications', 'groupingBeta'], false)) {
dispatch(processNewNotificationForGroups(notificationJSON));
}
break;
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/flavours/glitch/api/notification_policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { apiRequestGet, apiRequestPut } from 'flavours/glitch/api';
import type { NotificationPolicyJSON } from 'flavours/glitch/api_types/notification_policies';

export const apiGetNotificationPolicy = () =>
apiRequestGet<NotificationPolicyJSON>('/v2/notifications/policy');
apiRequestGet<NotificationPolicyJSON>('v2/notifications/policy');

export const apiUpdateNotificationsPolicy = (
policy: Partial<NotificationPolicyJSON>,
) => apiRequestPut<NotificationPolicyJSON>('/v2/notifications/policy', policy);
) => apiRequestPut<NotificationPolicyJSON>('v2/notifications/policy', policy);
26 changes: 24 additions & 2 deletions app/javascript/flavours/glitch/api_types/statuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,29 @@ export interface ApiPreviewCardJSON {
authors: ApiPreviewCardAuthorJSON[];
}

export type FilterContext =
| 'home'
| 'notifications'
| 'public'
| 'thread'
| 'account';

export interface ApiFilterJSON {
id: string;
title: string;
context: FilterContext;
expires_at: string;
filter_action: 'warn' | 'hide';
keywords?: unknown[]; // TODO: FilterKeywordSerializer
statuses?: unknown[]; // TODO: FilterStatusSerializer
}

export interface ApiFilterResultJSON {
filter: ApiFilterJSON;
keyword_matches: string[];
status_matches: string[];
}

export interface ApiStatusJSON {
id: string;
created_at: string;
Expand All @@ -80,8 +103,7 @@ export interface ApiStatusJSON {
bookmarked?: boolean;
pinned?: boolean;

// filtered: FilterResult[]
filtered: unknown; // TODO
filtered?: ApiFilterResultJSON[];
content?: string;
text?: string;

Expand Down
14 changes: 8 additions & 6 deletions app/javascript/flavours/glitch/reducers/notification_groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,14 @@ export const notificationGroupsReducer = createReducer<NotificationGroupsState>(
})
.addCase(processNewNotificationForGroups.fulfilled, (state, action) => {
const notification = action.payload;
processNewNotification(
usePendingItems ? state.pendingGroups : state.groups,
notification,
);
updateLastReadId(state);
trimNotifications(state);
if (notification) {
processNewNotification(
usePendingItems ? state.pendingGroups : state.groups,
notification,
);
updateLastReadId(state);
trimNotifications(state);
}
})
.addCase(disconnectTimeline, (state, action) => {
if (action.payload.timeline === 'home') {
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/flavours/glitch/styles/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8521,7 +8521,8 @@ noscript {

.account__avatar {
background: var(--background-color);
border: 2px solid var(--background-border-color);
border: 1px solid var(--background-border-color);
border-radius: 4px;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ html {
color: darken($action-button-color, 25%);
}

.account__header__bar .avatar .account__avatar {
border-color: $white;
}

.getting-started__footer a {
color: $ui-secondary-color;
text-decoration: underline;
Expand Down
37 changes: 37 additions & 0 deletions app/javascript/flavours/glitch/styles/reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,40 @@ table {
html {
scrollbar-color: lighten($ui-base-color, 4%) rgba($base-overlay-background, 0.1);
}

::-webkit-scrollbar {
width: 12px;
height: 12px;
}

::-webkit-scrollbar-thumb {
background: lighten($ui-base-color, 4%);
border: 0px none $base-border-color;
border-radius: 50px;
}

::-webkit-scrollbar-thumb:hover {
background: lighten($ui-base-color, 6%);
}

::-webkit-scrollbar-thumb:active {
background: lighten($ui-base-color, 4%);
}

::-webkit-scrollbar-track {
border: 0px none $base-border-color;
border-radius: 0;
background: rgba($base-overlay-background, 0.1);
}

::-webkit-scrollbar-track:hover {
background: $ui-base-color;
}

::-webkit-scrollbar-track:active {
background: $ui-base-color;
}

::-webkit-scrollbar-corner {
background: transparent;
}
27 changes: 26 additions & 1 deletion app/javascript/mastodon/actions/notification_groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type { NotificationGap } from 'mastodon/reducers/notification_groups';
import {
selectSettingsNotificationsExcludedTypes,
selectSettingsNotificationsQuickFilterActive,
selectSettingsNotificationsShows,
} from 'mastodon/selectors/settings';
import type { AppDispatch } from 'mastodon/store';
import {
Expand Down Expand Up @@ -104,7 +105,31 @@ export const fetchNotificationsGap = createDataLoadingThunk(

export const processNewNotificationForGroups = createAppAsyncThunk(
'notificationGroups/processNew',
(notification: ApiNotificationJSON, { dispatch }) => {
(notification: ApiNotificationJSON, { dispatch, getState }) => {
const state = getState();
const activeFilter = selectSettingsNotificationsQuickFilterActive(state);
const notificationShows = selectSettingsNotificationsShows(state);

const showInColumn =
activeFilter === 'all'
? notificationShows[notification.type]
: activeFilter === notification.type;

if (!showInColumn) return;

if (
(notification.type === 'mention' || notification.type === 'update') &&
notification.status.filtered
) {
const filters = notification.status.filtered.filter((result) =>
result.filter.context.includes('notifications'),
);

if (filters.some((result) => result.filter.filter_action === 'hide')) {
return;
}
}

dispatchAssociatedRecords(dispatch, [notification]);

return notification;
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/actions/streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
const notificationJSON = JSON.parse(data.payload);
dispatch(updateNotifications(notificationJSON, messages, locale));
// TODO: remove this once the groups feature replaces the previous one
if(getState().notificationGroups.groups.length > 0) {
if(getState().settings.getIn(['notifications', 'groupingBeta'], false)) {
dispatch(processNewNotificationForGroups(notificationJSON));
}
break;
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/api/notification_policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { apiRequestGet, apiRequestPut } from 'mastodon/api';
import type { NotificationPolicyJSON } from 'mastodon/api_types/notification_policies';

export const apiGetNotificationPolicy = () =>
apiRequestGet<NotificationPolicyJSON>('/v2/notifications/policy');
apiRequestGet<NotificationPolicyJSON>('v2/notifications/policy');

export const apiUpdateNotificationsPolicy = (
policy: Partial<NotificationPolicyJSON>,
) => apiRequestPut<NotificationPolicyJSON>('/v2/notifications/policy', policy);
) => apiRequestPut<NotificationPolicyJSON>('v2/notifications/policy', policy);
26 changes: 24 additions & 2 deletions app/javascript/mastodon/api_types/statuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,29 @@ export interface ApiPreviewCardJSON {
authors: ApiPreviewCardAuthorJSON[];
}

export type FilterContext =
| 'home'
| 'notifications'
| 'public'
| 'thread'
| 'account';

export interface ApiFilterJSON {
id: string;
title: string;
context: FilterContext;
expires_at: string;
filter_action: 'warn' | 'hide';
keywords?: unknown[]; // TODO: FilterKeywordSerializer
statuses?: unknown[]; // TODO: FilterStatusSerializer
}

export interface ApiFilterResultJSON {
filter: ApiFilterJSON;
keyword_matches: string[];
status_matches: string[];
}

export interface ApiStatusJSON {
id: string;
created_at: string;
Expand All @@ -80,8 +103,7 @@ export interface ApiStatusJSON {
bookmarked?: boolean;
pinned?: boolean;

// filtered: FilterResult[]
filtered: unknown; // TODO
filtered?: ApiFilterResultJSON[];
content?: string;
text?: string;

Expand Down
9 changes: 9 additions & 0 deletions app/javascript/mastodon/locales/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,16 @@
"home.pending_critical_update.link": "Veure actualitzacions",
"home.pending_critical_update.title": "Actualització de seguretat crítica disponible!",
"home.show_announcements": "Mostra els anuncis",
"ignore_notifications_modal.disclaimer": "Mastodon no pot informar als usuaris de que heu ignorat notificacions seves.\nIgnorar notificacions no evitarà que se segueixin enviant els missatges.",
"ignore_notifications_modal.filter_to_act_users": "Encara podreu acceptar, rebutjar o reportar usuaris",
"ignore_notifications_modal.filter_to_avoid_confusion": "Filtrar ajuda a evitar potencials confusions",
"ignore_notifications_modal.filter_to_review_separately": "Podeu revisar separadament notificacions filtrades",
"ignore_notifications_modal.ignore": "Ignora les notificacions",
"ignore_notifications_modal.limited_accounts_title": "Voleu ignorar les notificacions dels comptes moderats?",
"ignore_notifications_modal.new_accounts_title": "Voleu ignorar les notificacions dels comptes nous?",
"ignore_notifications_modal.not_followers_title": "Voleu ignorar les notificacions de qui no us segueix?",
"ignore_notifications_modal.not_following_title": "Voleu ignorar les notificacions de qui no seguiu?",
"ignore_notifications_modal.private_mentions_title": "Voleu ignorar les notificacions de mencions privades no sol·licitades?",
"interaction_modal.description.favourite": "Amb un compte a Mastodon pots afavorir aquest tut perquè l'autor sàpiga que t'ha agradat i desar-lo per a més endavant.",
"interaction_modal.description.follow": "Amb un compte a Mastodon, pots seguir a {name} per a rebre els seus tuts en la teva línia de temps d'Inici.",
"interaction_modal.description.reblog": "Amb un compte a Mastodon, pots impulsar aquest tut per a compartir-lo amb els teus seguidors.",
Expand Down Expand Up @@ -514,6 +522,7 @@
"notification_requests.confirm_accept_all.button": "Accepta-ho tot",
"notification_requests.confirm_accept_all.message": "Esteu a punt d'acceptar {count, plural, one {una petició de notificació} other {# peticions de notificació}}. N'esteu segurs de continuar?",
"notification_requests.confirm_accept_all.title": "Accepteu peticions de notificació?",
"notification_requests.confirm_dismiss_all.button": "Descarta-les totes",
"notification_requests.dismiss": "Ignora",
"notification_requests.explainer_for_limited_account": "S'han filtrat les notificacions d'aquest compte perquè un moderador l'ha limitat.",
"notification_requests.explainer_for_limited_remote_account": "S'han filtrat les notificacions d'aquest compte perquè un moderador ha limitat el compte o el seu servidor.",
Expand Down
13 changes: 13 additions & 0 deletions app/javascript/mastodon/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"about.not_available": "Эта информация не указана на данном сервере.",
"about.powered_by": "Децентрализованная социальная сеть на базе {mastodon}",
"about.rules": "Правила сервера",
"account.account_note_header": "Личная заметка",
"account.add_or_remove_from_list": "Управление списками",
"account.badges.bot": "Бот",
"account.badges.group": "Группа",
Expand Down Expand Up @@ -167,19 +168,25 @@
"confirmations.block.confirm": "Заблокировать",
"confirmations.delete.confirm": "Удалить",
"confirmations.delete.message": "Вы уверены, что хотите удалить этот пост?",
"confirmations.delete.title": "Удалить пост?",
"confirmations.delete_list.confirm": "Удалить",
"confirmations.delete_list.message": "Вы действительно хотите навсегда удалить этот список?",
"confirmations.delete_list.title": "Удалить список?",
"confirmations.discard_edit_media.confirm": "Отменить",
"confirmations.discard_edit_media.message": "У вас есть несохранённые изменения описания мультимедиа или предпросмотра, отменить их?",
"confirmations.edit.confirm": "Редактировать",
"confirmations.edit.message": "В данный момент, редактирование перезапишет составляемое вами сообщение. Вы уверены, что хотите продолжить?",
"confirmations.edit.title": "Переписать сообщение?",
"confirmations.logout.confirm": "Выйти",
"confirmations.logout.message": "Вы уверены, что хотите выйти?",
"confirmations.logout.title": "Выйти?",
"confirmations.mute.confirm": "Игнорировать",
"confirmations.redraft.confirm": "Удалить и исправить",
"confirmations.redraft.message": "Вы уверены, что хотите удалить и переписать этот пост? Отметки «избранного», продвижения и ответы к оригинальному посту будут удалены.",
"confirmations.redraft.title": "Удалим и исправим пост?",
"confirmations.reply.confirm": "Ответить",
"confirmations.reply.message": "При ответе, текст набираемого поста будет очищен. Продолжить?",
"confirmations.reply.title": "Перепишем пост?",
"confirmations.unfollow.confirm": "Отписаться",
"confirmations.unfollow.message": "Вы уверены, что хотите отписаться от {name}?",
"conversation.delete": "Удалить беседу",
Expand Down Expand Up @@ -484,13 +491,16 @@
"notification.update": "{name} изменил(а) пост",
"notification_requests.accept": "Принять",
"notification_requests.dismiss": "Отклонить",
"notification_requests.maximize": "Развернуть",
"notification_requests.notifications_from": "Уведомления от {name}",
"notification_requests.title": "Отфильтрованные уведомления",
"notifications.clear": "Очистить уведомления",
"notifications.clear_confirmation": "Вы уверены, что хотите очистить все уведомления?",
"notifications.clear_title": "Сбросить уведомления?",
"notifications.column_settings.admin.report": "Новые жалобы:",
"notifications.column_settings.admin.sign_up": "Новые регистрации:",
"notifications.column_settings.alert": "Уведомления на рабочем столе",
"notifications.column_settings.beta.category": "Экспериментальные функции",
"notifications.column_settings.favourite": "Избранные:",
"notifications.column_settings.filter_bar.advanced": "Отображать все категории",
"notifications.column_settings.filter_bar.category": "Панель сортировки",
Expand Down Expand Up @@ -519,6 +529,7 @@
"notifications.permission_denied": "Уведомления на рабочем столе недоступны, так как вы запретили их отправку в браузере. Проверьте настройки для сайта, чтобы включить их обратно.",
"notifications.permission_denied_alert": "Уведомления на рабочем столе недоступны, так как вы ранее отклонили запрос на их отправку.",
"notifications.permission_required": "Чтобы включить уведомления на рабочем столе, необходимо разрешить их в браузере.",
"notifications.policy.drop": "Игнорируем",
"notifications.policy.filter_new_accounts.hint": "Создано в течение последних {days, plural, one {один день} few {# дней} many {# дней} other {# дня}}",
"notifications.policy.filter_new_accounts_title": "Новые учётные записи",
"notifications.policy.filter_not_followers_title": "Люди, не подписанные на вас",
Expand Down Expand Up @@ -652,8 +663,10 @@
"report.unfollow_explanation": "Вы подписаны на этого пользователя. Чтобы не видеть его/её посты в своей домашней ленте, отпишитесь от него/неё.",
"report_notification.attached_statuses": "{count, plural, one {{count} сообщение} few {{count} сообщения} many {{count} сообщений} other {{count} сообщений}} вложено",
"report_notification.categories.legal": "Правовая информация",
"report_notification.categories.legal_sentence": "срамной контент",
"report_notification.categories.other": "Прочее",
"report_notification.categories.spam": "Спам",
"report_notification.categories.spam_sentence": "спам",
"report_notification.categories.violation": "Нарушение правил",
"report_notification.open": "Открыть жалобу",
"search.no_recent_searches": "Недавние запросы отсутствуют",
Expand Down
Loading

0 comments on commit 115fb0a

Please sign in to comment.