Skip to content

Commit

Permalink
re-add nano tips
Browse files Browse the repository at this point in the history
  • Loading branch information
nano2dev committed Mar 2, 2024
1 parent 482ec12 commit e643366
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 807 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import RepeatPrivateActiveIcon from '@/svg-icons/repeat_private_active.svg?react
import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'mastodon/permissions';
import { WithRouterPropTypes } from 'mastodon/utils/react_router';

import api from '../api';
import { IconButton } from '../../../components/icon_button';
import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
import { me } from '../../../initial_state';
Expand Down Expand Up @@ -105,6 +106,45 @@ class ActionBar extends PureComponent {
this.props.onReblog(this.props.status, e);
};

handleTipClick = () => {

const { status } = this.props;

const id = status.getIn(['account', 'id'])

api().get(`/api/v1/accounts/${id}`).then(response => {

if (!response.data.fields || !response.data.fields.length) return window.alert('User does not have a nano address.')

var raw_address = response.data.fields.find(a => a.value && a.value.includes('nano_'))
var nano_to_name = response.data.fields.find(a => a.value && (a.value.includes('ӿ.to/') || a.value.includes('nano.to/') || a.value.includes('xno.to/')))

if (raw_address) return window.location.href = `nano:${raw_address.value}`;

if (nano_to_name) {
api().get('/api/v1/streaming/nano_known').then(known => {
console.log( response.data.fields )

Check warning on line 126 in app/javascript/mastodon/features/status/components/action_bar.jsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
var name = nano_to_name.value.match(/href="([^"]*)"/)[1]
name = name.replace('https://', '').replace('http://', '')
name = name.split('/')[1]
var account = known.data.find(a => a.name.toLowerCase() === name.toLowerCase())
if (account) return window.location.href = `nano:${account.address}`
return window.alert('This user has a Nano.to Name that is invalid or expired.')
}).catch((e) => {
console.log(e)

Check warning on line 134 in app/javascript/mastodon/features/status/components/action_bar.jsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
})
}

if (!raw_address && !nano_to_name) return window.alert('User does not have a nano address.')

return false

}).catch((e) => {
console.log(e)

Check warning on line 143 in app/javascript/mastodon/features/status/components/action_bar.jsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
})

};

handleFavouriteClick = () => {
this.props.onFavourite(this.props.status);
};
Expand Down Expand Up @@ -315,7 +355,11 @@ class ActionBar extends PureComponent {
<div className='detailed-status__button'><IconButton title={intl.formatMessage(messages.reply)} icon={status.get('in_reply_to_account_id') === status.getIn(['account', 'id']) ? 'reply' : replyIcon} iconComponent={status.get('in_reply_to_account_id') === status.getIn(['account', 'id']) ? ReplyIcon : replyIconComponent} onClick={this.handleReplyClick} /></div>
<div className='detailed-status__button'><IconButton className={classNames({ reblogPrivate })} disabled={!publicStatus && !reblogPrivate} active={status.get('reblogged')} title={reblogTitle} icon='retweet' iconComponent={reblogIconComponent} onClick={this.handleReblogClick} /></div>
<div className='detailed-status__button'><IconButton className='star-icon' animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' iconComponent={status.get('favourited') ? StarIcon : StarBorderIcon} onClick={this.handleFavouriteClick} /></div>
<div className='detailed-status__button'><IconButton className='bookmark-icon' disabled={!signedIn} active={status.get('bookmarked')} title={intl.formatMessage(messages.bookmark)} icon='bookmark' iconComponent={status.get('bookmarked') ? BookmarkIcon : BookmarkBorderIcon} onClick={this.handleBookmarkClick} /></div>
{/*<div className='detailed-status__button'><IconButton className='bookmark-icon' disabled={!signedIn} active={status.get('bookmarked')} title={intl.formatMessage(messages.bookmark)} icon='bookmark' iconComponent={status.get('bookmarked') ? BookmarkIcon : BookmarkBorderIcon} onClick={this.handleBookmarkClick} /></div>*/}

<button onClick={this.handleTipClick} className='status__action-bar__button icon-button'>
<img style={{ maxWidth: '16px', verticalAlign: 'middle' }} src='/nano-logo.png' alt='Nano Logo' className='logo logo--icon' />
</button>

<div className='detailed-status__action-bar-dropdown'>
<DropdownMenuContainer icon='ellipsis-h' iconComponent={MoreHorizIcon} status={status} items={menu} direction='left' title={intl.formatMessage(messages.more)} />
Expand Down
2 changes: 0 additions & 2 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@

= stylesheet_link_tag custom_css_path, skip_pipeline: true, host: root_url, media: 'all'

%script{ src: '/nanopay.js' }

= yield :header_tags

%body{ class: body_classes }
Expand Down
2 changes: 1 addition & 1 deletion config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
set :rbenv_ruby, File.read('.ruby-version').strip
set :migration_role, :app

append :linked_files, '.env.production', 'public/nanopay.js'
# append :linked_files, '.env.production', 'public/nanopay.js'
append :linked_files, '.env.production', 'public/nano-logo.png'

append :linked_files, '.env.production', 'public/robots.txt'
Expand Down
Loading

0 comments on commit e643366

Please sign in to comment.