forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2860 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes up to 9d664f8
- Loading branch information
Showing
240 changed files
with
3,060 additions
and
1,468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/controllers/api/v1/domain_blocks/previews_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
class Api::V1::DomainBlocks::PreviewsController < Api::BaseController | ||
before_action -> { doorkeeper_authorize! :follow, :write, :'write:blocks' } | ||
before_action :require_user! | ||
before_action :set_domain | ||
before_action :set_domain_block_preview | ||
|
||
def show | ||
render json: @domain_block_preview, serializer: REST::DomainBlockPreviewSerializer | ||
end | ||
|
||
private | ||
|
||
def set_domain | ||
@domain = TagManager.instance.normalize_domain(params[:domain]) | ||
end | ||
|
||
def set_domain_block_preview | ||
@domain_block_preview = with_read_replica do | ||
DomainBlockPreviewPresenter.new( | ||
following_count: current_account.following.where(domain: @domain).count, | ||
followers_count: current_account.followers.where(domain: @domain).count | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
app/javascript/flavours/glitch/components/alt_text_badge.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { useState, useCallback, useRef } from 'react'; | ||
|
||
import { FormattedMessage } from 'react-intl'; | ||
|
||
import Overlay from 'react-overlays/Overlay'; | ||
import type { | ||
OffsetValue, | ||
UsePopperOptions, | ||
} from 'react-overlays/esm/usePopper'; | ||
|
||
const offset = [0, 4] as OffsetValue; | ||
const popperConfig = { strategy: 'fixed' } as UsePopperOptions; | ||
|
||
export const AltTextBadge: React.FC<{ | ||
description: string; | ||
}> = ({ description }) => { | ||
const anchorRef = useRef<HTMLButtonElement>(null); | ||
const [open, setOpen] = useState(false); | ||
|
||
const handleClick = useCallback(() => { | ||
setOpen((v) => !v); | ||
}, [setOpen]); | ||
|
||
const handleClose = useCallback(() => { | ||
setOpen(false); | ||
}, [setOpen]); | ||
|
||
return ( | ||
<> | ||
<button | ||
ref={anchorRef} | ||
className='media-gallery__alt__label' | ||
onClick={handleClick} | ||
> | ||
ALT | ||
</button> | ||
|
||
<Overlay | ||
rootClose | ||
onHide={handleClose} | ||
show={open} | ||
target={anchorRef.current} | ||
placement='top-end' | ||
flip | ||
offset={offset} | ||
popperConfig={popperConfig} | ||
> | ||
{({ props }) => ( | ||
<div {...props} className='hover-card-controller'> | ||
<div | ||
className='media-gallery__alt__popover dropdown-animation' | ||
role='tooltip' | ||
> | ||
<h4> | ||
<FormattedMessage | ||
id='alt_text_badge.title' | ||
defaultMessage='Alt text' | ||
/> | ||
</h4> | ||
<p>{description}</p> | ||
</div> | ||
</div> | ||
)} | ||
</Overlay> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.