tangled
alpha
login
or
join now
rocksky.app
/
rocksky
96
fork
atom
A decentralized music tracking and discovery platform built on AT Protocol 🎵
rocksky.app
spotify
atproto
lastfm
musicbrainz
scrobbling
listenbrainz
96
fork
atom
overview
issues
7
pulls
pipelines
[web] clean commented codes
tsiry-sandratraina.com
8 months ago
8a4d8736
70534e43
-164
2 changed files
expand all
collapse all
unified
split
apps
web
src
pages
dropbox
Dropbox.tsx
googledrive
GoogleDrive.tsx
-78
apps/web/src/pages/dropbox/Dropbox.tsx
···
69
}),
70
];
71
72
-
/*
73
-
useEffect(() => {
74
-
const fetchFiles = async () => {
75
-
setLoading(true);
76
-
const files = await getFiles(props.fileId);
77
-
const cache = { ...dropbox?.cache };
78
-
cache[props.fileId || "/Music"] = {
79
-
files: files.entries.filter(
80
-
(entry) =>
81
-
entry[".tag"] === "folder" ||
82
-
(entry[".tag"] === "file" &&
83
-
AUDIO_EXTENSIONS.includes(entry.name.split(".").pop() || ""))
84
-
),
85
-
};
86
-
_.orderBy(files.entries, "name", "asc");
87
-
let current_dir = "Music";
88
-
let parent_dir;
89
-
let parent_id;
90
-
91
-
if (props.fileId) {
92
-
const file = await getFile(props.fileId);
93
-
current_dir = file.name;
94
-
// extract the parent directory from the path
95
-
const parent_path = file.path_display.split("/").slice(0, -1).join("/");
96
-
parent_dir = file.path_display.split("/").slice(0, -1).pop();
97
-
if (parent_path) {
98
-
const parent = await getFile(parent_path);
99
-
parent_id = parent.id;
100
-
}
101
-
}
102
-
103
-
setDropbox({
104
-
current_dir,
105
-
parent_dir,
106
-
parent_id,
107
-
cache: {
108
-
...cache,
109
-
[props.fileId || "/Music"]: {
110
-
...cache[props.fileId || "/Music"],
111
-
current_dir,
112
-
parent_dir,
113
-
parent_id,
114
-
},
115
-
},
116
-
});
117
-
setLoading(false);
118
-
};
119
-
fetchFiles();
120
-
// eslint-disable-next-line react-hooks/exhaustive-deps
121
-
}, [props.fileId]);
122
-
*/
123
-
124
return (
125
<Main>
126
-
{/*
127
-
((props.fileId && dropbox?.cache[props.fileId]) ||
128
-
!isLoading ||
129
-
pathname === "/dropbox") && (
130
-
<div className="pt-[80px] fixed bg-[var(--color-background)] top-[19px] w-[770px]">
131
-
<Breadcrumbs>
132
-
{parent_dir && current_dir !== "Music" && (
133
-
<Link
134
-
to={current_dir === "Music" ? `/dropbox` : `/dropbox/$id`}
135
-
params={{ id: parent_id! }}
136
-
className="!text-[var(--color-text)]"
137
-
>
138
-
{parent_dir}
139
-
</Link>
140
-
)}
141
-
</Breadcrumbs>
142
-
<HeadingMedium
143
-
marginTop={"10px"}
144
-
marginBottom={"25px"}
145
-
className="!text-[var(--color-text)]"
146
-
>
147
-
{current_dir === "Music" ? "Dropbox" : current_dir}
148
-
</HeadingMedium>
149
-
</div>
150
-
)
151
-
*/}
152
<div className="pt-[80px] fixed bg-[var(--color-background)] top-[19px] w-[770px]">
153
<Breadcrumbs>
154
{
···
69
}),
70
];
71
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
72
return (
73
<Main>
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
74
<div className="pt-[80px] fixed bg-[var(--color-background)] top-[19px] w-[770px]">
75
<Breadcrumbs>
76
{
-86
apps/web/src/pages/googledrive/GoogleDrive.tsx
···
56
}),
57
];
58
59
-
/*
60
-
useEffect(() => {
61
-
const fetchGoogleDrive = async () => {
62
-
setLoading(true);
63
-
const { files, authUrl } = await getFiles(props.fileId);
64
-
65
-
if (authUrl) {
66
-
window.location.href = authUrl;
67
-
return;
68
-
}
69
-
70
-
const cache = { ...googleDrive?.cache };
71
-
cache[props.fileId || "/Music"] = {
72
-
files: files
73
-
.filter(
74
-
(x) =>
75
-
x.mimeType.includes("folder") ||
76
-
AUDIO_EXTENSIONS.includes(x.name.split(".").pop() || "")
77
-
)
78
-
.map((x) => ({
79
-
id: x.id,
80
-
name: x.name,
81
-
mime_type: x.mimeType,
82
-
parents: x.parents,
83
-
})),
84
-
};
85
-
86
-
let current_dir = "Music";
87
-
let parent_dir;
88
-
let parent_id;
89
-
if (props.fileId) {
90
-
const current = await getFile(props.fileId);
91
-
current_dir = current.name;
92
-
parent_id = _.get(current, "parents.0");
93
-
const parent = await getFile(_.get(current, "parents.0"));
94
-
parent_dir = parent.name;
95
-
}
96
-
97
-
setGoogleDrive({
98
-
current_dir,
99
-
parent_dir,
100
-
parent_id,
101
-
cache: {
102
-
...cache,
103
-
[props.fileId || "/Music"]: {
104
-
parent_id,
105
-
parent_dir,
106
-
current_dir,
107
-
...cache[props.fileId || "/Music"],
108
-
},
109
-
},
110
-
});
111
-
setLoading(false);
112
-
};
113
-
fetchGoogleDrive();
114
-
// eslint-disable-next-line react-hooks/exhaustive-deps
115
-
}, [props.fileId]);
116
-
*/
117
-
118
return (
119
<Main>
120
-
{/*
121
-
((props.fileId && googleDrive?.cache[props.fileId]) ||
122
-
!isLoading ||
123
-
pathname === "/googledrive") && (
124
-
<div className="pt-[80px] fixed bg-[var(--color-background)] top-[19px] w-[770px]">
125
-
<Breadcrumbs>
126
-
{parent_dir && current_dir !== "Music" && (
127
-
<Link
128
-
to={
129
-
current_dir === "Music" ? "/googledrive" : "/googledrive/$id"
130
-
}
131
-
params={{ id: parent_id || "/Music" }}
132
-
className="!text-[var(--color-text)]"
133
-
>
134
-
{parent_dir}
135
-
</Link>
136
-
)}
137
-
</Breadcrumbs>
138
-
<HeadingMedium
139
-
marginTop={"10px"}
140
-
marginBottom={"25px"}
141
-
className="!text-[var(--color-text)]"
142
-
>
143
-
{current_dir === "Music" ? "Google Drive" : current_dir}
144
-
</HeadingMedium>
145
-
</div>
146
-
)*/}
147
<div className="pt-[80px] fixed bg-[var(--color-background)] top-[19px] w-[770px]">
148
<Breadcrumbs>
149
{
···
56
}),
57
];
58
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
59
return (
60
<Main>
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
61
<div className="pt-[80px] fixed bg-[var(--color-background)] top-[19px] w-[770px]">
62
<Breadcrumbs>
63
{