fix: use only necessary fields

This commit is contained in:
naskya 2024-05-24 10:07:16 +09:00
parent abaed389f9
commit 38c5b85220
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
4 changed files with 18 additions and 10 deletions

View file

@ -241,7 +241,6 @@ export interface ImageSize {
height: number height: number
} }
export function getImageSizeFromUrl(url: string): Promise<ImageSize> export function getImageSizeFromUrl(url: string): Promise<ImageSize>
/** TODO: handle name collisions better */
export interface NoteLikeForAllTexts { export interface NoteLikeForAllTexts {
fileIds: Array<string> fileIds: Array<string>
userId: string userId: string
@ -257,7 +256,13 @@ export interface NoteLikeForGetNoteSummary {
hasPoll: boolean hasPoll: boolean
} }
export function getNoteSummary(note: NoteLikeForGetNoteSummary): string export function getNoteSummary(note: NoteLikeForGetNoteSummary): string
export function isQuote(note: Note): boolean export interface NoteLikeForIsQuote {
renoteId: string | null
text: string | null
hasPoll: boolean
fileIds: Array<string>
}
export function isQuote(note: NoteLikeForIsQuote): boolean
export function isSafeUrl(url: string): boolean export function isSafeUrl(url: string): boolean
export function latestVersion(): Promise<string> export function latestVersion(): Promise<string>
export function fetchMeta(useCache: boolean): Promise<Meta> export function fetchMeta(useCache: boolean): Promise<Meta>

View file

@ -2,7 +2,7 @@ use crate::database::db_conn;
use crate::model::entity::{drive_file, note}; use crate::model::entity::{drive_file, note};
use sea_orm::{prelude::*, QuerySelect}; use sea_orm::{prelude::*, QuerySelect};
/// TODO: handle name collisions better // TODO?: handle name collisions
#[crate::export(object, js_name = "NoteLikeForAllTexts")] #[crate::export(object, js_name = "NoteLikeForAllTexts")]
pub struct NoteLike { pub struct NoteLike {
pub file_ids: Vec<String>, pub file_ids: Vec<String>,

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
// TODO: handle name collisions in a better way // TODO?: handle name collisions
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[crate::export(object, js_name = "NoteLikeForGetNoteSummary")] #[crate::export(object, js_name = "NoteLikeForGetNoteSummary")]

View file

@ -1,10 +1,13 @@
use crate::model::entity::note; // TODO?: handle name collisions
#[crate::export(object, js_name = "NoteLikeForIsQuote")]
// for napi export pub struct NoteLike {
// https://github.com/napi-rs/napi-rs/issues/2060 pub renote_id: Option<String>,
type Note = note::Model; pub text: Option<String>,
pub has_poll: bool,
pub file_ids: Vec<String>,
}
#[crate::export] #[crate::export]
pub fn is_quote(note: Note) -> bool { pub fn is_quote(note: &NoteLike) -> bool {
note.renote_id.is_some() && (note.text.is_some() || note.has_poll || !note.file_ids.is_empty()) note.renote_id.is_some() && (note.text.is_some() || note.has_poll || !note.file_ids.is_empty())
} }