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

chore: minor changes

This commit is contained in:
Sami Mazouz
2025-02-14 09:24:13 +01:00
parent 090fd4dea5
commit 5557bf82d3
3 changed files with 10 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ export interface IIPAddressAttrs extends ComponentAttrs {
* @example * @example
* <IPAddress ip="127.0.0.1" /> * <IPAddress ip="127.0.0.1" />
* @example * @example
* <IPAddress ip={post.data.attributes.ipAddress} /> * <IPAddress ip={post.ipAddress()} />
*/ */
export default class IPAddress<CustomAttrs extends IIPAddressAttrs = IIPAddressAttrs> extends Component<CustomAttrs> { export default class IPAddress<CustomAttrs extends IIPAddressAttrs = IIPAddressAttrs> extends Component<CustomAttrs> {
ip!: string; ip!: string;
@@ -31,7 +31,7 @@ export default class IPAddress<CustomAttrs extends IIPAddressAttrs = IIPAddressA
viewItems(): ItemList<Mithril.Children> { viewItems(): ItemList<Mithril.Children> {
const items = new ItemList<Mithril.Children>(); const items = new ItemList<Mithril.Children>();
items.add('ip', <>{this.ip}</>, 100); items.add('ip', <span className="IPAddress-value">{this.ip}</span>, 100);
return items; return items;
} }

View File

@@ -41,6 +41,10 @@ export default class Post extends Model {
}).call(this); }).call(this);
} }
ipAddress() {
return Model.attribute<string | null | undefined>('ipAddress').call(this);
}
editedAt() { editedAt() {
return Model.attribute('editedAt', Model.transformDate).call(this); return Model.attribute('editedAt', Model.transformDate).call(this);
} }

View File

@@ -8,7 +8,9 @@ import type Model from '../../common/Model';
import type User from '../../common/models/User'; import type User from '../../common/models/User';
import classList from '../../common/utils/classList'; import classList from '../../common/utils/classList';
type ModelType = Post | (Model & { user: () => User | null | false; createdAt: () => Date }); type ModelType =
| Post
| (Model & { user: () => User | null | false; createdAt: () => Date; ipAddress: undefined | (() => string | null | undefined) });
export interface IPostMetaAttrs extends ComponentAttrs { export interface IPostMetaAttrs extends ComponentAttrs {
/** Can be a post or similar model like private message */ /** Can be a post or similar model like private message */
@@ -53,7 +55,7 @@ export default class PostMeta<CustomAttrs extends IPostMetaAttrs = IPostMetaAttr
<div className="Dropdown-menu dropdown-menu"> <div className="Dropdown-menu dropdown-menu">
<span className="PostMeta-number">{this.postIdentifier(post)}</span> <span className="PostMeta-time">{fullTime(time)}</span>{' '} <span className="PostMeta-number">{this.postIdentifier(post)}</span> <span className="PostMeta-time">{fullTime(time)}</span>{' '}
<span className="PostMeta-ip"> <span className="PostMeta-ip">
<IPAddress ip={post.data.attributes?.ipAddress} /> <IPAddress ip={post.ipAddress?.()} />
</span> </span>
{touch ? ( {touch ? (
<a className="Button PostMeta-permalink" href={permalink}> <a className="Button PostMeta-permalink" href={permalink}>