Add reload button for iOS

This commit is contained in:
noellabo 2022-08-29 17:22:23 +09:00
parent 73df565bde
commit 17ecde6a6e
13 changed files with 63 additions and 1 deletions

View file

@ -94,6 +94,7 @@ class Settings::PreferencesController < Settings::BaseController
:setting_hide_bot_on_public_timeline,
:setting_confirm_follow_from_bot,
:setting_default_search_searchability,
:setting_show_reload_button,
notification_emails: %i(follow follow_request reblog favourite emoji_reaction status_reference mention digest report pending_account trending_tag),
interactions: %i(must_be_follower must_be_following must_be_following_dm)
)

View file

@ -0,0 +1,32 @@
import React from 'react';
import PropTypes from 'prop-types';
import { injectIntl, defineMessages } from 'react-intl';
import Icon from 'mastodon/components/icon';
const messages = defineMessages({
reload: { id: 'status.reload', defaultMessage: 'Reload' },
});
export default @injectIntl
class ReloadZone extends React.PureComponent {
static propTypes = {
onClick: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
};
handleClick = () => {
this.props.onClick();
}
render () {
const { intl } = this.props;
return (
<button className='load-more load-gap' onClick={this.handleClick} aria-label={intl.formatMessage(messages.reload)}>
<Icon id='refresh' />
</button>
);
}
}

View file

@ -4,9 +4,12 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import StatusContainer from '../containers/status_container';
import ImmutablePureComponent from 'react-immutable-pure-component';
import ReloadZone from './reload_zone';
import LoadGap from './load_gap';
import ScrollableList from './scrollable_list';
import RegenerationIndicator from 'mastodon/components/regeneration_indicator';
import { isIOS } from 'mastodon/is_mobile';
import { showReloadButton } from '../initial_state';
export default class StatusList extends ImmutablePureComponent {
@ -59,6 +62,10 @@ export default class StatusList extends ImmutablePureComponent {
this.props.onLoadMore(this.props.statusIds.size > 0 ? this.props.statusIds.last() : undefined);
}, 300, { leading: true })
handleReload = () => {
location.reload();
}
_selectChild (index, align_top) {
const container = this.node.node;
const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
@ -122,6 +129,10 @@ export default class StatusList extends ImmutablePureComponent {
)).concat(scrollableContent);
}
if (showReloadButton && scrollableContent && isIOS()) {
scrollableContent = scrollableContent.unshift(<ReloadZone key='reload' onClick={this.handleReload} />);
}
return (
<ScrollableList {...other} showLoading={isLoading && statusIds.size === 0} onLoadMore={onLoadMore && this.handleLoadOlder} ref={this.setRef}>
{scrollableContent}

View file

@ -51,5 +51,6 @@ export const enableStatusReference = getMeta('enable_status_reference');
export const maxReferences = initialState?.status_references?.max_references;
export const matchVisibilityOfReferences = getMeta('match_visibility_of_references');
export const enableEmptyColumn = getMeta('enable_empty_column');
export const showReloadButton = getMeta('show_reload_button');
export default initialState;

View file

@ -550,6 +550,7 @@
"status.redraft": "Delete & re-draft",
"status.reference": "Reference",
"status.referred_by": "Referred",
"status.reload": "Reload",
"status.remove_bookmark": "Remove bookmark",
"status.reply": "Reply",
"status.replyAll": "Reply to thread",

View file

@ -550,6 +550,7 @@
"status.redraft": "削除して下書きに戻す",
"status.reference": "参照",
"status.referred_by": "参照",
"status.reload": "再読み込み",
"status.remove_bookmark": "ブックマークを削除",
"status.reply": "返信",
"status.replyAll": "全員に返信",

View file

@ -88,6 +88,7 @@ class UserSettingsDecorator
user.settings['hide_bot_on_public_timeline'] = hide_bot_on_public_timeline_preference if change?('setting_hide_bot_on_public_timeline')
user.settings['confirm_follow_from_bot'] = confirm_follow_from_bot_preference if change?('setting_confirm_follow_from_bot')
user.settings['default_search_searchability'] = default_search_searchability_preference if change?('setting_default_search_searchability')
user.settings['show_reload_button'] = show_reload_button_preference if change?('setting_show_reload_button')
end
def merged_notification_emails
@ -326,6 +327,10 @@ end
settings['setting_default_search_searchability']
end
def show_reload_button_preference
boolean_cast_setting 'setting_show_reload_button'
end
def boolean_cast_setting(key)
ActiveModel::Type::Boolean.new.cast(settings[key])
end

View file

@ -142,6 +142,7 @@ class User < ApplicationRecord
:mobile_customize, :mobile_content_font_size, :mobile_info_font_size, :mobile_content_emoji_reaction_size,
:hide_bot_on_public_timeline, :confirm_follow_from_bot,
:default_search_searchability,
:show_reload_button,
to: :settings, prefix: :setting, allow_nil: false

View file

@ -70,7 +70,8 @@ class InitialStateSerializer < ActiveModel::Serializer
store[:info_font_size] = object.current_account.user.setting_info_font_size
store[:content_emoji_reaction_size] = object.current_account.user.setting_content_emoji_reaction_size
store[:hide_bot_on_public_timeline] = object.current_account.user.setting_hide_bot_on_public_timeline
store[:confirm_follow_from_bot] = object.current_account.user.setting_confirm_follow_from_bot
store[:confirm_follow_from_bot] = object.current_account.user.setting_confirm_follow_from_bot
store[:show_reload_button] = object.current_account.user.setting_show_reload_button
else
store[:auto_play_gif] = Setting.auto_play_gif
store[:display_media] = Setting.display_media

View file

@ -99,6 +99,9 @@
.fields-group
= f.input :setting_confirm_follow_from_bot, as: :boolean, wrapper: :with_label, fedibird_features: true
.fields-group
= f.input :setting_show_reload_button, as: :boolean, wrapper: :with_label, fedibird_features: true
-# .fields-group
-# = f.input :setting_show_target, as: :boolean, wrapper: :with_label

View file

@ -83,6 +83,7 @@ en:
setting_show_follow_button_on_timeline: You can easily check the follow status and build a follow list quickly
setting_show_navigation_panel: Show the navigation panel at the right end of the advanced UI
setting_show_quote_button: Selects whether to display the button on the action bar. It does not enable/disable the citation function.
setting_show_reload_button: Show reload button at the top of the iPhone / iPad timeline
setting_show_reply_tree_button: Blue marker for replies to another post, yellow marker for posts with replies, and green marker for both
setting_show_subscribe_button_on_timeline: You can easily check the status of your subscriptions and quickly build a subscription list
setting_show_tab_bar_label: When adding a list etc. to the tab bar, it is recommended to display the label because it is not possible to distinguish by the icon alone
@ -257,6 +258,7 @@ en:
setting_show_follow_button_on_timeline: Show follow button on timeline
setting_show_navigation_panel: Show the navigation panel
setting_show_quote_button: Show the quote button on the action bar
setting_show_reload_button: Show reload button
setting_show_reply_tree_button: Show markers on posts where a reply relationship exists
setting_show_subscribe_button_on_timeline: Show subscribe button on timeline
setting_show_tab_bar_label: Show labels in the tab bar

View file

@ -83,6 +83,7 @@ ja:
setting_show_follow_button_on_timeline: フォロー状態を確認し易くなり、素早くフォローリストを構築できます
setting_show_navigation_panel: 上級者向け UI の右端にナビゲーションパネルを表示します
setting_show_quote_button: アクションバーへボタンを表示するかどうかの設定です。引用機能の有効・無効を切り替えるものではありません
setting_show_reload_button: iPhoneとiPadで、タイムラインの最上部に再読み込みボタンを表示します
setting_show_reply_tree_button: 別の投稿に対しての返信に青のマーカー、返信のついている投稿に黄色のマーカー、両方の場合は緑のマーカーを表示します
setting_show_subscribe_button_on_timeline: 購読状態を確認し易くなり、素早く購読リストを構築できます
setting_show_tab_bar_label: リスト等をタブバーに追加する場合、アイコンだけでは区別がつかないので、ラベルを表示することをおすすめします
@ -257,6 +258,7 @@ ja:
setting_show_follow_button_on_timeline: タイムライン上にフォローボタンを表示する
setting_show_navigation_panel: ナビゲーションパネルを表示する
setting_show_quote_button: 引用ボタンをアクションバーに表示する
setting_show_reload_button: 再読み込みボタンを表示する
setting_show_reply_tree_button: リプライ関係の存在する投稿にマーカーを表示する
setting_show_subscribe_button_on_timeline: タイムライン上に購読ボタンを表示する
setting_show_tab_bar_label: タブバーにラベルを表示する

View file

@ -107,6 +107,7 @@ defaults: &defaults
hide_bot_on_public_timeline: false
confirm_follow_from_bot: true
default_search_searchability: 'private'
show_reload_button: true
development:
<<: *defaults