feat(web): show partners assets on the main timeline (#4933)

This commit is contained in:
Alex 2023-11-11 15:06:19 -06:00 committed by GitHub
parent 3b11854702
commit 35767591d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
59 changed files with 1929 additions and 172 deletions

View file

@ -20,14 +20,14 @@
let loading = false;
const { getAssets, clearSelect } = getAssetControlContext();
const { clearSelect, getOwnedAssets } = getAssetControlContext();
const handleArchive = async () => {
const isArchived = !unarchive;
loading = true;
try {
const assets = Array.from(getAssets()).filter((asset) => asset.isArchived !== isArchived);
const assets = Array.from(getOwnedAssets()).filter((asset) => asset.isArchived !== isArchived);
const ids = assets.map(({ id }) => id);
if (ids.length > 0) {

View file

@ -14,13 +14,13 @@
AssetJobName.TranscodeVideo,
];
const { getAssets, clearSelect } = getAssetControlContext();
const { clearSelect, getOwnedAssets } = getAssetControlContext();
$: isAllVideos = Array.from(getAssets()).every((asset) => asset.type === AssetTypeEnum.Video);
$: isAllVideos = Array.from(getOwnedAssets()).every((asset) => asset.type === AssetTypeEnum.Video);
const handleRunJob = async (name: AssetJobName) => {
try {
const ids = Array.from(getAssets()).map(({ id }) => id);
const ids = Array.from(getOwnedAssets()).map(({ id }) => id);
await api.assetApi.runAssetJobs({ assetJobsDto: { assetIds: ids, name } });
notificationController.show({ message: api.getAssetJobMessage(name), type: NotificationType.Info });
clearSelect();

View file

@ -17,7 +17,7 @@
export let menuItem = false;
export let force = !$featureFlags.trash;
const { getAssets, clearSelect } = getAssetControlContext();
const { clearSelect, getOwnedAssets } = getAssetControlContext();
const dispatch = createEventDispatcher();
@ -37,7 +37,7 @@
loading = true;
try {
const ids = Array.from(getAssets())
const ids = Array.from(getOwnedAssets())
.filter((a) => !a.isExternal)
.map((a) => a.id);
await api.assetApi.deleteAssets({ assetBulkDeleteDto: { ids, force } });
@ -75,7 +75,7 @@
{#if isShowConfirmation}
<ConfirmDialogue
title="Permanently Delete Asset{getAssets().size > 1 ? 's' : ''}"
title="Permanently Delete Asset{getOwnedAssets().size > 1 ? 's' : ''}"
confirmText="Delete"
on:confirm={handleDelete}
on:cancel={() => (isShowConfirmation = false)}
@ -84,8 +84,8 @@
<svelte:fragment slot="prompt">
<p>
Are you sure you want to permanently delete
{#if getAssets().size > 1}
these <b>{getAssets().size}</b> assets? This will also remove them from their album(s).
{#if getOwnedAssets().size > 1}
these <b>{getOwnedAssets().size}</b> assets? This will also remove them from their album(s).
{:else}
this asset? This will also remove it from its album(s).
{/if}

View file

@ -20,14 +20,15 @@
let loading = false;
const { getAssets, clearSelect } = getAssetControlContext();
const { clearSelect, getOwnedAssets } = getAssetControlContext();
const handleFavorite = async () => {
const isFavorite = !removeFavorite;
loading = true;
try {
const assets = Array.from(getAssets()).filter((asset) => asset.isFavorite !== isFavorite);
const assets = Array.from(getOwnedAssets()).filter((asset) => asset.isFavorite !== isFavorite);
const ids = assets.map(({ id }) => id);
if (ids.length > 0) {

View file

@ -10,11 +10,11 @@
export let onStack: OnStack | undefined = undefined;
const { getAssets, clearSelect } = getAssetControlContext();
const { clearSelect, getOwnedAssets } = getAssetControlContext();
const handleStack = async () => {
try {
const assets = Array.from(getAssets());
const assets = Array.from(getOwnedAssets());
const parent = assets.at(0);
if (parent == undefined) {

View file

@ -9,7 +9,8 @@
export interface AssetControlContext {
// Wrap assets in a function, because context isn't reactive.
getAssets: () => Set<AssetResponseDto>;
getAssets: () => Set<AssetResponseDto>; // All assets includes partners' assets
getOwnedAssets: () => Set<AssetResponseDto>; // Only assets owned by the user
clearSelect: () => void;
}
@ -25,8 +26,14 @@
export let assets: Set<AssetResponseDto>;
export let clearSelect: () => void;
export let ownerId: string | undefined = undefined;
setContext({ getAssets: () => assets, clearSelect });
setContext({
getAssets: () => assets,
getOwnedAssets: () =>
ownerId !== undefined ? new Set(Array.from(assets).filter((asset) => asset.ownerId === ownerId)) : assets,
clearSelect,
});
</script>
<ControlAppBar on:close-button-click={clearSelect} backIcon={mdiClose} tailwindClasses="bg-white shadow-md">