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