You've already forked pigallery2
mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-11-27 22:38:10 +02:00
@@ -565,7 +565,7 @@ export class ContentWrapper {
|
||||
lens: new Map(), camera: new Map(), directories: new Map()
|
||||
};
|
||||
|
||||
if (cw.directory) {
|
||||
if (cw?.directory) {
|
||||
ContentWrapper.packDirectory(cw, cw.directory);
|
||||
} else if (cw.searchResult) {
|
||||
ContentWrapper.packDirectory(cw, cw.searchResult, true);
|
||||
@@ -589,7 +589,7 @@ export class ContentWrapper {
|
||||
if (!cw || cw.notModified) {
|
||||
return cw;
|
||||
}
|
||||
if (cw.directory) {
|
||||
if (cw?.directory) {
|
||||
ContentWrapper.unPackDirectory(cw, cw.directory);
|
||||
} else if (cw.searchResult) {
|
||||
ContentWrapper.unPackDirectory(cw, cw.searchResult, true);
|
||||
|
||||
@@ -314,8 +314,8 @@ export class GalleryCacheService {
|
||||
|
||||
const key =
|
||||
GalleryCacheService.CONTENT_PREFIX +
|
||||
Utils.concatUrls(cw.directory.path, cw.directory.name);
|
||||
if (cw.directory.isPartial === true && localStorage.getItem(key)) {
|
||||
Utils.concatUrls(cw?.directory.path, cw?.directory.name);
|
||||
if (cw?.directory?.isPartial === true && localStorage.getItem(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ export class ContentLoaderService {
|
||||
new ContentWrapperWithError()
|
||||
);
|
||||
this.originalContent = this.content.pipe(
|
||||
map((c) => (c.directory ? c.directory : c.searchResult))
|
||||
map((c) => (c?.directory ? c?.directory : c?.searchResult))
|
||||
);
|
||||
|
||||
}
|
||||
@@ -64,15 +64,15 @@ export class ContentLoaderService {
|
||||
|
||||
if (
|
||||
!forceReload &&
|
||||
cw.directory &&
|
||||
cw.directory.lastModified &&
|
||||
cw.directory.lastScanned &&
|
||||
!cw.directory.isPartial
|
||||
cw?.directory &&
|
||||
cw?.directory.lastModified &&
|
||||
cw?.directory.lastScanned &&
|
||||
!cw?.directory.isPartial
|
||||
) {
|
||||
params[QueryParams.gallery.knownLastModified] =
|
||||
cw.directory.lastModified;
|
||||
cw?.directory.lastModified;
|
||||
params[QueryParams.gallery.knownLastScanned] =
|
||||
cw.directory.lastScanned;
|
||||
cw?.directory.lastScanned;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -93,18 +93,18 @@ export class GalleryNavigatorComponent {
|
||||
this.routes = this.contentLoaderService.content.pipe(
|
||||
map((c) => {
|
||||
this.parentPath = null;
|
||||
if (!c.directory && !this.isExactDirectorySearch(c)) {
|
||||
if (!c?.directory && !this.isExactDirectorySearch(c)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let path: string;
|
||||
let name: string;
|
||||
if (c.directory) {
|
||||
if (c?.directory) {
|
||||
path = c.directory.path;
|
||||
name = c.directory.name;
|
||||
} else {
|
||||
// Handle exact directory search
|
||||
const searchQuery = c.searchResult.searchQuery as TextSearch;
|
||||
const searchQuery = c?.searchResult.searchQuery as TextSearch;
|
||||
path = searchQuery.text.replace(/^\.\//, ''); // Remove leading ./ if present
|
||||
const lastSlashIndex = path.lastIndexOf('/');
|
||||
if (lastSlashIndex !== -1) {
|
||||
@@ -265,7 +265,7 @@ export class GalleryNavigatorComponent {
|
||||
searchQuery = {
|
||||
type: SearchQueryTypes.directory,
|
||||
matchType: TextSearchQueryMatchTypes.exact_match,
|
||||
text: Utils.concatUrls('./', c.directory.path, c.directory.name)
|
||||
text: Utils.concatUrls('./', c?.directory.path, c?.directory.name)
|
||||
} as TextSearch;
|
||||
} else {
|
||||
return null;
|
||||
@@ -293,7 +293,7 @@ export class GalleryNavigatorComponent {
|
||||
return JSON.stringify({
|
||||
type: SearchQueryTypes.directory,
|
||||
matchType: TextSearchQueryMatchTypes.like,
|
||||
text: Utils.concatUrls('./', c.directory.path, c.directory.name),
|
||||
text: Utils.concatUrls('./', c?.directory.path, c?.directory.name),
|
||||
} as TextSearch);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ export class RandomQueryBuilderGalleryComponent implements OnInit, OnDestroy {
|
||||
ngOnInit(): void {
|
||||
this.contentSubscription = this.contentLoaderService.content.subscribe(
|
||||
(content: ContentWrapper) => {
|
||||
this.enabled = !!content.directory;
|
||||
this.enabled = !!content?.directory;
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -86,23 +86,23 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
|
||||
this.contentSubscription = this.galleryService.content.subscribe(
|
||||
async (content: ContentWrapper) => {
|
||||
this.activeShares = [];
|
||||
this.enabled = !!(content.directory || (content as any).searchResult);
|
||||
this.enabled = !!(content?.directory || (content as any)?.searchResult);
|
||||
this.currentDir = '';
|
||||
this.currentQuery = null;
|
||||
this.sharingTarget = '';
|
||||
this.currentMediaCount = 0;
|
||||
this.currentMediaCountIsLowerBound = false;
|
||||
|
||||
if ((content as any).searchResult) {
|
||||
if ((content as any)?.searchResult) {
|
||||
const sr = (content as any).searchResult;
|
||||
this.currentQuery = sr.searchQuery as SearchQueryDTO;
|
||||
this.sharingTarget = $localize`Search query`;
|
||||
this.currentMediaCount = (sr.media ? sr.media.length : 0);
|
||||
this.currentMediaCountIsLowerBound = !!sr.resultOverflow;
|
||||
} else if (content.directory) {
|
||||
} else if (content?.directory) {
|
||||
this.currentDir = Utils.concatUrls(
|
||||
content.directory.path,
|
||||
content.directory.name
|
||||
content?.directory.path,
|
||||
content?.directory.name
|
||||
);
|
||||
this.currentQuery = {
|
||||
type: SearchQueryTypes.directory,
|
||||
@@ -111,7 +111,7 @@ export class GalleryShareComponent implements OnInit, OnDestroy {
|
||||
} as TextSearch;
|
||||
this.sharingTarget = this.currentDir;
|
||||
// Prefer mediaCount, fallback to media length if needed
|
||||
this.currentMediaCount = (typeof content.directory.cache?.mediaCount === 'number' ? content.directory.cache?.mediaCount : (content.directory.media ? content.directory.media.length : 0));
|
||||
this.currentMediaCount = (typeof content?.directory.cache?.mediaCount === 'number' ? content.directory.cache?.mediaCount : (content.directory.media ? content.directory.media.length : 0));
|
||||
this.currentMediaCountIsLowerBound = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('ContentWrapper', () => {
|
||||
delete cw.notModified;
|
||||
}
|
||||
|
||||
const content = (cw.directory ? cw.directory : cw.searchResult);
|
||||
const content = (cw?.directory ? cw.directory : cw?.searchResult);
|
||||
for (let i = 0; i < content.media.length; ++i) {
|
||||
const m = content.media[i];
|
||||
if (MediaDTOUtils.isPhoto(m)) {
|
||||
|
||||
Reference in New Issue
Block a user