Path: blob/master/src/packages/frontend/account/default-file-name-generator.ts
1503 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45// Return a default filename with the given ext (or not extension if ext not given)6// this is just a wrapper for backwards compatibility7import { redux } from "@cocalc/frontend/app-framework";8import { DEFAULT_NEW_FILENAMES, NEW_FILENAMES } from "@cocalc/util/db-schema";9import { NewFilenames } from "../project/utils";1011const new_filenames_generator = new NewFilenames(undefined, true);1213export function default_filename(ext?: string, project_id?: string): string {14const account_store = redux.getStore("account");15const type =16account_store?.getIn(["other_settings", NEW_FILENAMES]) ??17DEFAULT_NEW_FILENAMES;18new_filenames_generator.set_ext(ext);1920if (project_id != undefined) {21const avoid = redux22.getProjectActions(project_id)23.get_filenames_in_current_dir();24return new_filenames_generator.gen(type, avoid);25} else {26return new_filenames_generator.gen(type);27}28}293031