-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(card-image): remove domain from URL and use settings.currentInst…
…ance
- Loading branch information
Stéphane
committed
Oct 13, 2023
1 parent
bf2c87b
commit e3aaa29
Showing
6 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/database/13102023_migrate_remove_card_image_url_domain.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { db } from "."; | ||
import { Playlist } from "../types/interfaces/Playlist"; | ||
|
||
const DOMAIN_REGEX = | ||
/^(?:https?:\/\/)?(?:[^@/\n]+@)?(?:www\.)?([^:/?\n]+\.+[^:/?\n]+)/gm; | ||
|
||
const migration = () => { | ||
const favoritePlaylist = db.queryAll("playlists", { | ||
query: { title: "Favorites" }, | ||
})[0] as Playlist; | ||
|
||
try { | ||
const updatedVideos = favoritePlaylist.videos.map((video) => { | ||
if (video.videoThumbnails) { | ||
return { | ||
...video, | ||
videoThumbnails: video.videoThumbnails?.map((thumbnail) => ({ | ||
...thumbnail, | ||
url: thumbnail.url.replace(DOMAIN_REGEX, ""), | ||
})), | ||
}; | ||
} | ||
return video; | ||
}); | ||
|
||
favoritePlaylist.videos = updatedVideos; | ||
|
||
db.update("playlists", { title: "Favorites" }, () => favoritePlaylist); | ||
db.commit(); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}; | ||
|
||
export default migration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters