Skip to content

Commit

Permalink
#769 - Fix folder update
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Mar 1, 2024
1 parent 286ac4a commit d1dba01
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/commands/Folders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,13 @@ export class Folders {
* @param folders
*/
public static async update(folders: ContentFolder[]) {
const originalFolders = Settings.get(SETTING_CONTENT_PAGE_FOLDERS) as ContentFolder[];
const wsFolder = Folders.getWorkspaceFolder();

// Filter out the locale folders
folders = folders.filter((folder) => !folder.locale || folder.locale === folder.defaultLocale);

// Remove the internal FM properties
const folderDetails = folders
.map((folder) => {
const detail = {
Expand All @@ -418,6 +423,19 @@ export class Folders {
return null;
}

if (detail.locale && detail.locale === detail.defaultLocale) {
// Check if the folder was on the original list
const originalFolder = originalFolders.find((f) => f.path === folder.originalPath);

if (originalFolder && !originalFolder.locales && folder.locales) {
delete detail.locales;
}

delete detail.localeSourcePath;
delete detail.localeTitle;
}

delete detail.locale;
delete detail.originalPath;

return detail;
Expand Down
2 changes: 1 addition & 1 deletion src/models/ContentFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ export interface ContentFolder {
localeTitle?: string;
localeSourcePath?: string;
defaultLocale?: string;
locales: I18nConfig[];
locales?: I18nConfig[];
}

0 comments on commit d1dba01

Please sign in to comment.