Check null for current user + default state

old-stable24
Varun Patil 2022-10-28 16:21:08 -07:00
parent a1f3ee4ede
commit 2291bd4495
13 changed files with 31 additions and 20 deletions

View File

@ -472,7 +472,7 @@ export default class SelectionHandler extends Mixins(GlobalMixin, UserConfig) {
}
// Check photo ownership
if (this.$route.params.user !== getCurrentUser().uid) {
if (this.$route.params.user !== getCurrentUser()?.uid) {
showError(
this.t("memories", 'Only user "{user}" can update this person', {
user,

View File

@ -231,7 +231,7 @@ export default class AddToAlbumModal extends Mixins(GlobalMixin) {
get searchResults(): string[] {
return this.currentSearchResults
.filter(({ id }) => id !== getCurrentUser().uid)
.filter(({ id }) => id !== getCurrentUser()?.uid)
.map(({ type, id }) => `${type}:${id}`)
.filter(
(collaboratorKey) =>

View File

@ -50,7 +50,7 @@ export default class AlbumDeleteModal extends Mixins(GlobalMixin) {
public open() {
const user = this.$route.params.user || "";
if (this.$route.params.user !== getCurrentUser().uid) {
if (this.$route.params.user !== getCurrentUser()?.uid) {
showError(
this.t("memories", 'Only user "{user}" can delete this album', { user })
);

View File

@ -195,7 +195,7 @@ export default class AlbumForm extends Mixins(GlobalMixin) {
this.loading = true;
let album = {
basename: this.albumName,
filename: `/photos/${getCurrentUser().uid}/albums/${this.albumName}`,
filename: `/photos/${getCurrentUser()?.uid}/albums/${this.albumName}`,
nbItems: 0,
location: this.albumLocation,
lastPhoto: -1,

View File

@ -44,7 +44,7 @@ export default class FaceDeleteModal extends Mixins(GlobalMixin) {
public open() {
const user = this.$route.params.user || "";
if (this.$route.params.user !== getCurrentUser().uid) {
if (this.$route.params.user !== getCurrentUser()?.uid) {
showError(
this.t("memories", 'Only user "{user}" can delete this person', {
user,

View File

@ -52,7 +52,7 @@ export default class FaceEditModal extends Mixins(GlobalMixin) {
public open() {
const user = this.$route.params.user || "";
if (this.$route.params.user !== getCurrentUser().uid) {
if (this.$route.params.user !== getCurrentUser()?.uid) {
showError(
this.t("memories", 'Only user "{user}" can update this person', {
user,

View File

@ -62,7 +62,7 @@ export default class FaceMergeModal extends Mixins(GlobalMixin) {
public open() {
const user = this.$route.params.user || "";
if (this.$route.params.user !== getCurrentUser().uid) {
if (this.$route.params.user !== getCurrentUser()?.uid) {
showError(
this.t("memories", 'Only user "{user}" can update this person', {
user,

View File

@ -55,7 +55,7 @@ export default class FaceMoveModal extends Mixins(GlobalMixin) {
// check ownership
const user = this.$route.params.user || "";
if (this.$route.params.user !== getCurrentUser().uid) {
if (this.$route.params.user !== getCurrentUser()?.uid) {
showError(
this.t("memories", 'Only user "{user}" can update this person', {
user,

View File

@ -31,14 +31,25 @@ const localSettings = ["squareThumbs", "showFaceRect"];
@Component
export default class UserConfig extends Vue {
config_timelinePath: string = loadState("memories", "timelinePath") || "";
config_foldersPath: string = loadState("memories", "foldersPath") || "/";
config_showHidden = loadState("memories", "showHidden") === "true";
config_timelinePath: string = loadState(
"memories",
"timelinePath",
<string>""
);
config_foldersPath: string = loadState(
"memories",
"foldersPath",
<string>"/"
);
config_showHidden =
loadState("memories", "showHidden", <string>"false") === "true";
config_tagsEnabled = Boolean(loadState("memories", "systemtags"));
config_recognizeEnabled = Boolean(loadState("memories", "recognize"));
config_mapsEnabled = Boolean(loadState("memories", "maps"));
config_albumsEnabled = Boolean(loadState("memories", "albums"));
config_tagsEnabled = Boolean(loadState("memories", "systemtags", <string>""));
config_recognizeEnabled = Boolean(
loadState("memories", "recognize", <string>"")
);
config_mapsEnabled = Boolean(loadState("memories", "maps", <string>""));
config_albumsEnabled = Boolean(loadState("memories", "albums", <string>""));
config_squareThumbs = localStorage.getItem("memories_squareThumbs") === "1";
config_showFaceRect = localStorage.getItem("memories_showFaceRect") === "1";

View File

@ -217,7 +217,7 @@ export const constants = {
/** Cache store */
let staticCache: Cache | null = null;
const cacheName = `memories-${loadState("memories", "version")}-${
getCurrentUser()!.uid
getCurrentUser()?.uid
}`;
openCache().then((cache) => {
staticCache = cache;

View File

@ -20,7 +20,7 @@ import client from "../DavClient";
*/
export function getAlbumPath(user: string, name: string) {
// Folder in the dav collection for user
const cuid = getCurrentUser().uid;
const cuid = getCurrentUser()?.uid;
if (user === cuid) {
return `/photos/${cuid}/albums/${name}`;
} else {

View File

@ -66,7 +66,7 @@ export async function getFiles(photos: IPhoto[]): Promise<IFileInfo[]> {
* @returns list of file infos
*/
async function getFilesInternal(fileIds: number[]): Promise<IFileInfo[]> {
const prefixPath = `/files/${getCurrentUser()!.uid}`;
const prefixPath = `/files/${getCurrentUser()?.uid}`;
// IMPORTANT: if this isn't there, then a blank
// returns EVERYTHING on the server!
@ -158,7 +158,7 @@ export async function* runInParallel<T>(
* @param path path to the file
*/
export async function deleteFile(path: string) {
const prefixPath = `/files/${getCurrentUser()!.uid}`;
const prefixPath = `/files/${getCurrentUser()?.uid}`;
return await client.deleteFile(`${prefixPath}${path}`);
}

View File

@ -13,7 +13,7 @@ export async function getFolderPreviewFileIds(
folderPath: string,
limit: number
): Promise<IFileInfo[]> {
const prefixPath = `/files/${getCurrentUser()!.uid}`;
const prefixPath = `/files/${getCurrentUser()?.uid}`;
const filter = base.IMAGE_MIME_TYPES.map(
(mime) => `