Bladeren bron

PR review comments addressed

singulart 3 jaren geleden
bovenliggende
commit
74b3423c72

+ 3 - 3
community-contributions/joystreamvideobot/src/bot.ts

@@ -66,14 +66,14 @@ const main = async () => {
                 )
                 .setTimestamp();
                 const uploaderTitle = `${edge.node.channel.title} (${edge.node.channel.ownerMember.rootAccount})`
-                if(edge.node.channel.avatarPhotoDataObject && edge.node.channel.avatarPhotoDataObject.liaison) {
+                if(edge.node.channel.avatarPhotoDataObject?.liaison) {
                   const avatar = 
                         `${edge.node.channel.avatarPhotoDataObject.liaison.metadata}asset/v0/${edge.node.channel.avatarPhotoDataObject.joystreamContentId}`;
                   exampleEmbed.setAuthor(uploaderTitle, avatar, `https://play.joystream.org/channel/${edge.node.channel.id}`);
                 } else {
                   exampleEmbed.setAuthor(uploaderTitle, null, `https://play.joystream.org/channel/${edge.node.channel.id}`);
                 }
-                if(edge.node.thumbnailPhotoDataObject && edge.node.thumbnailPhotoDataObject.liaison) {
+                if(edge.node.thumbnailPhotoDataObject?.liaison) {
                   exampleEmbed.setImage(`${edge.node.thumbnailPhotoDataObject.liaison.metadata}asset/v0/${edge.node.thumbnailPhotoDataObject.joystreamContentId}`)
                 }
               channel.send(exampleEmbed);
@@ -110,7 +110,7 @@ const cleanup = (ids: any[], cutoffDate: Date) => {
 
 const lookup = (ids: any[], id: string) => {
   for (let video of ids) {
-    if (video.id == id) {
+    if (video.id === id) {
       return true;
     }
   }

+ 5 - 4
community-contributions/joystreamvideobot/src/sizeformat.ts

@@ -9,9 +9,9 @@
 * @return Formatted string.
 */
 export const humanFileSize = (bytes: number, si=false, dp=1): string => {
- const thresh = si ? 1000 : 1024;
+ const threshold = si ? 1000 : 1024;
 
- if (Math.abs(bytes) < thresh) {
+ if (Math.abs(bytes) < threshold) {
    return bytes + ' B';
  }
 
@@ -22,10 +22,11 @@ export const humanFileSize = (bytes: number, si=false, dp=1): string => {
  const r = 10**dp;
 
  do {
-   bytes /= thresh;
+   bytes /= threshold;
    ++u;
- } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
+ } while (Math.round(Math.abs(bytes) * r) / r >= threshold && u < units.length - 1);
 
 
  return bytes.toFixed(dp) + ' ' + units[u];
+ 
 }