Commit 686d31b3 authored by Claude's avatar Claude

feat: enhance attachment store with MobX observables and actions

parent e35f1630
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment