Skip to content

Commit

Permalink
Add limited timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
noellabo authored and jesseplusplus committed Apr 1, 2022
1 parent a6351a3 commit 4119b65
Show file tree
Hide file tree
Showing 31 changed files with 2,233 additions and 743 deletions.
9 changes: 8 additions & 1 deletion app/controllers/api/v1/timelines/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def home_statuses
limit_param(DEFAULT_STATUSES_LIMIT),
params[:max_id],
params[:since_id],
params[:min_id]
params[:min_id],
visibilities
)
end

Expand Down Expand Up @@ -60,4 +61,10 @@ def pagination_max_id
def pagination_since_id
@statuses.first.id
end

def visibilities
val = params.permit(visibilities: [])[:visibilities] || []
val = [val] unless val.is_a?(Enumerable)
val
end
end
11 changes: 11 additions & 0 deletions app/controllers/settings/preferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ def user_settings_params
:setting_use_pending_items,
:setting_trends,
:setting_crop_images,
:setting_show_follow_button_on_timeline,
:setting_show_subscribe_button_on_timeline,
:setting_show_followed_by,
:setting_follow_button_to_list_adder,
:setting_show_navigation_panel,
:setting_show_quote_button,
:setting_show_bookmark_button,
:setting_place_tab_bar_at_bottom,
:setting_show_tab_bar_label,
:setting_show_target,
:setting_enable_limited_timeline,
notification_emails: %i(follow follow_request reblog favourite mention digest report pending_account trending_tag),
interactions: %i(must_be_follower must_be_following must_be_following_dm)
)
Expand Down
9 changes: 8 additions & 1 deletion app/javascript/mastodon/actions/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useEmoji } from './emojis';
import resizeImage from '../utils/resize_image';
import { importFetchedAccounts } from './importer';
import { updateTimeline } from './timelines';
import { getHomeVisibilities, getLimitedVisibilities } from 'mastodon/selectors';
import { showAlertForError } from './alerts';
import { showAlert } from './alerts';
import { openModal } from './modal';
Expand Down Expand Up @@ -140,6 +141,8 @@ export function submitCompose(routerHistory) {
return function (dispatch, getState) {
const status = getState().getIn(['compose', 'text'], '');
const media = getState().getIn(['compose', 'media_attachments']);
const homeVisibilities = getHomeVisibilities(getState());
const limitedVisibilities = getLimitedVisibilities(getState());

if ((!status || !status.length) && media.size === 0) {
return;
Expand Down Expand Up @@ -178,10 +181,14 @@ export function submitCompose(routerHistory) {
}
};

if (response.data.visibility !== 'direct') {
if (homeVisibilities.length == 0 || homeVisibilities.includes(response.data.visibility)) {
insertIfOnline('home');
}

if (limitedVisibilities.includes(response.data.visibility)) {
insertIfOnline('limited');
}

if (response.data.in_reply_to_id === null && response.data.visibility === 'public') {
insertIfOnline('community');
insertIfOnline('public');
Expand Down
11 changes: 7 additions & 4 deletions app/javascript/mastodon/actions/streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
connectTimeline,
disconnectTimeline,
} from './timelines';
import { getHomeVisibilities } from 'mastodon/selectors';
import { updateNotifications, expandNotifications } from './notifications';
import { updateConversations } from './conversations';
import {
Expand Down Expand Up @@ -44,10 +45,10 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
let pollingId;

/**
* @param {function(Function, Function): void} fallback
* @param {function(Function, Function, Function): void} fallback
*/
const useFallback = fallback => {
fallback(dispatch, () => {
fallback(dispatch, getState, () => {
pollingId = setTimeout(() => useFallback(fallback), 20000 + randomUpTo(20000));
});
};
Expand Down Expand Up @@ -105,8 +106,10 @@ export const connectTimelineStream = (timelineId, channelName, params = {}, opti
* @param {Function} dispatch
* @param {function(): void} done
*/
const refreshHomeTimelineAndNotification = (dispatch, done) => {
dispatch(expandHomeTimeline({}, () =>
const refreshHomeTimelineAndNotification = (dispatch, getState, done) => {
const visibilities = getHomeVisibilities(getState());

dispatch(expandHomeTimeline({ visibilities }, () =>
dispatch(expandNotifications({}, () =>
dispatch(fetchAnnouncements(done))))));
};
Expand Down
Loading

0 comments on commit 4119b65

Please sign in to comment.