feat: enhance attachment store with MobX observables and actions

pull/5184/head
Claude 2 weeks ago
parent e35f16306e
commit 686d31b357

@ -4,6 +4,7 @@
* Manages file attachment state including uploads and metadata.
* This is a server state store that fetches and caches attachment data.
*/
import { makeObservable, observable, computed } from "mobx";
import { attachmentServiceClient } from "@/grpcweb";
import { CreateAttachmentRequest, Attachment, UpdateAttachmentRequest } from "@/types/proto/api/v1/attachment_service";
import { StandardState, createServerStore } from "./base-store";
@ -19,6 +20,15 @@ class AttachmentState extends StandardState {
*/
attachmentMapByName: Record<string, Attachment> = {};
constructor() {
super();
makeObservable(this, {
attachmentMapByName: observable,
attachments: computed,
size: computed,
});
}
/**
* Computed getter for all attachments as an array
*/

@ -6,7 +6,7 @@
* - BaseClientStore: For stores that manage UI/client state
* - Common patterns for all stores
*/
import { makeAutoObservable } from "mobx";
import { makeObservable, action } from "mobx";
import { RequestDeduplicator, StoreError } from "./store-utils";
/**
@ -166,7 +166,9 @@ export function createClientStore<TState extends BaseState>(state: TState, confi
*/
export abstract class StandardState implements BaseState {
constructor() {
makeAutoObservable(this);
makeObservable(this, {
setPartial: action,
});
}
setPartial(partial: Partial<this>): void {

Loading…
Cancel
Save