Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .callstack.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
# yaml-language-server: $schema=https://storage.googleapis.com/config-schema/schema.v2.json

pr_review:
modules:
bug_hunter:
enabled: true
suggestions: true

code_suggestions:
enabled: false

code_conventions:
enabled: false
conventions: |
Exported code should be defined before internal code.

description:
enabled: true
diagram: true

grammar:
enabled: true

performance:
enabled: true

security:
enabled: true

exclude:
- "**/go.*"
33 changes: 33 additions & 0 deletions .github/workflows/reviewer.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
name: Cal PR Review

on:
workflow_dispatch:
inputs:
config:
type: string
description: "config for reviewer"
required: true
head:
type: string
description: "head commit sha"
required: true
base:
type: string
description: "base commit sha"
required: false
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.head }}

- name: Run reviewer
uses: addnab/docker-run-action@v3
with:
image: callstackai/cal:latest
options: -v ${{ github.workspace }}:/code
run: |
/reviewer --dir /code --id ${{ github.run_id }} --token ${{ github.token }} --config "${{ inputs.config }}"
50 changes: 3 additions & 47 deletions .rubocop_todo.yml
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.63.5.
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.64.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand DownExpand Up@@ -55,7 +55,6 @@ Style/FetchEnvVar:
- 'config/initializers/vapid.rb'
- 'lib/mastodon/redis_config.rb'
- 'lib/tasks/repo.rake'
- 'spec/system/profile_spec.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
Expand All@@ -66,40 +65,10 @@ Style/FormatStringToken:
- 'config/initializers/devise.rb'
- 'lib/paperclip/color_extractor.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'config/environments/development.rb'
- 'config/environments/production.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
Exclude:
- 'app/lib/activitypub/activity/block.rb'
- 'app/lib/request.rb'
- 'app/lib/request_pool.rb'
- 'app/lib/webfinger.rb'
- 'app/lib/webfinger_resource.rb'
- 'app/models/concerns/account/counters.rb'
- 'app/models/concerns/user/ldap_authenticable.rb'
- 'app/models/tag.rb'
- 'app/models/user.rb'
- 'app/services/fan_out_on_write_service.rb'
- 'app/services/post_status_service.rb'
- 'app/services/process_hashtags_service.rb'
- 'app/workers/move_worker.rb'
- 'app/workers/redownload_avatar_worker.rb'
- 'app/workers/redownload_header_worker.rb'
- 'app/workers/redownload_media_worker.rb'
- 'app/workers/remote_account_refresh_worker.rb'
- 'config/initializers/devise.rb'
- 'lib/devise/strategies/two_factor_ldap_authenticatable.rb'
- 'lib/devise/strategies/two_factor_pam_authenticatable.rb'
- 'lib/mastodon/cli/accounts.rb'
- 'lib/mastodon/cli/maintenance.rb'
- 'lib/mastodon/cli/media.rb'
- 'lib/tasks/repo.rake'
Enabled: false

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashTransformValues:
Expand All@@ -121,16 +90,10 @@ Style/MutableConstant:
- 'app/services/delete_account_service.rb'
- 'lib/mastodon/migration_warning.rb'

# This cop supports safe autocorrection (--autocorrect).
Style/NilLambda:
Exclude:
- 'config/initializers/paperclip.rb'

# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'app/helpers/admin/account_moderation_notes_helper.rb'
- 'app/helpers/jsonld_helper.rb'
- 'app/lib/admin/system_check/message.rb'
- 'app/lib/request.rb'
Expand All@@ -154,13 +117,6 @@ Style/RedundantConstantBase:
- 'config/environments/production.rb'
- 'config/initializers/sidekiq.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'app/models/concerns/account/finder_concern.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: WordRegex.
# SupportedStyles: percent, brackets
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2_alpha/notifications_controller.rb
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@ def index
@relationships = StatusRelationshipsPresenter.new(target_statuses_from_notifications, current_user&.account_id)
end

render json: @notifications.map { |notification| NotificationGroup.from_notification(notification) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
render json: @notifications.map { |notification| NotificationGroup.from_notification(notification, max_id: @group_metadata.dig(notification.group_key, :max_id)) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/actions/streaming.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
},

onDisconnect() {
dispatch(disconnectTimeline(timelineId));
dispatch(disconnectTimeline({ timeline: timelineId }));

if (options.fallback) {
// @ts-expect-error
Expand Down
21 changes: 5 additions & 16 deletions app/javascript/mastodon/actions/timelines.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,9 +6,11 @@ import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

import { importFetchedStatus, importFetchedStatuses } from './importer';
import { submitMarkers } from './markers';
import {timelineDelete} from './timelines_typed';

export { disconnectTimeline } from './timelines_typed';

export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
export const TIMELINE_CLEAR = 'TIMELINE_CLEAR';

export const TIMELINE_EXPAND_REQUEST = 'TIMELINE_EXPAND_REQUEST';
Expand All@@ -17,7 +19,6 @@ export const TIMELINE_EXPAND_FAIL = 'TIMELINE_EXPAND_FAIL';

export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
export const TIMELINE_LOAD_PENDING = 'TIMELINE_LOAD_PENDING';
export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
export const TIMELINE_CONNECT = 'TIMELINE_CONNECT';

export const TIMELINE_MARK_AS_PARTIAL = 'TIMELINE_MARK_AS_PARTIAL';
Expand DownExpand Up@@ -62,16 +63,10 @@ export function updateTimeline(timeline, status, accept) {
export function deleteFromTimelines(id) {
return (dispatch, getState) => {
const accountId = getState().getIn(['statuses', id, 'account']);
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id'));
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id')).toText();
const reblogOf = getState().getIn(['statuses', id, 'reblog'], null);

dispatch({
type: TIMELINE_DELETE,
id,
accountId,
references,
reblogOf,
});
dispatch(timelineDelete(id, accountId, reference, reblogOf));
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
};
}

Expand DownExpand Up@@ -225,12 +220,6 @@ export function connectTimeline(timeline) {
};
}

export const disconnectTimeline = timeline => ({
type: TIMELINE_DISCONNECT,
timeline,
usePendingItems: preferPendingItems,
});

export const markAsPartial = timeline => ({
type: TIMELINE_MARK_AS_PARTIAL,
timeline,
Expand Down
20 changes: 20 additions & 0 deletions app/javascript/mastodon/actions/timelines_typed.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
import { createAction } from '@reduxjs/toolkit';

import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

export const disconnectTimeline = createAction(
'timeline/disconnect',
({ timeline }: { timeline: string }) => ({
payload: {
timeline,
usePendingItems: preferPendingItems,
},
}),
);

export const timelineDelete = createAction<{
statusId: string;
accountId: string;
references: string[];
reblogOf: string | null;
}>('timelines/delete');
4 changes: 2 additions & 2 deletions app/javascript/mastodon/features/account_timeline/index.jsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -133,15 +133,15 @@ class AccountTimeline extends ImmutablePureComponent {
}

if (prevProps.accountId === me && accountId !== me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

componentWillUnmount () {
const { dispatch, accountId } = this.props;

if (accountId === me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/locales/ko.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@
"account.featured_tags.last_status_never": "게시물 없음",
"account.featured_tags.title": "{name} 님의 추천 해시태그",
"account.follow": "팔로우",
"account.follow_back": "맞팔로우",
"account.follow_back": "맞팔로우 하기",
"account.followers": "팔로워",
"account.followers.empty": "아직 아무도 이 사용자를 팔로우하고 있지 않습니다.",
"account.followers_counter": "{counter} 팔로워",
Expand All@@ -53,7 +53,7 @@
"account.mute_notifications_short": "알림 뮤트",
"account.mute_short": "뮤트",
"account.muted": "뮤트됨",
"account.mutual": "상호 팔로우",
"account.mutual": "맞팔로우 중",
"account.no_bio": "제공된 설명이 없습니다.",
"account.open_original_page": "원본 페이지 열기",
"account.posts": "게시물",
Expand Down
9 changes: 5 additions & 4 deletions app/javascript/mastodon/reducers/compose.js
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
COMPOSE_MOUNT,
COMPOSE_UNMOUNT,
Expand DownExpand Up@@ -51,7 +53,6 @@ import {
} from '../actions/compose';
import { REDRAFT } from '../actions/statuses';
import { STORE_HYDRATE } from '../actions/store';
import { TIMELINE_DELETE } from '../actions/timelines';
import { me } from '../initial_state';
import { unescapeHTML } from '../utils/html';
import { uuid } from '../uuid';
Expand DownExpand Up@@ -446,10 +447,10 @@ export default function compose(state = initialState, action) {
return updateSuggestionTags(state, action.token);
case COMPOSE_TAG_HISTORY_UPDATE:
return state.set('tagHistory', fromJS(action.tags));
case TIMELINE_DELETE:
if (action.id === state.get('in_reply_to')) {
case timelineDelete.type:
if (action.payload.statusId === state.get('in_reply_to')) {
return state.set('in_reply_to', null);
} else if (action.id === state.get('id')) {
} else if (action.payload.statusId === state.get('id')) {
return state.set('id', null);
} else {
return state;
Expand Down
8 changes: 5 additions & 3 deletions app/javascript/mastodon/reducers/contexts.js
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
blockAccountSuccess,
muteAccountSuccess,
} from '../actions/accounts';
import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
import { TIMELINE_DELETE, TIMELINE_UPDATE } from '../actions/timelines';
import { TIMELINE_UPDATE } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -97,8 +99,8 @@ export default function replies(state = initialState, action) {
return filterContexts(state, action.payload.relationship, action.payload.statuses);
case CONTEXT_FETCH_SUCCESS:
return normalizeContext(state, action.id, action.ancestors, action.descendants);
case TIMELINE_DELETE:
return deleteFromContexts(state, [action.id]);
case timelineDelete.type:
return deleteFromContexts(state, [action.payload.statusId]);
case TIMELINE_UPDATE:
return updateContext(state, action.status);
default:
Expand Down
7 changes: 4 additions & 3 deletions app/javascript/mastodon/reducers/modal.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
import type { Reducer } from '@reduxjs/toolkit';
import { Record as ImmutableRecord, Stack } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import { COMPOSE_UPLOAD_CHANGE_SUCCESS } from '../actions/compose';
import type { ModalType } from '../actions/modal';
import { openModal, closeModal } from '../actions/modal';
import { TIMELINE_DELETE } from '../actions/timelines';

export type ModalProps = Record<string, unknown>;
interface Modal {
Expand DownExpand Up@@ -72,10 +73,10 @@ export const modalReducer: Reducer<State> = (state = initialState, action) => {
// TODO: type those actions
else if (action.type === COMPOSE_UPLOAD_CHANGE_SUCCESS)
return popModal(state, { modalType: 'FOCAL_POINT', ignoreFocus: false });
else if (action.type === TIMELINE_DELETE)
else if (timelineDelete.match(action))
return state.update('stack', (stack) =>
stack.filterNot(
(modal) => modal.get('modalProps').statusId === action.id,
(modal) => modal.get('modalProps').statusId === action.payload.statusId,
),
);
else return state;
Expand Down
13 changes: 7 additions & 6 deletions app/javascript/mastodon/reducers/notifications.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import { fromJS, Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { blockDomainSuccess } from 'mastodon/actions/domain_blocks';
import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
authorizeFollowRequestSuccess,
Expand DownExpand Up@@ -30,7 +31,7 @@ import {
NOTIFICATIONS_SET_BROWSER_SUPPORT,
NOTIFICATIONS_SET_BROWSER_PERMISSION,
} from '../actions/notifications';
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines';
import { disconnectTimeline } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -291,11 +292,11 @@ export default function notifications(state = initialState, action) {
return filterNotifications(state, [action.payload.id], 'follow_request');
case NOTIFICATIONS_CLEAR:
return state.set('items', ImmutableList()).set('pendingItems', ImmutableList()).set('hasMore', false);
case TIMELINE_DELETE:
return deleteByStatus(state, action.id);
case TIMELINE_DISCONNECT:
return action.timeline === 'home' ?
state.update(action.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
case timelineDelete.type:
return deleteByStatus(state, action.payload.statusId);
case disconnectTimeline.type:
return action.payload.timeline === 'home' ?
state.update(action.payload.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
state;
case NOTIFICATIONS_MARK_AS_READ:
const lastNotification = state.get('items').find(item => item !== null);
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Head1 by hackal · Pull Request #3 · CallstackAI/mastodon · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .callstack.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
# yaml-language-server: $schema=https://storage.googleapis.com/config-schema/schema.v2.json

pr_review:
modules:
bug_hunter:
enabled: true
suggestions: true

code_suggestions:
enabled: false

code_conventions:
enabled: false
conventions: |
Exported code should be defined before internal code.

description:
enabled: true
diagram: true

grammar:
enabled: true

performance:
enabled: true

security:
enabled: true

exclude:
- "**/go.*"
33 changes: 33 additions & 0 deletions .github/workflows/reviewer.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
name: Cal PR Review

on:
workflow_dispatch:
inputs:
config:
type: string
description: "config for reviewer"
required: true
head:
type: string
description: "head commit sha"
required: true
base:
type: string
description: "base commit sha"
required: false
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.head }}

- name: Run reviewer
uses: addnab/docker-run-action@v3
with:
image: callstackai/cal:latest
options: -v ${{ github.workspace }}:/code
run: |
/reviewer --dir /code --id ${{ github.run_id }} --token ${{ github.token }} --config "${{ inputs.config }}"
50 changes: 3 additions & 47 deletions .rubocop_todo.yml
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.63.5.
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.64.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand DownExpand Up@@ -55,7 +55,6 @@ Style/FetchEnvVar:
- 'config/initializers/vapid.rb'
- 'lib/mastodon/redis_config.rb'
- 'lib/tasks/repo.rake'
- 'spec/system/profile_spec.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
Expand All@@ -66,40 +65,10 @@ Style/FormatStringToken:
- 'config/initializers/devise.rb'
- 'lib/paperclip/color_extractor.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'config/environments/development.rb'
- 'config/environments/production.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
Exclude:
- 'app/lib/activitypub/activity/block.rb'
- 'app/lib/request.rb'
- 'app/lib/request_pool.rb'
- 'app/lib/webfinger.rb'
- 'app/lib/webfinger_resource.rb'
- 'app/models/concerns/account/counters.rb'
- 'app/models/concerns/user/ldap_authenticable.rb'
- 'app/models/tag.rb'
- 'app/models/user.rb'
- 'app/services/fan_out_on_write_service.rb'
- 'app/services/post_status_service.rb'
- 'app/services/process_hashtags_service.rb'
- 'app/workers/move_worker.rb'
- 'app/workers/redownload_avatar_worker.rb'
- 'app/workers/redownload_header_worker.rb'
- 'app/workers/redownload_media_worker.rb'
- 'app/workers/remote_account_refresh_worker.rb'
- 'config/initializers/devise.rb'
- 'lib/devise/strategies/two_factor_ldap_authenticatable.rb'
- 'lib/devise/strategies/two_factor_pam_authenticatable.rb'
- 'lib/mastodon/cli/accounts.rb'
- 'lib/mastodon/cli/maintenance.rb'
- 'lib/mastodon/cli/media.rb'
- 'lib/tasks/repo.rake'
Enabled: false

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashTransformValues:
Expand All@@ -121,16 +90,10 @@ Style/MutableConstant:
- 'app/services/delete_account_service.rb'
- 'lib/mastodon/migration_warning.rb'

# This cop supports safe autocorrection (--autocorrect).
Style/NilLambda:
Exclude:
- 'config/initializers/paperclip.rb'

# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'app/helpers/admin/account_moderation_notes_helper.rb'
- 'app/helpers/jsonld_helper.rb'
- 'app/lib/admin/system_check/message.rb'
- 'app/lib/request.rb'
Expand All@@ -154,13 +117,6 @@ Style/RedundantConstantBase:
- 'config/environments/production.rb'
- 'config/initializers/sidekiq.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'app/models/concerns/account/finder_concern.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: WordRegex.
# SupportedStyles: percent, brackets
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2_alpha/notifications_controller.rb
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@ def index
@relationships = StatusRelationshipsPresenter.new(target_statuses_from_notifications, current_user&.account_id)
end

render json: @notifications.map { |notification| NotificationGroup.from_notification(notification) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
render json: @notifications.map { |notification| NotificationGroup.from_notification(notification, max_id: @group_metadata.dig(notification.group_key, :max_id)) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/actions/streaming.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
},

onDisconnect() {
dispatch(disconnectTimeline(timelineId));
dispatch(disconnectTimeline({ timeline: timelineId }));

if (options.fallback) {
// @ts-expect-error
Expand Down
21 changes: 5 additions & 16 deletions app/javascript/mastodon/actions/timelines.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,9 +6,11 @@ import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

import { importFetchedStatus, importFetchedStatuses } from './importer';
import { submitMarkers } from './markers';
import {timelineDelete} from './timelines_typed';

export { disconnectTimeline } from './timelines_typed';

export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
export const TIMELINE_CLEAR = 'TIMELINE_CLEAR';

export const TIMELINE_EXPAND_REQUEST = 'TIMELINE_EXPAND_REQUEST';
Expand All@@ -17,7 +19,6 @@ export const TIMELINE_EXPAND_FAIL = 'TIMELINE_EXPAND_FAIL';

export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
export const TIMELINE_LOAD_PENDING = 'TIMELINE_LOAD_PENDING';
export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
export const TIMELINE_CONNECT = 'TIMELINE_CONNECT';

export const TIMELINE_MARK_AS_PARTIAL = 'TIMELINE_MARK_AS_PARTIAL';
Expand DownExpand Up@@ -62,16 +63,10 @@ export function updateTimeline(timeline, status, accept) {
export function deleteFromTimelines(id) {
return (dispatch, getState) => {
const accountId = getState().getIn(['statuses', id, 'account']);
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id'));
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id')).toText();
const reblogOf = getState().getIn(['statuses', id, 'reblog'], null);

dispatch({
type: TIMELINE_DELETE,
id,
accountId,
references,
reblogOf,
});
dispatch(timelineDelete(id, accountId, reference, reblogOf));
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
};
}

Expand DownExpand Up@@ -225,12 +220,6 @@ export function connectTimeline(timeline) {
};
}

export const disconnectTimeline = timeline => ({
type: TIMELINE_DISCONNECT,
timeline,
usePendingItems: preferPendingItems,
});

export const markAsPartial = timeline => ({
type: TIMELINE_MARK_AS_PARTIAL,
timeline,
Expand Down
20 changes: 20 additions & 0 deletions app/javascript/mastodon/actions/timelines_typed.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
import { createAction } from '@reduxjs/toolkit';

import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

export const disconnectTimeline = createAction(
'timeline/disconnect',
({ timeline }: { timeline: string }) => ({
payload: {
timeline,
usePendingItems: preferPendingItems,
},
}),
);

export const timelineDelete = createAction<{
statusId: string;
accountId: string;
references: string[];
reblogOf: string | null;
}>('timelines/delete');
4 changes: 2 additions & 2 deletions app/javascript/mastodon/features/account_timeline/index.jsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -133,15 +133,15 @@ class AccountTimeline extends ImmutablePureComponent {
}

if (prevProps.accountId === me && accountId !== me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

componentWillUnmount () {
const { dispatch, accountId } = this.props;

if (accountId === me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/locales/ko.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@
"account.featured_tags.last_status_never": "게시물 없음",
"account.featured_tags.title": "{name} 님의 추천 해시태그",
"account.follow": "팔로우",
"account.follow_back": "맞팔로우",
"account.follow_back": "맞팔로우 하기",
"account.followers": "팔로워",
"account.followers.empty": "아직 아무도 이 사용자를 팔로우하고 있지 않습니다.",
"account.followers_counter": "{counter} 팔로워",
Expand All@@ -53,7 +53,7 @@
"account.mute_notifications_short": "알림 뮤트",
"account.mute_short": "뮤트",
"account.muted": "뮤트됨",
"account.mutual": "상호 팔로우",
"account.mutual": "맞팔로우 중",
"account.no_bio": "제공된 설명이 없습니다.",
"account.open_original_page": "원본 페이지 열기",
"account.posts": "게시물",
Expand Down
9 changes: 5 additions & 4 deletions app/javascript/mastodon/reducers/compose.js
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
COMPOSE_MOUNT,
COMPOSE_UNMOUNT,
Expand DownExpand Up@@ -51,7 +53,6 @@ import {
} from '../actions/compose';
import { REDRAFT } from '../actions/statuses';
import { STORE_HYDRATE } from '../actions/store';
import { TIMELINE_DELETE } from '../actions/timelines';
import { me } from '../initial_state';
import { unescapeHTML } from '../utils/html';
import { uuid } from '../uuid';
Expand DownExpand Up@@ -446,10 +447,10 @@ export default function compose(state = initialState, action) {
return updateSuggestionTags(state, action.token);
case COMPOSE_TAG_HISTORY_UPDATE:
return state.set('tagHistory', fromJS(action.tags));
case TIMELINE_DELETE:
if (action.id === state.get('in_reply_to')) {
case timelineDelete.type:
if (action.payload.statusId === state.get('in_reply_to')) {
return state.set('in_reply_to', null);
} else if (action.id === state.get('id')) {
} else if (action.payload.statusId === state.get('id')) {
return state.set('id', null);
} else {
return state;
Expand Down
8 changes: 5 additions & 3 deletions app/javascript/mastodon/reducers/contexts.js
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
blockAccountSuccess,
muteAccountSuccess,
} from '../actions/accounts';
import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
import { TIMELINE_DELETE, TIMELINE_UPDATE } from '../actions/timelines';
import { TIMELINE_UPDATE } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -97,8 +99,8 @@ export default function replies(state = initialState, action) {
return filterContexts(state, action.payload.relationship, action.payload.statuses);
case CONTEXT_FETCH_SUCCESS:
return normalizeContext(state, action.id, action.ancestors, action.descendants);
case TIMELINE_DELETE:
return deleteFromContexts(state, [action.id]);
case timelineDelete.type:
return deleteFromContexts(state, [action.payload.statusId]);
case TIMELINE_UPDATE:
return updateContext(state, action.status);
default:
Expand Down
7 changes: 4 additions & 3 deletions app/javascript/mastodon/reducers/modal.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
import type { Reducer } from '@reduxjs/toolkit';
import { Record as ImmutableRecord, Stack } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import { COMPOSE_UPLOAD_CHANGE_SUCCESS } from '../actions/compose';
import type { ModalType } from '../actions/modal';
import { openModal, closeModal } from '../actions/modal';
import { TIMELINE_DELETE } from '../actions/timelines';

export type ModalProps = Record<string, unknown>;
interface Modal {
Expand DownExpand Up@@ -72,10 +73,10 @@ export const modalReducer: Reducer<State> = (state = initialState, action) => {
// TODO: type those actions
else if (action.type === COMPOSE_UPLOAD_CHANGE_SUCCESS)
return popModal(state, { modalType: 'FOCAL_POINT', ignoreFocus: false });
else if (action.type === TIMELINE_DELETE)
else if (timelineDelete.match(action))
return state.update('stack', (stack) =>
stack.filterNot(
(modal) => modal.get('modalProps').statusId === action.id,
(modal) => modal.get('modalProps').statusId === action.payload.statusId,
),
);
else return state;
Expand Down
13 changes: 7 additions & 6 deletions app/javascript/mastodon/reducers/notifications.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import { fromJS, Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { blockDomainSuccess } from 'mastodon/actions/domain_blocks';
import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
authorizeFollowRequestSuccess,
Expand DownExpand Up@@ -30,7 +31,7 @@ import {
NOTIFICATIONS_SET_BROWSER_SUPPORT,
NOTIFICATIONS_SET_BROWSER_PERMISSION,
} from '../actions/notifications';
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines';
import { disconnectTimeline } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -291,11 +292,11 @@ export default function notifications(state = initialState, action) {
return filterNotifications(state, [action.payload.id], 'follow_request');
case NOTIFICATIONS_CLEAR:
return state.set('items', ImmutableList()).set('pendingItems', ImmutableList()).set('hasMore', false);
case TIMELINE_DELETE:
return deleteByStatus(state, action.id);
case TIMELINE_DISCONNECT:
return action.timeline === 'home' ?
state.update(action.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
case timelineDelete.type:
return deleteByStatus(state, action.payload.statusId);
case disconnectTimeline.type:
return action.payload.timeline === 'home' ?
state.update(action.payload.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
state;
case NOTIFICATIONS_MARK_AS_READ:
const lastNotification = state.get('items').find(item => item !== null);
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Head1 by hackal · Pull Request #3 · CallstackAI/mastodon · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .callstack.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
# yaml-language-server: $schema=https://storage.googleapis.com/config-schema/schema.v2.json

pr_review:
modules:
bug_hunter:
enabled: true
suggestions: true

code_suggestions:
enabled: false

code_conventions:
enabled: false
conventions: |
Exported code should be defined before internal code.

description:
enabled: true
diagram: true

grammar:
enabled: true

performance:
enabled: true

security:
enabled: true

exclude:
- "**/go.*"
33 changes: 33 additions & 0 deletions .github/workflows/reviewer.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
name: Cal PR Review

on:
workflow_dispatch:
inputs:
config:
type: string
description: "config for reviewer"
required: true
head:
type: string
description: "head commit sha"
required: true
base:
type: string
description: "base commit sha"
required: false
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.head }}

- name: Run reviewer
uses: addnab/docker-run-action@v3
with:
image: callstackai/cal:latest
options: -v ${{ github.workspace }}:/code
run: |
/reviewer --dir /code --id ${{ github.run_id }} --token ${{ github.token }} --config "${{ inputs.config }}"
50 changes: 3 additions & 47 deletions .rubocop_todo.yml
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.63.5.
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.64.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand DownExpand Up@@ -55,7 +55,6 @@ Style/FetchEnvVar:
- 'config/initializers/vapid.rb'
- 'lib/mastodon/redis_config.rb'
- 'lib/tasks/repo.rake'
- 'spec/system/profile_spec.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
Expand All@@ -66,40 +65,10 @@ Style/FormatStringToken:
- 'config/initializers/devise.rb'
- 'lib/paperclip/color_extractor.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'config/environments/development.rb'
- 'config/environments/production.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
Exclude:
- 'app/lib/activitypub/activity/block.rb'
- 'app/lib/request.rb'
- 'app/lib/request_pool.rb'
- 'app/lib/webfinger.rb'
- 'app/lib/webfinger_resource.rb'
- 'app/models/concerns/account/counters.rb'
- 'app/models/concerns/user/ldap_authenticable.rb'
- 'app/models/tag.rb'
- 'app/models/user.rb'
- 'app/services/fan_out_on_write_service.rb'
- 'app/services/post_status_service.rb'
- 'app/services/process_hashtags_service.rb'
- 'app/workers/move_worker.rb'
- 'app/workers/redownload_avatar_worker.rb'
- 'app/workers/redownload_header_worker.rb'
- 'app/workers/redownload_media_worker.rb'
- 'app/workers/remote_account_refresh_worker.rb'
- 'config/initializers/devise.rb'
- 'lib/devise/strategies/two_factor_ldap_authenticatable.rb'
- 'lib/devise/strategies/two_factor_pam_authenticatable.rb'
- 'lib/mastodon/cli/accounts.rb'
- 'lib/mastodon/cli/maintenance.rb'
- 'lib/mastodon/cli/media.rb'
- 'lib/tasks/repo.rake'
Enabled: false

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashTransformValues:
Expand All@@ -121,16 +90,10 @@ Style/MutableConstant:
- 'app/services/delete_account_service.rb'
- 'lib/mastodon/migration_warning.rb'

# This cop supports safe autocorrection (--autocorrect).
Style/NilLambda:
Exclude:
- 'config/initializers/paperclip.rb'

# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'app/helpers/admin/account_moderation_notes_helper.rb'
- 'app/helpers/jsonld_helper.rb'
- 'app/lib/admin/system_check/message.rb'
- 'app/lib/request.rb'
Expand All@@ -154,13 +117,6 @@ Style/RedundantConstantBase:
- 'config/environments/production.rb'
- 'config/initializers/sidekiq.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'app/models/concerns/account/finder_concern.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: WordRegex.
# SupportedStyles: percent, brackets
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2_alpha/notifications_controller.rb
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@ def index
@relationships = StatusRelationshipsPresenter.new(target_statuses_from_notifications, current_user&.account_id)
end

render json: @notifications.map { |notification| NotificationGroup.from_notification(notification) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
render json: @notifications.map { |notification| NotificationGroup.from_notification(notification, max_id: @group_metadata.dig(notification.group_key, :max_id)) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/actions/streaming.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
},

onDisconnect() {
dispatch(disconnectTimeline(timelineId));
dispatch(disconnectTimeline({ timeline: timelineId }));

if (options.fallback) {
// @ts-expect-error
Expand Down
21 changes: 5 additions & 16 deletions app/javascript/mastodon/actions/timelines.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,9 +6,11 @@ import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

import { importFetchedStatus, importFetchedStatuses } from './importer';
import { submitMarkers } from './markers';
import {timelineDelete} from './timelines_typed';

export { disconnectTimeline } from './timelines_typed';

export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
export const TIMELINE_CLEAR = 'TIMELINE_CLEAR';

export const TIMELINE_EXPAND_REQUEST = 'TIMELINE_EXPAND_REQUEST';
Expand All@@ -17,7 +19,6 @@ export const TIMELINE_EXPAND_FAIL = 'TIMELINE_EXPAND_FAIL';

export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
export const TIMELINE_LOAD_PENDING = 'TIMELINE_LOAD_PENDING';
export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
export const TIMELINE_CONNECT = 'TIMELINE_CONNECT';

export const TIMELINE_MARK_AS_PARTIAL = 'TIMELINE_MARK_AS_PARTIAL';
Expand DownExpand Up@@ -62,16 +63,10 @@ export function updateTimeline(timeline, status, accept) {
export function deleteFromTimelines(id) {
return (dispatch, getState) => {
const accountId = getState().getIn(['statuses', id, 'account']);
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id'));
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id')).toText();
const reblogOf = getState().getIn(['statuses', id, 'reblog'], null);

dispatch({
type: TIMELINE_DELETE,
id,
accountId,
references,
reblogOf,
});
dispatch(timelineDelete(id, accountId, reference, reblogOf));
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
};
}

Expand DownExpand Up@@ -225,12 +220,6 @@ export function connectTimeline(timeline) {
};
}

export const disconnectTimeline = timeline => ({
type: TIMELINE_DISCONNECT,
timeline,
usePendingItems: preferPendingItems,
});

export const markAsPartial = timeline => ({
type: TIMELINE_MARK_AS_PARTIAL,
timeline,
Expand Down
20 changes: 20 additions & 0 deletions app/javascript/mastodon/actions/timelines_typed.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
import { createAction } from '@reduxjs/toolkit';

import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

export const disconnectTimeline = createAction(
'timeline/disconnect',
({ timeline }: { timeline: string }) => ({
payload: {
timeline,
usePendingItems: preferPendingItems,
},
}),
);

export const timelineDelete = createAction<{
statusId: string;
accountId: string;
references: string[];
reblogOf: string | null;
}>('timelines/delete');
4 changes: 2 additions & 2 deletions app/javascript/mastodon/features/account_timeline/index.jsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -133,15 +133,15 @@ class AccountTimeline extends ImmutablePureComponent {
}

if (prevProps.accountId === me && accountId !== me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

componentWillUnmount () {
const { dispatch, accountId } = this.props;

if (accountId === me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/locales/ko.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@
"account.featured_tags.last_status_never": "게시물 없음",
"account.featured_tags.title": "{name} 님의 추천 해시태그",
"account.follow": "팔로우",
"account.follow_back": "맞팔로우",
"account.follow_back": "맞팔로우 하기",
"account.followers": "팔로워",
"account.followers.empty": "아직 아무도 이 사용자를 팔로우하고 있지 않습니다.",
"account.followers_counter": "{counter} 팔로워",
Expand All@@ -53,7 +53,7 @@
"account.mute_notifications_short": "알림 뮤트",
"account.mute_short": "뮤트",
"account.muted": "뮤트됨",
"account.mutual": "상호 팔로우",
"account.mutual": "맞팔로우 중",
"account.no_bio": "제공된 설명이 없습니다.",
"account.open_original_page": "원본 페이지 열기",
"account.posts": "게시물",
Expand Down
9 changes: 5 additions & 4 deletions app/javascript/mastodon/reducers/compose.js
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
COMPOSE_MOUNT,
COMPOSE_UNMOUNT,
Expand DownExpand Up@@ -51,7 +53,6 @@ import {
} from '../actions/compose';
import { REDRAFT } from '../actions/statuses';
import { STORE_HYDRATE } from '../actions/store';
import { TIMELINE_DELETE } from '../actions/timelines';
import { me } from '../initial_state';
import { unescapeHTML } from '../utils/html';
import { uuid } from '../uuid';
Expand DownExpand Up@@ -446,10 +447,10 @@ export default function compose(state = initialState, action) {
return updateSuggestionTags(state, action.token);
case COMPOSE_TAG_HISTORY_UPDATE:
return state.set('tagHistory', fromJS(action.tags));
case TIMELINE_DELETE:
if (action.id === state.get('in_reply_to')) {
case timelineDelete.type:
if (action.payload.statusId === state.get('in_reply_to')) {
return state.set('in_reply_to', null);
} else if (action.id === state.get('id')) {
} else if (action.payload.statusId === state.get('id')) {
return state.set('id', null);
} else {
return state;
Expand Down
8 changes: 5 additions & 3 deletions app/javascript/mastodon/reducers/contexts.js
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
blockAccountSuccess,
muteAccountSuccess,
} from '../actions/accounts';
import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
import { TIMELINE_DELETE, TIMELINE_UPDATE } from '../actions/timelines';
import { TIMELINE_UPDATE } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -97,8 +99,8 @@ export default function replies(state = initialState, action) {
return filterContexts(state, action.payload.relationship, action.payload.statuses);
case CONTEXT_FETCH_SUCCESS:
return normalizeContext(state, action.id, action.ancestors, action.descendants);
case TIMELINE_DELETE:
return deleteFromContexts(state, [action.id]);
case timelineDelete.type:
return deleteFromContexts(state, [action.payload.statusId]);
case TIMELINE_UPDATE:
return updateContext(state, action.status);
default:
Expand Down
7 changes: 4 additions & 3 deletions app/javascript/mastodon/reducers/modal.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
import type { Reducer } from '@reduxjs/toolkit';
import { Record as ImmutableRecord, Stack } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import { COMPOSE_UPLOAD_CHANGE_SUCCESS } from '../actions/compose';
import type { ModalType } from '../actions/modal';
import { openModal, closeModal } from '../actions/modal';
import { TIMELINE_DELETE } from '../actions/timelines';

export type ModalProps = Record<string, unknown>;
interface Modal {
Expand DownExpand Up@@ -72,10 +73,10 @@ export const modalReducer: Reducer<State> = (state = initialState, action) => {
// TODO: type those actions
else if (action.type === COMPOSE_UPLOAD_CHANGE_SUCCESS)
return popModal(state, { modalType: 'FOCAL_POINT', ignoreFocus: false });
else if (action.type === TIMELINE_DELETE)
else if (timelineDelete.match(action))
return state.update('stack', (stack) =>
stack.filterNot(
(modal) => modal.get('modalProps').statusId === action.id,
(modal) => modal.get('modalProps').statusId === action.payload.statusId,
),
);
else return state;
Expand Down
13 changes: 7 additions & 6 deletions app/javascript/mastodon/reducers/notifications.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import { fromJS, Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { blockDomainSuccess } from 'mastodon/actions/domain_blocks';
import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
authorizeFollowRequestSuccess,
Expand DownExpand Up@@ -30,7 +31,7 @@ import {
NOTIFICATIONS_SET_BROWSER_SUPPORT,
NOTIFICATIONS_SET_BROWSER_PERMISSION,
} from '../actions/notifications';
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines';
import { disconnectTimeline } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -291,11 +292,11 @@ export default function notifications(state = initialState, action) {
return filterNotifications(state, [action.payload.id], 'follow_request');
case NOTIFICATIONS_CLEAR:
return state.set('items', ImmutableList()).set('pendingItems', ImmutableList()).set('hasMore', false);
case TIMELINE_DELETE:
return deleteByStatus(state, action.id);
case TIMELINE_DISCONNECT:
return action.timeline === 'home' ?
state.update(action.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
case timelineDelete.type:
return deleteByStatus(state, action.payload.statusId);
case disconnectTimeline.type:
return action.payload.timeline === 'home' ?
state.update(action.payload.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
state;
case NOTIFICATIONS_MARK_AS_READ:
const lastNotification = state.get('items').find(item => item !== null);
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Head1 by hackal · Pull Request #3 · CallstackAI/mastodon · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .callstack.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
# yaml-language-server: $schema=https://storage.googleapis.com/config-schema/schema.v2.json

pr_review:
modules:
bug_hunter:
enabled: true
suggestions: true

code_suggestions:
enabled: false

code_conventions:
enabled: false
conventions: |
Exported code should be defined before internal code.

description:
enabled: true
diagram: true

grammar:
enabled: true

performance:
enabled: true

security:
enabled: true

exclude:
- "**/go.*"
33 changes: 33 additions & 0 deletions .github/workflows/reviewer.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
name: Cal PR Review

on:
workflow_dispatch:
inputs:
config:
type: string
description: "config for reviewer"
required: true
head:
type: string
description: "head commit sha"
required: true
base:
type: string
description: "base commit sha"
required: false
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.head }}

- name: Run reviewer
uses: addnab/docker-run-action@v3
with:
image: callstackai/cal:latest
options: -v ${{ github.workspace }}:/code
run: |
/reviewer --dir /code --id ${{ github.run_id }} --token ${{ github.token }} --config "${{ inputs.config }}"
50 changes: 3 additions & 47 deletions .rubocop_todo.yml
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.63.5.
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.64.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand DownExpand Up@@ -55,7 +55,6 @@ Style/FetchEnvVar:
- 'config/initializers/vapid.rb'
- 'lib/mastodon/redis_config.rb'
- 'lib/tasks/repo.rake'
- 'spec/system/profile_spec.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
Expand All@@ -66,40 +65,10 @@ Style/FormatStringToken:
- 'config/initializers/devise.rb'
- 'lib/paperclip/color_extractor.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'config/environments/development.rb'
- 'config/environments/production.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
Exclude:
- 'app/lib/activitypub/activity/block.rb'
- 'app/lib/request.rb'
- 'app/lib/request_pool.rb'
- 'app/lib/webfinger.rb'
- 'app/lib/webfinger_resource.rb'
- 'app/models/concerns/account/counters.rb'
- 'app/models/concerns/user/ldap_authenticable.rb'
- 'app/models/tag.rb'
- 'app/models/user.rb'
- 'app/services/fan_out_on_write_service.rb'
- 'app/services/post_status_service.rb'
- 'app/services/process_hashtags_service.rb'
- 'app/workers/move_worker.rb'
- 'app/workers/redownload_avatar_worker.rb'
- 'app/workers/redownload_header_worker.rb'
- 'app/workers/redownload_media_worker.rb'
- 'app/workers/remote_account_refresh_worker.rb'
- 'config/initializers/devise.rb'
- 'lib/devise/strategies/two_factor_ldap_authenticatable.rb'
- 'lib/devise/strategies/two_factor_pam_authenticatable.rb'
- 'lib/mastodon/cli/accounts.rb'
- 'lib/mastodon/cli/maintenance.rb'
- 'lib/mastodon/cli/media.rb'
- 'lib/tasks/repo.rake'
Enabled: false

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashTransformValues:
Expand All@@ -121,16 +90,10 @@ Style/MutableConstant:
- 'app/services/delete_account_service.rb'
- 'lib/mastodon/migration_warning.rb'

# This cop supports safe autocorrection (--autocorrect).
Style/NilLambda:
Exclude:
- 'config/initializers/paperclip.rb'

# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'app/helpers/admin/account_moderation_notes_helper.rb'
- 'app/helpers/jsonld_helper.rb'
- 'app/lib/admin/system_check/message.rb'
- 'app/lib/request.rb'
Expand All@@ -154,13 +117,6 @@ Style/RedundantConstantBase:
- 'config/environments/production.rb'
- 'config/initializers/sidekiq.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'app/models/concerns/account/finder_concern.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: WordRegex.
# SupportedStyles: percent, brackets
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2_alpha/notifications_controller.rb
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@ def index
@relationships = StatusRelationshipsPresenter.new(target_statuses_from_notifications, current_user&.account_id)
end

render json: @notifications.map { |notification| NotificationGroup.from_notification(notification) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
render json: @notifications.map { |notification| NotificationGroup.from_notification(notification, max_id: @group_metadata.dig(notification.group_key, :max_id)) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/actions/streaming.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
},

onDisconnect() {
dispatch(disconnectTimeline(timelineId));
dispatch(disconnectTimeline({ timeline: timelineId }));

if (options.fallback) {
// @ts-expect-error
Expand Down
21 changes: 5 additions & 16 deletions app/javascript/mastodon/actions/timelines.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,9 +6,11 @@ import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

import { importFetchedStatus, importFetchedStatuses } from './importer';
import { submitMarkers } from './markers';
import {timelineDelete} from './timelines_typed';

export { disconnectTimeline } from './timelines_typed';

export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
export const TIMELINE_CLEAR = 'TIMELINE_CLEAR';

export const TIMELINE_EXPAND_REQUEST = 'TIMELINE_EXPAND_REQUEST';
Expand All@@ -17,7 +19,6 @@ export const TIMELINE_EXPAND_FAIL = 'TIMELINE_EXPAND_FAIL';

export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
export const TIMELINE_LOAD_PENDING = 'TIMELINE_LOAD_PENDING';
export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
export const TIMELINE_CONNECT = 'TIMELINE_CONNECT';

export const TIMELINE_MARK_AS_PARTIAL = 'TIMELINE_MARK_AS_PARTIAL';
Expand DownExpand Up@@ -62,16 +63,10 @@ export function updateTimeline(timeline, status, accept) {
export function deleteFromTimelines(id) {
return (dispatch, getState) => {
const accountId = getState().getIn(['statuses', id, 'account']);
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id'));
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id')).toText();
const reblogOf = getState().getIn(['statuses', id, 'reblog'], null);

dispatch({
type: TIMELINE_DELETE,
id,
accountId,
references,
reblogOf,
});
dispatch(timelineDelete(id, accountId, reference, reblogOf));
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
};
}

Expand DownExpand Up@@ -225,12 +220,6 @@ export function connectTimeline(timeline) {
};
}

export const disconnectTimeline = timeline => ({
type: TIMELINE_DISCONNECT,
timeline,
usePendingItems: preferPendingItems,
});

export const markAsPartial = timeline => ({
type: TIMELINE_MARK_AS_PARTIAL,
timeline,
Expand Down
20 changes: 20 additions & 0 deletions app/javascript/mastodon/actions/timelines_typed.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
import { createAction } from '@reduxjs/toolkit';

import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

export const disconnectTimeline = createAction(
'timeline/disconnect',
({ timeline }: { timeline: string }) => ({
payload: {
timeline,
usePendingItems: preferPendingItems,
},
}),
);

export const timelineDelete = createAction<{
statusId: string;
accountId: string;
references: string[];
reblogOf: string | null;
}>('timelines/delete');
4 changes: 2 additions & 2 deletions app/javascript/mastodon/features/account_timeline/index.jsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -133,15 +133,15 @@ class AccountTimeline extends ImmutablePureComponent {
}

if (prevProps.accountId === me && accountId !== me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

componentWillUnmount () {
const { dispatch, accountId } = this.props;

if (accountId === me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/locales/ko.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@
"account.featured_tags.last_status_never": "게시물 없음",
"account.featured_tags.title": "{name} 님의 추천 해시태그",
"account.follow": "팔로우",
"account.follow_back": "맞팔로우",
"account.follow_back": "맞팔로우 하기",
"account.followers": "팔로워",
"account.followers.empty": "아직 아무도 이 사용자를 팔로우하고 있지 않습니다.",
"account.followers_counter": "{counter} 팔로워",
Expand All@@ -53,7 +53,7 @@
"account.mute_notifications_short": "알림 뮤트",
"account.mute_short": "뮤트",
"account.muted": "뮤트됨",
"account.mutual": "상호 팔로우",
"account.mutual": "맞팔로우 중",
"account.no_bio": "제공된 설명이 없습니다.",
"account.open_original_page": "원본 페이지 열기",
"account.posts": "게시물",
Expand Down
9 changes: 5 additions & 4 deletions app/javascript/mastodon/reducers/compose.js
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
COMPOSE_MOUNT,
COMPOSE_UNMOUNT,
Expand DownExpand Up@@ -51,7 +53,6 @@ import {
} from '../actions/compose';
import { REDRAFT } from '../actions/statuses';
import { STORE_HYDRATE } from '../actions/store';
import { TIMELINE_DELETE } from '../actions/timelines';
import { me } from '../initial_state';
import { unescapeHTML } from '../utils/html';
import { uuid } from '../uuid';
Expand DownExpand Up@@ -446,10 +447,10 @@ export default function compose(state = initialState, action) {
return updateSuggestionTags(state, action.token);
case COMPOSE_TAG_HISTORY_UPDATE:
return state.set('tagHistory', fromJS(action.tags));
case TIMELINE_DELETE:
if (action.id === state.get('in_reply_to')) {
case timelineDelete.type:
if (action.payload.statusId === state.get('in_reply_to')) {
return state.set('in_reply_to', null);
} else if (action.id === state.get('id')) {
} else if (action.payload.statusId === state.get('id')) {
return state.set('id', null);
} else {
return state;
Expand Down
8 changes: 5 additions & 3 deletions app/javascript/mastodon/reducers/contexts.js
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
blockAccountSuccess,
muteAccountSuccess,
} from '../actions/accounts';
import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
import { TIMELINE_DELETE, TIMELINE_UPDATE } from '../actions/timelines';
import { TIMELINE_UPDATE } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -97,8 +99,8 @@ export default function replies(state = initialState, action) {
return filterContexts(state, action.payload.relationship, action.payload.statuses);
case CONTEXT_FETCH_SUCCESS:
return normalizeContext(state, action.id, action.ancestors, action.descendants);
case TIMELINE_DELETE:
return deleteFromContexts(state, [action.id]);
case timelineDelete.type:
return deleteFromContexts(state, [action.payload.statusId]);
case TIMELINE_UPDATE:
return updateContext(state, action.status);
default:
Expand Down
7 changes: 4 additions & 3 deletions app/javascript/mastodon/reducers/modal.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
import type { Reducer } from '@reduxjs/toolkit';
import { Record as ImmutableRecord, Stack } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import { COMPOSE_UPLOAD_CHANGE_SUCCESS } from '../actions/compose';
import type { ModalType } from '../actions/modal';
import { openModal, closeModal } from '../actions/modal';
import { TIMELINE_DELETE } from '../actions/timelines';

export type ModalProps = Record<string, unknown>;
interface Modal {
Expand DownExpand Up@@ -72,10 +73,10 @@ export const modalReducer: Reducer<State> = (state = initialState, action) => {
// TODO: type those actions
else if (action.type === COMPOSE_UPLOAD_CHANGE_SUCCESS)
return popModal(state, { modalType: 'FOCAL_POINT', ignoreFocus: false });
else if (action.type === TIMELINE_DELETE)
else if (timelineDelete.match(action))
return state.update('stack', (stack) =>
stack.filterNot(
(modal) => modal.get('modalProps').statusId === action.id,
(modal) => modal.get('modalProps').statusId === action.payload.statusId,
),
);
else return state;
Expand Down
13 changes: 7 additions & 6 deletions app/javascript/mastodon/reducers/notifications.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import { fromJS, Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { blockDomainSuccess } from 'mastodon/actions/domain_blocks';
import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
authorizeFollowRequestSuccess,
Expand DownExpand Up@@ -30,7 +31,7 @@ import {
NOTIFICATIONS_SET_BROWSER_SUPPORT,
NOTIFICATIONS_SET_BROWSER_PERMISSION,
} from '../actions/notifications';
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines';
import { disconnectTimeline } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -291,11 +292,11 @@ export default function notifications(state = initialState, action) {
return filterNotifications(state, [action.payload.id], 'follow_request');
case NOTIFICATIONS_CLEAR:
return state.set('items', ImmutableList()).set('pendingItems', ImmutableList()).set('hasMore', false);
case TIMELINE_DELETE:
return deleteByStatus(state, action.id);
case TIMELINE_DISCONNECT:
return action.timeline === 'home' ?
state.update(action.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
case timelineDelete.type:
return deleteByStatus(state, action.payload.statusId);
case disconnectTimeline.type:
return action.payload.timeline === 'home' ?
state.update(action.payload.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
state;
case NOTIFICATIONS_MARK_AS_READ:
const lastNotification = state.get('items').find(item => item !== null);
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Head1 by hackal · Pull Request #3 · CallstackAI/mastodon · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .callstack.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
# yaml-language-server: $schema=https://storage.googleapis.com/config-schema/schema.v2.json

pr_review:
modules:
bug_hunter:
enabled: true
suggestions: true

code_suggestions:
enabled: false

code_conventions:
enabled: false
conventions: |
Exported code should be defined before internal code.

description:
enabled: true
diagram: true

grammar:
enabled: true

performance:
enabled: true

security:
enabled: true

exclude:
- "**/go.*"
33 changes: 33 additions & 0 deletions .github/workflows/reviewer.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
name: Cal PR Review

on:
workflow_dispatch:
inputs:
config:
type: string
description: "config for reviewer"
required: true
head:
type: string
description: "head commit sha"
required: true
base:
type: string
description: "base commit sha"
required: false
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.head }}

- name: Run reviewer
uses: addnab/docker-run-action@v3
with:
image: callstackai/cal:latest
options: -v ${{ github.workspace }}:/code
run: |
/reviewer --dir /code --id ${{ github.run_id }} --token ${{ github.token }} --config "${{ inputs.config }}"
50 changes: 3 additions & 47 deletions .rubocop_todo.yml
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.63.5.
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.64.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand DownExpand Up@@ -55,7 +55,6 @@ Style/FetchEnvVar:
- 'config/initializers/vapid.rb'
- 'lib/mastodon/redis_config.rb'
- 'lib/tasks/repo.rake'
- 'spec/system/profile_spec.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
Expand All@@ -66,40 +65,10 @@ Style/FormatStringToken:
- 'config/initializers/devise.rb'
- 'lib/paperclip/color_extractor.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'config/environments/development.rb'
- 'config/environments/production.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
Exclude:
- 'app/lib/activitypub/activity/block.rb'
- 'app/lib/request.rb'
- 'app/lib/request_pool.rb'
- 'app/lib/webfinger.rb'
- 'app/lib/webfinger_resource.rb'
- 'app/models/concerns/account/counters.rb'
- 'app/models/concerns/user/ldap_authenticable.rb'
- 'app/models/tag.rb'
- 'app/models/user.rb'
- 'app/services/fan_out_on_write_service.rb'
- 'app/services/post_status_service.rb'
- 'app/services/process_hashtags_service.rb'
- 'app/workers/move_worker.rb'
- 'app/workers/redownload_avatar_worker.rb'
- 'app/workers/redownload_header_worker.rb'
- 'app/workers/redownload_media_worker.rb'
- 'app/workers/remote_account_refresh_worker.rb'
- 'config/initializers/devise.rb'
- 'lib/devise/strategies/two_factor_ldap_authenticatable.rb'
- 'lib/devise/strategies/two_factor_pam_authenticatable.rb'
- 'lib/mastodon/cli/accounts.rb'
- 'lib/mastodon/cli/maintenance.rb'
- 'lib/mastodon/cli/media.rb'
- 'lib/tasks/repo.rake'
Enabled: false

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashTransformValues:
Expand All@@ -121,16 +90,10 @@ Style/MutableConstant:
- 'app/services/delete_account_service.rb'
- 'lib/mastodon/migration_warning.rb'

# This cop supports safe autocorrection (--autocorrect).
Style/NilLambda:
Exclude:
- 'config/initializers/paperclip.rb'

# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'app/helpers/admin/account_moderation_notes_helper.rb'
- 'app/helpers/jsonld_helper.rb'
- 'app/lib/admin/system_check/message.rb'
- 'app/lib/request.rb'
Expand All@@ -154,13 +117,6 @@ Style/RedundantConstantBase:
- 'config/environments/production.rb'
- 'config/initializers/sidekiq.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'app/models/concerns/account/finder_concern.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: WordRegex.
# SupportedStyles: percent, brackets
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2_alpha/notifications_controller.rb
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@ def index
@relationships = StatusRelationshipsPresenter.new(target_statuses_from_notifications, current_user&.account_id)
end

render json: @notifications.map { |notification| NotificationGroup.from_notification(notification) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
render json: @notifications.map { |notification| NotificationGroup.from_notification(notification, max_id: @group_metadata.dig(notification.group_key, :max_id)) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/actions/streaming.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
},

onDisconnect() {
dispatch(disconnectTimeline(timelineId));
dispatch(disconnectTimeline({ timeline: timelineId }));

if (options.fallback) {
// @ts-expect-error
Expand Down
21 changes: 5 additions & 16 deletions app/javascript/mastodon/actions/timelines.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,9 +6,11 @@ import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

import { importFetchedStatus, importFetchedStatuses } from './importer';
import { submitMarkers } from './markers';
import {timelineDelete} from './timelines_typed';

export { disconnectTimeline } from './timelines_typed';

export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
export const TIMELINE_CLEAR = 'TIMELINE_CLEAR';

export const TIMELINE_EXPAND_REQUEST = 'TIMELINE_EXPAND_REQUEST';
Expand All@@ -17,7 +19,6 @@ export const TIMELINE_EXPAND_FAIL = 'TIMELINE_EXPAND_FAIL';

export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
export const TIMELINE_LOAD_PENDING = 'TIMELINE_LOAD_PENDING';
export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
export const TIMELINE_CONNECT = 'TIMELINE_CONNECT';

export const TIMELINE_MARK_AS_PARTIAL = 'TIMELINE_MARK_AS_PARTIAL';
Expand DownExpand Up@@ -62,16 +63,10 @@ export function updateTimeline(timeline, status, accept) {
export function deleteFromTimelines(id) {
return (dispatch, getState) => {
const accountId = getState().getIn(['statuses', id, 'account']);
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id'));
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id')).toText();
const reblogOf = getState().getIn(['statuses', id, 'reblog'], null);

dispatch({
type: TIMELINE_DELETE,
id,
accountId,
references,
reblogOf,
});
dispatch(timelineDelete(id, accountId, reference, reblogOf));
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
};
}

Expand DownExpand Up@@ -225,12 +220,6 @@ export function connectTimeline(timeline) {
};
}

export const disconnectTimeline = timeline => ({
type: TIMELINE_DISCONNECT,
timeline,
usePendingItems: preferPendingItems,
});

export const markAsPartial = timeline => ({
type: TIMELINE_MARK_AS_PARTIAL,
timeline,
Expand Down
20 changes: 20 additions & 0 deletions app/javascript/mastodon/actions/timelines_typed.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
import { createAction } from '@reduxjs/toolkit';

import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

export const disconnectTimeline = createAction(
'timeline/disconnect',
({ timeline }: { timeline: string }) => ({
payload: {
timeline,
usePendingItems: preferPendingItems,
},
}),
);

export const timelineDelete = createAction<{
statusId: string;
accountId: string;
references: string[];
reblogOf: string | null;
}>('timelines/delete');
4 changes: 2 additions & 2 deletions app/javascript/mastodon/features/account_timeline/index.jsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -133,15 +133,15 @@ class AccountTimeline extends ImmutablePureComponent {
}

if (prevProps.accountId === me && accountId !== me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

componentWillUnmount () {
const { dispatch, accountId } = this.props;

if (accountId === me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/locales/ko.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@
"account.featured_tags.last_status_never": "게시물 없음",
"account.featured_tags.title": "{name} 님의 추천 해시태그",
"account.follow": "팔로우",
"account.follow_back": "맞팔로우",
"account.follow_back": "맞팔로우 하기",
"account.followers": "팔로워",
"account.followers.empty": "아직 아무도 이 사용자를 팔로우하고 있지 않습니다.",
"account.followers_counter": "{counter} 팔로워",
Expand All@@ -53,7 +53,7 @@
"account.mute_notifications_short": "알림 뮤트",
"account.mute_short": "뮤트",
"account.muted": "뮤트됨",
"account.mutual": "상호 팔로우",
"account.mutual": "맞팔로우 중",
"account.no_bio": "제공된 설명이 없습니다.",
"account.open_original_page": "원본 페이지 열기",
"account.posts": "게시물",
Expand Down
9 changes: 5 additions & 4 deletions app/javascript/mastodon/reducers/compose.js
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
COMPOSE_MOUNT,
COMPOSE_UNMOUNT,
Expand DownExpand Up@@ -51,7 +53,6 @@ import {
} from '../actions/compose';
import { REDRAFT } from '../actions/statuses';
import { STORE_HYDRATE } from '../actions/store';
import { TIMELINE_DELETE } from '../actions/timelines';
import { me } from '../initial_state';
import { unescapeHTML } from '../utils/html';
import { uuid } from '../uuid';
Expand DownExpand Up@@ -446,10 +447,10 @@ export default function compose(state = initialState, action) {
return updateSuggestionTags(state, action.token);
case COMPOSE_TAG_HISTORY_UPDATE:
return state.set('tagHistory', fromJS(action.tags));
case TIMELINE_DELETE:
if (action.id === state.get('in_reply_to')) {
case timelineDelete.type:
if (action.payload.statusId === state.get('in_reply_to')) {
return state.set('in_reply_to', null);
} else if (action.id === state.get('id')) {
} else if (action.payload.statusId === state.get('id')) {
return state.set('id', null);
} else {
return state;
Expand Down
8 changes: 5 additions & 3 deletions app/javascript/mastodon/reducers/contexts.js
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
blockAccountSuccess,
muteAccountSuccess,
} from '../actions/accounts';
import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
import { TIMELINE_DELETE, TIMELINE_UPDATE } from '../actions/timelines';
import { TIMELINE_UPDATE } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -97,8 +99,8 @@ export default function replies(state = initialState, action) {
return filterContexts(state, action.payload.relationship, action.payload.statuses);
case CONTEXT_FETCH_SUCCESS:
return normalizeContext(state, action.id, action.ancestors, action.descendants);
case TIMELINE_DELETE:
return deleteFromContexts(state, [action.id]);
case timelineDelete.type:
return deleteFromContexts(state, [action.payload.statusId]);
case TIMELINE_UPDATE:
return updateContext(state, action.status);
default:
Expand Down
7 changes: 4 additions & 3 deletions app/javascript/mastodon/reducers/modal.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
import type { Reducer } from '@reduxjs/toolkit';
import { Record as ImmutableRecord, Stack } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import { COMPOSE_UPLOAD_CHANGE_SUCCESS } from '../actions/compose';
import type { ModalType } from '../actions/modal';
import { openModal, closeModal } from '../actions/modal';
import { TIMELINE_DELETE } from '../actions/timelines';

export type ModalProps = Record<string, unknown>;
interface Modal {
Expand DownExpand Up@@ -72,10 +73,10 @@ export const modalReducer: Reducer<State> = (state = initialState, action) => {
// TODO: type those actions
else if (action.type === COMPOSE_UPLOAD_CHANGE_SUCCESS)
return popModal(state, { modalType: 'FOCAL_POINT', ignoreFocus: false });
else if (action.type === TIMELINE_DELETE)
else if (timelineDelete.match(action))
return state.update('stack', (stack) =>
stack.filterNot(
(modal) => modal.get('modalProps').statusId === action.id,
(modal) => modal.get('modalProps').statusId === action.payload.statusId,
),
);
else return state;
Expand Down
13 changes: 7 additions & 6 deletions app/javascript/mastodon/reducers/notifications.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import { fromJS, Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { blockDomainSuccess } from 'mastodon/actions/domain_blocks';
import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
authorizeFollowRequestSuccess,
Expand DownExpand Up@@ -30,7 +31,7 @@ import {
NOTIFICATIONS_SET_BROWSER_SUPPORT,
NOTIFICATIONS_SET_BROWSER_PERMISSION,
} from '../actions/notifications';
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines';
import { disconnectTimeline } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -291,11 +292,11 @@ export default function notifications(state = initialState, action) {
return filterNotifications(state, [action.payload.id], 'follow_request');
case NOTIFICATIONS_CLEAR:
return state.set('items', ImmutableList()).set('pendingItems', ImmutableList()).set('hasMore', false);
case TIMELINE_DELETE:
return deleteByStatus(state, action.id);
case TIMELINE_DISCONNECT:
return action.timeline === 'home' ?
state.update(action.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
case timelineDelete.type:
return deleteByStatus(state, action.payload.statusId);
case disconnectTimeline.type:
return action.payload.timeline === 'home' ?
state.update(action.payload.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
state;
case NOTIFICATIONS_MARK_AS_READ:
const lastNotification = state.get('items').find(item => item !== null);
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Head1 by hackal · Pull Request #3 · CallstackAI/mastodon · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .callstack.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
# yaml-language-server: $schema=https://storage.googleapis.com/config-schema/schema.v2.json

pr_review:
modules:
bug_hunter:
enabled: true
suggestions: true

code_suggestions:
enabled: false

code_conventions:
enabled: false
conventions: |
Exported code should be defined before internal code.

description:
enabled: true
diagram: true

grammar:
enabled: true

performance:
enabled: true

security:
enabled: true

exclude:
- "**/go.*"
33 changes: 33 additions & 0 deletions .github/workflows/reviewer.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
name: Cal PR Review

on:
workflow_dispatch:
inputs:
config:
type: string
description: "config for reviewer"
required: true
head:
type: string
description: "head commit sha"
required: true
base:
type: string
description: "base commit sha"
required: false
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.head }}

- name: Run reviewer
uses: addnab/docker-run-action@v3
with:
image: callstackai/cal:latest
options: -v ${{ github.workspace }}:/code
run: |
/reviewer --dir /code --id ${{ github.run_id }} --token ${{ github.token }} --config "${{ inputs.config }}"
50 changes: 3 additions & 47 deletions .rubocop_todo.yml
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.63.5.
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.64.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand DownExpand Up@@ -55,7 +55,6 @@ Style/FetchEnvVar:
- 'config/initializers/vapid.rb'
- 'lib/mastodon/redis_config.rb'
- 'lib/tasks/repo.rake'
- 'spec/system/profile_spec.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
Expand All@@ -66,40 +65,10 @@ Style/FormatStringToken:
- 'config/initializers/devise.rb'
- 'lib/paperclip/color_extractor.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'config/environments/development.rb'
- 'config/environments/production.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
Exclude:
- 'app/lib/activitypub/activity/block.rb'
- 'app/lib/request.rb'
- 'app/lib/request_pool.rb'
- 'app/lib/webfinger.rb'
- 'app/lib/webfinger_resource.rb'
- 'app/models/concerns/account/counters.rb'
- 'app/models/concerns/user/ldap_authenticable.rb'
- 'app/models/tag.rb'
- 'app/models/user.rb'
- 'app/services/fan_out_on_write_service.rb'
- 'app/services/post_status_service.rb'
- 'app/services/process_hashtags_service.rb'
- 'app/workers/move_worker.rb'
- 'app/workers/redownload_avatar_worker.rb'
- 'app/workers/redownload_header_worker.rb'
- 'app/workers/redownload_media_worker.rb'
- 'app/workers/remote_account_refresh_worker.rb'
- 'config/initializers/devise.rb'
- 'lib/devise/strategies/two_factor_ldap_authenticatable.rb'
- 'lib/devise/strategies/two_factor_pam_authenticatable.rb'
- 'lib/mastodon/cli/accounts.rb'
- 'lib/mastodon/cli/maintenance.rb'
- 'lib/mastodon/cli/media.rb'
- 'lib/tasks/repo.rake'
Enabled: false

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashTransformValues:
Expand All@@ -121,16 +90,10 @@ Style/MutableConstant:
- 'app/services/delete_account_service.rb'
- 'lib/mastodon/migration_warning.rb'

# This cop supports safe autocorrection (--autocorrect).
Style/NilLambda:
Exclude:
- 'config/initializers/paperclip.rb'

# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'app/helpers/admin/account_moderation_notes_helper.rb'
- 'app/helpers/jsonld_helper.rb'
- 'app/lib/admin/system_check/message.rb'
- 'app/lib/request.rb'
Expand All@@ -154,13 +117,6 @@ Style/RedundantConstantBase:
- 'config/environments/production.rb'
- 'config/initializers/sidekiq.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'app/models/concerns/account/finder_concern.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: WordRegex.
# SupportedStyles: percent, brackets
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2_alpha/notifications_controller.rb
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@ def index
@relationships = StatusRelationshipsPresenter.new(target_statuses_from_notifications, current_user&.account_id)
end

render json: @notifications.map { |notification| NotificationGroup.from_notification(notification) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
render json: @notifications.map { |notification| NotificationGroup.from_notification(notification, max_id: @group_metadata.dig(notification.group_key, :max_id)) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/actions/streaming.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
},

onDisconnect() {
dispatch(disconnectTimeline(timelineId));
dispatch(disconnectTimeline({ timeline: timelineId }));

if (options.fallback) {
// @ts-expect-error
Expand Down
21 changes: 5 additions & 16 deletions app/javascript/mastodon/actions/timelines.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,9 +6,11 @@ import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

import { importFetchedStatus, importFetchedStatuses } from './importer';
import { submitMarkers } from './markers';
import {timelineDelete} from './timelines_typed';

export { disconnectTimeline } from './timelines_typed';

export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
export const TIMELINE_CLEAR = 'TIMELINE_CLEAR';

export const TIMELINE_EXPAND_REQUEST = 'TIMELINE_EXPAND_REQUEST';
Expand All@@ -17,7 +19,6 @@ export const TIMELINE_EXPAND_FAIL = 'TIMELINE_EXPAND_FAIL';

export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
export const TIMELINE_LOAD_PENDING = 'TIMELINE_LOAD_PENDING';
export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
export const TIMELINE_CONNECT = 'TIMELINE_CONNECT';

export const TIMELINE_MARK_AS_PARTIAL = 'TIMELINE_MARK_AS_PARTIAL';
Expand DownExpand Up@@ -62,16 +63,10 @@ export function updateTimeline(timeline, status, accept) {
export function deleteFromTimelines(id) {
return (dispatch, getState) => {
const accountId = getState().getIn(['statuses', id, 'account']);
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id'));
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id')).toText();
const reblogOf = getState().getIn(['statuses', id, 'reblog'], null);

dispatch({
type: TIMELINE_DELETE,
id,
accountId,
references,
reblogOf,
});
dispatch(timelineDelete(id, accountId, reference, reblogOf));
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
};
}

Expand DownExpand Up@@ -225,12 +220,6 @@ export function connectTimeline(timeline) {
};
}

export const disconnectTimeline = timeline => ({
type: TIMELINE_DISCONNECT,
timeline,
usePendingItems: preferPendingItems,
});

export const markAsPartial = timeline => ({
type: TIMELINE_MARK_AS_PARTIAL,
timeline,
Expand Down
20 changes: 20 additions & 0 deletions app/javascript/mastodon/actions/timelines_typed.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
import { createAction } from '@reduxjs/toolkit';

import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

export const disconnectTimeline = createAction(
'timeline/disconnect',
({ timeline }: { timeline: string }) => ({
payload: {
timeline,
usePendingItems: preferPendingItems,
},
}),
);

export const timelineDelete = createAction<{
statusId: string;
accountId: string;
references: string[];
reblogOf: string | null;
}>('timelines/delete');
4 changes: 2 additions & 2 deletions app/javascript/mastodon/features/account_timeline/index.jsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -133,15 +133,15 @@ class AccountTimeline extends ImmutablePureComponent {
}

if (prevProps.accountId === me && accountId !== me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

componentWillUnmount () {
const { dispatch, accountId } = this.props;

if (accountId === me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/locales/ko.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@
"account.featured_tags.last_status_never": "게시물 없음",
"account.featured_tags.title": "{name} 님의 추천 해시태그",
"account.follow": "팔로우",
"account.follow_back": "맞팔로우",
"account.follow_back": "맞팔로우 하기",
"account.followers": "팔로워",
"account.followers.empty": "아직 아무도 이 사용자를 팔로우하고 있지 않습니다.",
"account.followers_counter": "{counter} 팔로워",
Expand All@@ -53,7 +53,7 @@
"account.mute_notifications_short": "알림 뮤트",
"account.mute_short": "뮤트",
"account.muted": "뮤트됨",
"account.mutual": "상호 팔로우",
"account.mutual": "맞팔로우 중",
"account.no_bio": "제공된 설명이 없습니다.",
"account.open_original_page": "원본 페이지 열기",
"account.posts": "게시물",
Expand Down
9 changes: 5 additions & 4 deletions app/javascript/mastodon/reducers/compose.js
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
COMPOSE_MOUNT,
COMPOSE_UNMOUNT,
Expand DownExpand Up@@ -51,7 +53,6 @@ import {
} from '../actions/compose';
import { REDRAFT } from '../actions/statuses';
import { STORE_HYDRATE } from '../actions/store';
import { TIMELINE_DELETE } from '../actions/timelines';
import { me } from '../initial_state';
import { unescapeHTML } from '../utils/html';
import { uuid } from '../uuid';
Expand DownExpand Up@@ -446,10 +447,10 @@ export default function compose(state = initialState, action) {
return updateSuggestionTags(state, action.token);
case COMPOSE_TAG_HISTORY_UPDATE:
return state.set('tagHistory', fromJS(action.tags));
case TIMELINE_DELETE:
if (action.id === state.get('in_reply_to')) {
case timelineDelete.type:
if (action.payload.statusId === state.get('in_reply_to')) {
return state.set('in_reply_to', null);
} else if (action.id === state.get('id')) {
} else if (action.payload.statusId === state.get('id')) {
return state.set('id', null);
} else {
return state;
Expand Down
8 changes: 5 additions & 3 deletions app/javascript/mastodon/reducers/contexts.js
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
blockAccountSuccess,
muteAccountSuccess,
} from '../actions/accounts';
import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
import { TIMELINE_DELETE, TIMELINE_UPDATE } from '../actions/timelines';
import { TIMELINE_UPDATE } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -97,8 +99,8 @@ export default function replies(state = initialState, action) {
return filterContexts(state, action.payload.relationship, action.payload.statuses);
case CONTEXT_FETCH_SUCCESS:
return normalizeContext(state, action.id, action.ancestors, action.descendants);
case TIMELINE_DELETE:
return deleteFromContexts(state, [action.id]);
case timelineDelete.type:
return deleteFromContexts(state, [action.payload.statusId]);
case TIMELINE_UPDATE:
return updateContext(state, action.status);
default:
Expand Down
7 changes: 4 additions & 3 deletions app/javascript/mastodon/reducers/modal.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
import type { Reducer } from '@reduxjs/toolkit';
import { Record as ImmutableRecord, Stack } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import { COMPOSE_UPLOAD_CHANGE_SUCCESS } from '../actions/compose';
import type { ModalType } from '../actions/modal';
import { openModal, closeModal } from '../actions/modal';
import { TIMELINE_DELETE } from '../actions/timelines';

export type ModalProps = Record<string, unknown>;
interface Modal {
Expand DownExpand Up@@ -72,10 +73,10 @@ export const modalReducer: Reducer<State> = (state = initialState, action) => {
// TODO: type those actions
else if (action.type === COMPOSE_UPLOAD_CHANGE_SUCCESS)
return popModal(state, { modalType: 'FOCAL_POINT', ignoreFocus: false });
else if (action.type === TIMELINE_DELETE)
else if (timelineDelete.match(action))
return state.update('stack', (stack) =>
stack.filterNot(
(modal) => modal.get('modalProps').statusId === action.id,
(modal) => modal.get('modalProps').statusId === action.payload.statusId,
),
);
else return state;
Expand Down
13 changes: 7 additions & 6 deletions app/javascript/mastodon/reducers/notifications.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import { fromJS, Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { blockDomainSuccess } from 'mastodon/actions/domain_blocks';
import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
authorizeFollowRequestSuccess,
Expand DownExpand Up@@ -30,7 +31,7 @@ import {
NOTIFICATIONS_SET_BROWSER_SUPPORT,
NOTIFICATIONS_SET_BROWSER_PERMISSION,
} from '../actions/notifications';
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines';
import { disconnectTimeline } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -291,11 +292,11 @@ export default function notifications(state = initialState, action) {
return filterNotifications(state, [action.payload.id], 'follow_request');
case NOTIFICATIONS_CLEAR:
return state.set('items', ImmutableList()).set('pendingItems', ImmutableList()).set('hasMore', false);
case TIMELINE_DELETE:
return deleteByStatus(state, action.id);
case TIMELINE_DISCONNECT:
return action.timeline === 'home' ?
state.update(action.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
case timelineDelete.type:
return deleteByStatus(state, action.payload.statusId);
case disconnectTimeline.type:
return action.payload.timeline === 'home' ?
state.update(action.payload.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
state;
case NOTIFICATIONS_MARK_AS_READ:
const lastNotification = state.get('items').find(item => item !== null);
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Head1 by hackal · Pull Request #3 · CallstackAI/mastodon · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .callstack.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
# yaml-language-server: $schema=https://storage.googleapis.com/config-schema/schema.v2.json

pr_review:
modules:
bug_hunter:
enabled: true
suggestions: true

code_suggestions:
enabled: false

code_conventions:
enabled: false
conventions: |
Exported code should be defined before internal code.

description:
enabled: true
diagram: true

grammar:
enabled: true

performance:
enabled: true

security:
enabled: true

exclude:
- "**/go.*"
33 changes: 33 additions & 0 deletions .github/workflows/reviewer.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
name: Cal PR Review

on:
workflow_dispatch:
inputs:
config:
type: string
description: "config for reviewer"
required: true
head:
type: string
description: "head commit sha"
required: true
base:
type: string
description: "base commit sha"
required: false
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.head }}

- name: Run reviewer
uses: addnab/docker-run-action@v3
with:
image: callstackai/cal:latest
options: -v ${{ github.workspace }}:/code
run: |
/reviewer --dir /code --id ${{ github.run_id }} --token ${{ github.token }} --config "${{ inputs.config }}"
50 changes: 3 additions & 47 deletions .rubocop_todo.yml
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.63.5.
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp`
# using RuboCop version 1.64.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand DownExpand Up@@ -55,7 +55,6 @@ Style/FetchEnvVar:
- 'config/initializers/vapid.rb'
- 'lib/mastodon/redis_config.rb'
- 'lib/tasks/repo.rake'
- 'spec/system/profile_spec.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
Expand All@@ -66,40 +65,10 @@ Style/FormatStringToken:
- 'config/initializers/devise.rb'
- 'lib/paperclip/color_extractor.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'config/environments/development.rb'
- 'config/environments/production.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
Exclude:
- 'app/lib/activitypub/activity/block.rb'
- 'app/lib/request.rb'
- 'app/lib/request_pool.rb'
- 'app/lib/webfinger.rb'
- 'app/lib/webfinger_resource.rb'
- 'app/models/concerns/account/counters.rb'
- 'app/models/concerns/user/ldap_authenticable.rb'
- 'app/models/tag.rb'
- 'app/models/user.rb'
- 'app/services/fan_out_on_write_service.rb'
- 'app/services/post_status_service.rb'
- 'app/services/process_hashtags_service.rb'
- 'app/workers/move_worker.rb'
- 'app/workers/redownload_avatar_worker.rb'
- 'app/workers/redownload_header_worker.rb'
- 'app/workers/redownload_media_worker.rb'
- 'app/workers/remote_account_refresh_worker.rb'
- 'config/initializers/devise.rb'
- 'lib/devise/strategies/two_factor_ldap_authenticatable.rb'
- 'lib/devise/strategies/two_factor_pam_authenticatable.rb'
- 'lib/mastodon/cli/accounts.rb'
- 'lib/mastodon/cli/maintenance.rb'
- 'lib/mastodon/cli/media.rb'
- 'lib/tasks/repo.rake'
Enabled: false

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashTransformValues:
Expand All@@ -121,16 +90,10 @@ Style/MutableConstant:
- 'app/services/delete_account_service.rb'
- 'lib/mastodon/migration_warning.rb'

# This cop supports safe autocorrection (--autocorrect).
Style/NilLambda:
Exclude:
- 'config/initializers/paperclip.rb'

# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'app/helpers/admin/account_moderation_notes_helper.rb'
- 'app/helpers/jsonld_helper.rb'
- 'app/lib/admin/system_check/message.rb'
- 'app/lib/request.rb'
Expand All@@ -154,13 +117,6 @@ Style/RedundantConstantBase:
- 'config/environments/production.rb'
- 'config/initializers/sidekiq.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'app/models/concerns/account/finder_concern.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: WordRegex.
# SupportedStyles: percent, brackets
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2_alpha/notifications_controller.rb
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@ def index
@relationships = StatusRelationshipsPresenter.new(target_statuses_from_notifications, current_user&.account_id)
end

render json: @notifications.map { |notification| NotificationGroup.from_notification(notification) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
render json: @notifications.map { |notification| NotificationGroup.from_notification(notification, max_id: @group_metadata.dig(notification.group_key, :max_id)) }, each_serializer: REST::NotificationGroupSerializer, relationships: @relationships, group_metadata: @group_metadata
end

def show
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/actions/streaming.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
},

onDisconnect() {
dispatch(disconnectTimeline(timelineId));
dispatch(disconnectTimeline({ timeline: timelineId }));

if (options.fallback) {
// @ts-expect-error
Expand Down
21 changes: 5 additions & 16 deletions app/javascript/mastodon/actions/timelines.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,9 +6,11 @@ import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

import { importFetchedStatus, importFetchedStatuses } from './importer';
import { submitMarkers } from './markers';
import {timelineDelete} from './timelines_typed';

export { disconnectTimeline } from './timelines_typed';

export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
export const TIMELINE_DELETE = 'TIMELINE_DELETE';
export const TIMELINE_CLEAR = 'TIMELINE_CLEAR';

export const TIMELINE_EXPAND_REQUEST = 'TIMELINE_EXPAND_REQUEST';
Expand All@@ -17,7 +19,6 @@ export const TIMELINE_EXPAND_FAIL = 'TIMELINE_EXPAND_FAIL';

export const TIMELINE_SCROLL_TOP = 'TIMELINE_SCROLL_TOP';
export const TIMELINE_LOAD_PENDING = 'TIMELINE_LOAD_PENDING';
export const TIMELINE_DISCONNECT = 'TIMELINE_DISCONNECT';
export const TIMELINE_CONNECT = 'TIMELINE_CONNECT';

export const TIMELINE_MARK_AS_PARTIAL = 'TIMELINE_MARK_AS_PARTIAL';
Expand DownExpand Up@@ -62,16 +63,10 @@ export function updateTimeline(timeline, status, accept) {
export function deleteFromTimelines(id) {
return (dispatch, getState) => {
const accountId = getState().getIn(['statuses', id, 'account']);
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id'));
const references = getState().get('statuses').filter(status => status.get('reblog') === id).map(status => status.get('id')).toText();
const reblogOf = getState().getIn(['statuses', id, 'reblog'], null);

dispatch({
type: TIMELINE_DELETE,
id,
accountId,
references,
reblogOf,
});
dispatch(timelineDelete(id, accountId, reference, reblogOf));
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
Comment thread
hackal marked this conversation as resolved.
};
}

Expand DownExpand Up@@ -225,12 +220,6 @@ export function connectTimeline(timeline) {
};
}

export const disconnectTimeline = timeline => ({
type: TIMELINE_DISCONNECT,
timeline,
usePendingItems: preferPendingItems,
});

export const markAsPartial = timeline => ({
type: TIMELINE_MARK_AS_PARTIAL,
timeline,
Expand Down
20 changes: 20 additions & 0 deletions app/javascript/mastodon/actions/timelines_typed.ts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
import { createAction } from '@reduxjs/toolkit';

import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';

export const disconnectTimeline = createAction(
'timeline/disconnect',
({ timeline }: { timeline: string }) => ({
payload: {
timeline,
usePendingItems: preferPendingItems,
},
}),
);

export const timelineDelete = createAction<{
statusId: string;
accountId: string;
references: string[];
reblogOf: string | null;
}>('timelines/delete');
4 changes: 2 additions & 2 deletions app/javascript/mastodon/features/account_timeline/index.jsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -133,15 +133,15 @@ class AccountTimeline extends ImmutablePureComponent {
}

if (prevProps.accountId === me && accountId !== me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

componentWillUnmount () {
const { dispatch, accountId } = this.props;

if (accountId === me) {
dispatch(disconnectTimeline(`account:${me}`));
dispatch(disconnectTimeline({ timeline: `account:${me}` }));
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/mastodon/locales/ko.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@
"account.featured_tags.last_status_never": "게시물 없음",
"account.featured_tags.title": "{name} 님의 추천 해시태그",
"account.follow": "팔로우",
"account.follow_back": "맞팔로우",
"account.follow_back": "맞팔로우 하기",
"account.followers": "팔로워",
"account.followers.empty": "아직 아무도 이 사용자를 팔로우하고 있지 않습니다.",
"account.followers_counter": "{counter} 팔로워",
Expand All@@ -53,7 +53,7 @@
"account.mute_notifications_short": "알림 뮤트",
"account.mute_short": "뮤트",
"account.muted": "뮤트됨",
"account.mutual": "상호 팔로우",
"account.mutual": "맞팔로우 중",
"account.no_bio": "제공된 설명이 없습니다.",
"account.open_original_page": "원본 페이지 열기",
"account.posts": "게시물",
Expand Down
9 changes: 5 additions & 4 deletions app/javascript/mastodon/reducers/compose.js
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
COMPOSE_MOUNT,
COMPOSE_UNMOUNT,
Expand DownExpand Up@@ -51,7 +53,6 @@ import {
} from '../actions/compose';
import { REDRAFT } from '../actions/statuses';
import { STORE_HYDRATE } from '../actions/store';
import { TIMELINE_DELETE } from '../actions/timelines';
import { me } from '../initial_state';
import { unescapeHTML } from '../utils/html';
import { uuid } from '../uuid';
Expand DownExpand Up@@ -446,10 +447,10 @@ export default function compose(state = initialState, action) {
return updateSuggestionTags(state, action.token);
case COMPOSE_TAG_HISTORY_UPDATE:
return state.set('tagHistory', fromJS(action.tags));
case TIMELINE_DELETE:
if (action.id === state.get('in_reply_to')) {
case timelineDelete.type:
if (action.payload.statusId === state.get('in_reply_to')) {
return state.set('in_reply_to', null);
} else if (action.id === state.get('id')) {
} else if (action.payload.statusId === state.get('id')) {
return state.set('id', null);
} else {
return state;
Expand Down
8 changes: 5 additions & 3 deletions app/javascript/mastodon/reducers/contexts.js
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
blockAccountSuccess,
muteAccountSuccess,
} from '../actions/accounts';
import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
import { TIMELINE_DELETE, TIMELINE_UPDATE } from '../actions/timelines';
import { TIMELINE_UPDATE } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -97,8 +99,8 @@ export default function replies(state = initialState, action) {
return filterContexts(state, action.payload.relationship, action.payload.statuses);
case CONTEXT_FETCH_SUCCESS:
return normalizeContext(state, action.id, action.ancestors, action.descendants);
case TIMELINE_DELETE:
return deleteFromContexts(state, [action.id]);
case timelineDelete.type:
return deleteFromContexts(state, [action.payload.statusId]);
case TIMELINE_UPDATE:
return updateContext(state, action.status);
default:
Expand Down
7 changes: 4 additions & 3 deletions app/javascript/mastodon/reducers/modal.ts
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
import type { Reducer } from '@reduxjs/toolkit';
import { Record as ImmutableRecord, Stack } from 'immutable';

import { timelineDelete } from 'mastodon/actions/timelines_typed';

import { COMPOSE_UPLOAD_CHANGE_SUCCESS } from '../actions/compose';
import type { ModalType } from '../actions/modal';
import { openModal, closeModal } from '../actions/modal';
import { TIMELINE_DELETE } from '../actions/timelines';

export type ModalProps = Record<string, unknown>;
interface Modal {
Expand DownExpand Up@@ -72,10 +73,10 @@ export const modalReducer: Reducer<State> = (state = initialState, action) => {
// TODO: type those actions
else if (action.type === COMPOSE_UPLOAD_CHANGE_SUCCESS)
return popModal(state, { modalType: 'FOCAL_POINT', ignoreFocus: false });
else if (action.type === TIMELINE_DELETE)
else if (timelineDelete.match(action))
return state.update('stack', (stack) =>
stack.filterNot(
(modal) => modal.get('modalProps').statusId === action.id,
(modal) => modal.get('modalProps').statusId === action.payload.statusId,
),
);
else return state;
Expand Down
13 changes: 7 additions & 6 deletions app/javascript/mastodon/reducers/notifications.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import { fromJS, Map as ImmutableMap, List as ImmutableList } from 'immutable';

import { blockDomainSuccess } from 'mastodon/actions/domain_blocks';
import { timelineDelete } from 'mastodon/actions/timelines_typed';

import {
authorizeFollowRequestSuccess,
Expand DownExpand Up@@ -30,7 +31,7 @@ import {
NOTIFICATIONS_SET_BROWSER_SUPPORT,
NOTIFICATIONS_SET_BROWSER_PERMISSION,
} from '../actions/notifications';
import { TIMELINE_DELETE, TIMELINE_DISCONNECT } from '../actions/timelines';
import { disconnectTimeline } from '../actions/timelines';
import { compareId } from '../compare_id';

const initialState = ImmutableMap({
Expand DownExpand Up@@ -291,11 +292,11 @@ export default function notifications(state = initialState, action) {
return filterNotifications(state, [action.payload.id], 'follow_request');
case NOTIFICATIONS_CLEAR:
return state.set('items', ImmutableList()).set('pendingItems', ImmutableList()).set('hasMore', false);
case TIMELINE_DELETE:
return deleteByStatus(state, action.id);
case TIMELINE_DISCONNECT:
return action.timeline === 'home' ?
state.update(action.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
case timelineDelete.type:
return deleteByStatus(state, action.payload.statusId);
case disconnectTimeline.type:
return action.payload.timeline === 'home' ?
state.update(action.payload.usePendingItems ? 'pendingItems' : 'items', items => items.first() ? items.unshift(null) : items) :
state;
case NOTIFICATIONS_MARK_AS_READ:
const lastNotification = state.get('items').find(item => item !== null);
Expand Down
Loading