Skip to content

make sure that recent view always sorts by opened_at #7777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class WorkflowThumbnailServiceBase(ABC):
"""Base class for workflow thumbnail services"""

@abstractmethod
def get_path(self, workflow_id: str) -> Path:
def get_path(self, workflow_id: str, with_hash: bool = True) -> Path:
"""Gets the path to a workflow thumbnail"""
pass

@abstractmethod
def get_url(self, workflow_id: str) -> str | None:
def get_url(self, workflow_id: str, with_hash: bool = True) -> str | None:
"""Gets the URL of a workflow thumbnail"""
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def save(self, workflow_id: str, image: PILImageType) -> None:
except Exception as e:
raise WorkflowThumbnailFileSaveException from e

def get_path(self, workflow_id: str) -> Path:
def get_path(self, workflow_id: str, with_hash: bool = True) -> Path:
workflow = self._invoker.services.workflow_records.get(workflow_id).workflow
if workflow.meta.category is WorkflowCategory.Default:
default_thumbnails_dir = Path(__file__).parent / Path("default_workflow_thumbnails")
Expand All @@ -51,15 +51,16 @@ def get_path(self, workflow_id: str) -> Path:

return path

def get_url(self, workflow_id: str) -> str | None:
def get_url(self, workflow_id: str, with_hash: bool = True) -> str | None:
path = self.get_path(workflow_id)
if not self._validate_path(path):
return

url = self._invoker.services.urls.get_workflow_thumbnail_url(workflow_id)

# The image URL never changes, so we must add random query string to it to prevent caching
url += f"?{uuid_string()}"
if with_hash:
url += f"?{uuid_string()}"

return url

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export const workflowLibrarySlice = createSlice({
workflowLibraryViewChanged: (state, action: PayloadAction<WorkflowLibraryState['view']>) => {
state.view = action.payload;
state.searchTerm = '';
if (action.payload === 'recent') {
state.orderBy = 'opened_at';
state.direction = 'DESC';
}
},
workflowLibraryTagToggled: (state, action: PayloadAction<string>) => {
const tag = action.payload;
Expand Down
6 changes: 3 additions & 3 deletions invokeai/frontend/web/src/services/api/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21177,7 +21177,7 @@ export type components = {
* Opened At
* @description The opened timestamp of the workflow.
*/
opened_at: string | null;
opened_at?: string | null;
/** @description The workflow. */
workflow: components["schemas"]["Workflow"];
};
Expand Down Expand Up @@ -21207,7 +21207,7 @@ export type components = {
* Opened At
* @description The opened timestamp of the workflow.
*/
opened_at: string | null;
opened_at?: string | null;
/**
* Description
* @description The description of the workflow.
Expand Down Expand Up @@ -21258,7 +21258,7 @@ export type components = {
* Opened At
* @description The opened timestamp of the workflow.
*/
opened_at: string | null;
opened_at?: string | null;
/** @description The workflow. */
workflow: components["schemas"]["Workflow"];
/**
Expand Down
Loading