Skip to content

Commit

Permalink
Merge remote-tracking branch 'glitch-soc/main' into merge/glitch/2024…
Browse files Browse the repository at this point in the history
…0812
  • Loading branch information
neatchee committed Aug 13, 2024
2 parents 893cee4 + 115fb0a commit 26fc7c4
Show file tree
Hide file tree
Showing 215 changed files with 2,260 additions and 3,501 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
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const IgnoreNotificationsModal = ({ filterType }) => {
<div className='safety-action-modal__bullet-points'>
<div>
<div className='safety-action-modal__bullet-points__icon'><Icon icon={InventoryIcon} /></div>
<div><FormattedMessage id='ignore_notifications_modal.filter_to_review_separately' defaultMessage='You can review filtered notifications speparately' /></div>
<div><FormattedMessage id='ignore_notifications_modal.filter_to_review_separately' defaultMessage='You can review filtered notifications separately' /></div>
</div>

<div>
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
6 changes: 3 additions & 3 deletions app/javascript/flavours/glitch/styles/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ $content-width: 840px;
background: $ui-base-color;
}

.fa-times {
.material-close {
display: none;
}

&.active {
.fa-times {
.material-close {
display: block;
}

.fa-bars {
.material-menu {
display: none;
}
}
Expand Down
16 changes: 12 additions & 4 deletions app/javascript/flavours/glitch/styles/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,17 @@ body > [data-popper-placement] {

&:hover,
&:focus,
&:active,
&:active {
background: var(--dropdown-border-color);

.autosuggest-account .display-name__account {
color: inherit;
}
}

&.selected {
background: $ui-highlight-color;
color: $primary-text-color;
color: $ui-button-color;

.autosuggest-account .display-name__account {
color: inherit;
Expand Down Expand Up @@ -465,7 +472,7 @@ body > [data-popper-placement] {
display: block;
line-height: 16px;
font-size: 12px;
color: $dark-text-color;
color: $ui-primary-color;
}
}

Expand Down Expand Up @@ -8531,7 +8538,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
4 changes: 4 additions & 0 deletions app/javascript/flavours/glitch/styles/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ code {
flex: 0;
}

.input.select.select--languages {
min-width: 32ch;
}

.required abbr {
text-decoration: none;
color: lighten($error-value-color, 12%);
Expand Down
10 changes: 6 additions & 4 deletions app/javascript/flavours/glitch/styles/mastodon-light/diff.scss
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 Expand Up @@ -630,3 +626,9 @@ a.sparkline {
.report-dialog-modal__textarea {
background: darken($ui-base-color, 10%);
}

.autosuggest-account {
.display-name__account {
color: $dark-text-color;
}
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const IgnoreNotificationsModal = ({ filterType }) => {
<div className='safety-action-modal__bullet-points'>
<div>
<div className='safety-action-modal__bullet-points__icon'><Icon icon={InventoryIcon} /></div>
<div><FormattedMessage id='ignore_notifications_modal.filter_to_review_separately' defaultMessage='You can review filtered notifications speparately' /></div>
<div><FormattedMessage id='ignore_notifications_modal.filter_to_review_separately' defaultMessage='You can review filtered notifications separately' /></div>
</div>

<div>
Expand Down
1 change: 0 additions & 1 deletion app/javascript/mastodon/locales/an.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@
"notification.admin.sign_up": "{name} se rechistró",
"notification.follow": "{name} t'empecipió a seguir",
"notification.follow_request": "{name} ha solicitau seguir-te",
"notification.mention": "{name} t'ha mencionau",
"notification.own_poll": "La tuya enqüesta ha rematau",
"notification.reblog": "{name} ha retutau la tuya publicación",
"notification.status": "{name} acaba de publicar",
Expand Down
2 changes: 0 additions & 2 deletions app/javascript/mastodon/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@
"notification.favourite": "أضاف {name} منشورك إلى مفضلته",
"notification.follow": "يتابعك {name}",
"notification.follow_request": "لقد طلب {name} متابعتك",
"notification.mention": "{name} ذكرك",
"notification.moderation-warning.learn_more": "اعرف المزيد",
"notification.moderation_warning": "لقد تلقيت تحذيرًا بالإشراف",
"notification.moderation_warning.action_delete_statuses": "تم إزالة بعض مشاركاتك.",
Expand Down Expand Up @@ -528,7 +527,6 @@
"notifications.policy.filter_not_following_title": "أشخاص لا تتابعهم",
"notifications.policy.filter_private_mentions_hint": "تمت تصفيته إلا إذا أن يكون ردًا على ذكرك أو إذا كنت تتابع الحساب",
"notifications.policy.filter_private_mentions_title": "إشارات خاصة غير مرغوب فيها",
"notifications.policy.title": "تصفية الإشعارات من…",
"notifications_permission_banner.enable": "تفعيل إشعارات سطح المكتب",
"notifications_permission_banner.how_to_control": "لتلقي الإشعارات عندما لا يكون ماستدون مفتوح، قم بتفعيل إشعارات سطح المكتب، يمكنك التحكم بدقة في أنواع التفاعلات التي تولد إشعارات سطح المكتب من خلال زر الـ{icon} أعلاه بمجرد تفعيلها.",
"notifications_permission_banner.title": "لا تفوت شيئاً أبداً",
Expand Down
Loading

0 comments on commit 26fc7c4

Please sign in to comment.