Skip to content

Commit

Permalink
fix: apply the color to folder as per the parent folder color
Browse files Browse the repository at this point in the history
  • Loading branch information
dhavaldodiya committed Aug 9, 2022
1 parent cbfe52f commit 4303518
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/workers/folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ const omit = ({
}: Partial<SoapFolder>): Partial<SoapFolder> => obj;

const hasId = (f: SoapFolder, id: string): boolean => f.id.split(':').includes(id);
const normalize = (f: SoapFolder): BaseFolder => ({
const normalize = (f: SoapFolder, p?: Folder): BaseFolder => ({
id: f.id,
uuid: f.uuid,
name: f.name,
absFolderPath: f.absFolderPath,
l: f.l,
luuid: f.luuid,
f: f.f,
color: f.color,
color: f.color || p?.color,
rgb: f.rgb,
u: f.u,
i4u: f.i4u,
Expand Down Expand Up @@ -77,8 +77,8 @@ const normalizeSearch = (s: SoapSearchFolder): BaseFolder & SearchFolderFields =
types: s.types
});

const normalizeLink = (l: SoapLink): BaseFolder & LinkFolderFields => ({
...normalize(l),
const normalizeLink = (l: SoapLink, p?: Folder): BaseFolder & LinkFolderFields => ({
...normalize(l, p),
owner: l.owner,
zid: l.zid,
rid: l.rid,
Expand All @@ -99,7 +99,7 @@ const processSearch = (soapSearch: SoapSearchFolder, parent: Folder): void => {

const processLink = (soapLink: SoapLink, depth: number, parent?: Folder): LinkFolder => {
const link = {
...normalizeLink(soapLink),
...normalizeLink(soapLink, parent),
isLink: true,
children: [],
parent,
Expand Down Expand Up @@ -132,7 +132,7 @@ const processLink = (soapLink: SoapLink, depth: number, parent?: Folder): LinkFo

const processFolder = (soapFolder: SoapFolder, depth: number, parent?: Folder): UserFolder => {
const folder: UserFolder = {
...normalize(soapFolder),
...normalize(soapFolder, parent),
isLink: false,
children: [],
parent,
Expand Down Expand Up @@ -168,7 +168,7 @@ export const handleFolderCreated = (created: Array<SoapFolder>): void =>
if (val.id && val.l) {
const parent = folders[val.l];
const folder: UserFolder = {
...normalize(val),
...normalize(val, parent),
isLink: false,
children: [],
parent,
Expand Down

0 comments on commit 4303518

Please sign in to comment.