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
}
export function getImageSizeFromUrl(url: string): Promise<ImageSize>
/** TODO: handle name collisions better */
export interface NoteLikeForAllTexts {
fileIds: Array<string>
userId: string
@ -257,7 +256,13 @@ export interface NoteLikeForGetNoteSummary {
hasPoll: boolean
}
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 latestVersion(): Promise<string>
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 sea_orm::{prelude::*, QuerySelect};
/// TODO: handle name collisions better
// TODO?: handle name collisions
#[crate::export(object, js_name = "NoteLikeForAllTexts")]
pub struct NoteLike {
pub file_ids: Vec<String>,

View file

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

View file

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