1
0
mirror of https://github.com/flarum/core.git synced 2025-08-20 23:31:27 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
flarum-bot
5c901cfba8 Bundled output for commit be1b5713fa
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-03-10 01:00:54 +00:00
David Sevilla Martin
be1b5713fa Replace ColorPreviewInput preview box with 'color' input (#3271) 2022-03-09 19:56:25 -05:00
Ian Morland
5045254c9f fix: unread filter gambit does not return results when > 999 read discussions for a user (#3295) 2022-03-09 15:41:04 -05:00
9 changed files with 39 additions and 16 deletions

View File

@@ -1,6 +1,5 @@
import type Mithril from 'mithril'; import type Mithril from 'mithril';
import Component, { ComponentAttrs } from '../Component'; import Component, { ComponentAttrs } from '../Component';
export default class ColorPreviewInput extends Component { export default class ColorPreviewInput extends Component {
value?: string;
view(vnode: Mithril.Vnode<ComponentAttrs, this>): JSX.Element; view(vnode: Mithril.Vnode<ComponentAttrs, this>): JSX.Element;
} }

2
js/dist/admin.js generated vendored

File diff suppressed because one or more lines are too long

2
js/dist/admin.js.map generated vendored

File diff suppressed because one or more lines are too long

2
js/dist/forum.js generated vendored

File diff suppressed because one or more lines are too long

2
js/dist/forum.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -5,23 +5,20 @@ import classList from '../utils/classList';
import icon from '../helpers/icon'; import icon from '../helpers/icon';
export default class ColorPreviewInput extends Component { export default class ColorPreviewInput extends Component {
value?: string;
view(vnode: Mithril.Vnode<ComponentAttrs, this>) { view(vnode: Mithril.Vnode<ComponentAttrs, this>) {
const { className, ...attrs } = this.attrs; const { className, id, ...attrs } = this.attrs;
const value = attrs.bidi?.() || attrs.value;
attrs.type ||= 'text'; attrs.type ||= 'text';
return ( return (
<div className="ColorInput"> <div className="ColorInput">
<input className={classList('FormControl', className)} {...attrs} /> <input className={classList('FormControl', className)} id={id} {...attrs} />
<span className="ColorInput-icon" role="presentation"> <span className="ColorInput-icon" role="presentation">
{icon('fas fa-exclamation-circle')} {icon('fas fa-exclamation-circle')}
</span> </span>
<div className="ColorInput-preview" style={{ '--input-value': value }} role="presentation" /> <input className="ColorInput-preview" {...attrs} type="color" />
</div> </div>
); );
} }

View File

@@ -7,12 +7,26 @@
bottom: 8px; bottom: 8px;
width: 20px; width: 20px;
height: 20px; height: 20px;
pointer-events: none;
} }
&-preview { &-preview {
background-color: var(--input-value); display: inline-block;
border-radius: 15%; border-radius: 15%;
padding: 0;
cursor: pointer;
overflow: hidden;
// Match both the wrapper div and the div with the background color
&, &::-webkit-color-swatch-wrapper, &::-webkit-color-swatch {
border: none;
padding: 0;
}
// This has to be a separate entry so other browsers
// don't ignore the entire CSS rule. Thanks Firefox.
&::-moz-color-swatch {
border: none;
}
} }
&-icon { &-icon {

View File

@@ -42,16 +42,29 @@ class DiscussionRepository
/** /**
* Get the IDs of discussions which a user has read completely. * Get the IDs of discussions which a user has read completely.
* *
* @deprecated 1.3 Use `getReadIdsQuery` instead
*
* @param User $user * @param User $user
* @return array * @return array
*/ */
public function getReadIds(User $user) public function getReadIds(User $user)
{
return $this->getReadIdsQuery($user)
->all();
}
/**
* Get a query containing the IDs of discussions which a user has read completely.
*
* @param User $user
* @return Builder
*/
public function getReadIdsQuery(User $user): Builder
{ {
return Discussion::leftJoin('discussion_user', 'discussion_user.discussion_id', '=', 'discussions.id') return Discussion::leftJoin('discussion_user', 'discussion_user.discussion_id', '=', 'discussions.id')
->where('discussion_user.user_id', $user->id) ->where('discussion_user.user_id', $user->id)
->whereColumn('last_read_post_number', '>=', 'last_post_number') ->whereColumn('last_read_post_number', '>=', 'last_post_number')
->pluck('id') ->select('id');
->all();
} }
/** /**

View File

@@ -61,7 +61,7 @@ class UnreadFilterGambit extends AbstractRegexGambit implements FilterInterface
protected function constrain(Builder $query, User $actor, bool $negate) protected function constrain(Builder $query, User $actor, bool $negate)
{ {
if ($actor->exists) { if ($actor->exists) {
$readIds = $this->discussions->getReadIds($actor); $readIds = $this->discussions->getReadIdsQuery($actor);
$query->where(function ($query) use ($readIds, $negate, $actor) { $query->where(function ($query) use ($readIds, $negate, $actor) {
if (! $negate) { if (! $negate) {