misskey/packages/frontend/src/pages/admin/custom-emojis-grid.impl.ts

69 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-01-21 02:39:52 +00:00
import * as Misskey from 'misskey-js';
export class GridItem {
readonly id?: string;
readonly url?: string;
readonly blob?: Blob;
public name: string;
public category: string;
2024-01-22 01:37:44 +00:00
public aliases: string;
2024-01-21 02:39:52 +00:00
public license: string;
public isSensitive: boolean;
public localOnly: boolean;
public roleIdsThatCanBeUsedThisEmojiAsReaction: string;
private readonly origin: string;
2024-01-22 01:37:44 +00:00
constructor(
2024-01-21 02:39:52 +00:00
id: string | undefined,
url: string | undefined = undefined,
blob: Blob | undefined = undefined,
name: string,
category: string,
2024-01-22 01:37:44 +00:00
aliases: string,
2024-01-21 02:39:52 +00:00
license: string,
isSensitive: boolean,
localOnly: boolean,
roleIdsThatCanBeUsedThisEmojiAsReaction: string,
) {
this.id = id;
this.url = url;
this.blob = blob;
this.aliases = aliases;
this.name = name;
this.category = category;
this.license = license;
this.isSensitive = isSensitive;
this.localOnly = localOnly;
this.roleIdsThatCanBeUsedThisEmojiAsReaction = roleIdsThatCanBeUsedThisEmojiAsReaction;
this.origin = JSON.stringify(this);
}
static ofEmojiDetailed(it: Misskey.entities.EmojiDetailed): GridItem {
2024-01-23 06:34:52 +00:00
return new GridItem(
it.id,
it.url,
undefined,
it.name,
it.category ?? '',
it.aliases.join(', '),
it.license ?? '',
it.isSensitive,
it.localOnly,
it.roleIdsThatCanBeUsedThisEmojiAsReaction.join(', '),
);
2024-01-21 02:39:52 +00:00
}
public get edited(): boolean {
const { origin, ..._this } = this;
return JSON.stringify(_this) !== origin;
}
2024-01-22 01:37:44 +00:00
2024-01-23 06:34:52 +00:00
public asRecord(): Record<string, never> {
return this as Record<string, never>;
2024-01-22 01:37:44 +00:00
}
2024-01-21 02:39:52 +00:00
}