feat: enhance document loading and state management in doc-content component
- Introduced a loading state (`loadingChunks`) to manage document chunk loading more effectively. - Updated the scroll handling logic to prevent multiple requests while loading chunks. - Adjusted the pagination logic to ensure correct page increments based on the total document count. This update improves the user experience by ensuring smoother document loading and better state management during scrolling interactions.
This commit is contained in:
@@ -104,7 +104,7 @@ func (s *modelService) GetModelByID(ctx context.Context, id string) (*types.Mode
|
||||
return nil, errors.New("model ID cannot be empty")
|
||||
}
|
||||
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
tenantID := types.MustTenantIDFromContext(ctx)
|
||||
|
||||
// Fetch model from repository
|
||||
model, err := s.repo.GetByID(ctx, tenantID, id)
|
||||
@@ -148,7 +148,7 @@ func (s *modelService) GetModelByID(ctx context.Context, id string) (*types.Mode
|
||||
func (s *modelService) ListModels(ctx context.Context) ([]*types.Model, error) {
|
||||
logger.Info(ctx, "Start listing models")
|
||||
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
tenantID := types.MustTenantIDFromContext(ctx)
|
||||
logger.Infof(ctx, "Listing models for tenant ID: %d", tenantID)
|
||||
|
||||
// List models from repository with no additional filters
|
||||
@@ -170,7 +170,7 @@ func (s *modelService) UpdateModel(ctx context.Context, model *types.Model) erro
|
||||
logger.Infof(ctx, "Updating model ID: %s, name: %s", model.ID, model.Name)
|
||||
|
||||
// Check if the model is builtin - builtin models cannot be updated
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
tenantID := types.MustTenantIDFromContext(ctx)
|
||||
existingModel, err := s.repo.GetByID(ctx, tenantID, model.ID)
|
||||
if err != nil {
|
||||
logger.ErrorWithFields(ctx, err, map[string]interface{}{
|
||||
@@ -202,7 +202,7 @@ func (s *modelService) DeleteModel(ctx context.Context, id string) error {
|
||||
logger.Info(ctx, "Start deleting model")
|
||||
logger.Infof(ctx, "Deleting model ID: %s", id)
|
||||
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
tenantID := types.MustTenantIDFromContext(ctx)
|
||||
logger.Infof(ctx, "Tenant ID: %d", tenantID)
|
||||
|
||||
// Check if the model is builtin - builtin models cannot be deleted
|
||||
@@ -368,7 +368,7 @@ func (s *modelService) GetChatModel(ctx context.Context, modelId string) (chat.C
|
||||
return nil, errors.New("model ID cannot be empty")
|
||||
}
|
||||
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
tenantID := types.MustTenantIDFromContext(ctx)
|
||||
|
||||
// Get the model directly from repository to avoid status checks
|
||||
model, err := s.repo.GetByID(ctx, tenantID, modelId)
|
||||
@@ -412,7 +412,7 @@ func (s *modelService) GetVLMModel(ctx context.Context, modelId string) (vlm.VLM
|
||||
return nil, errors.New("model ID cannot be empty")
|
||||
}
|
||||
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
tenantID := types.MustTenantIDFromContext(ctx)
|
||||
|
||||
model, err := s.repo.GetByID(ctx, tenantID, modelId)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user