Skip to content

Commit

Permalink
bug(NoteManager): Fix default edit access not working on notes
Browse files Browse the repository at this point in the history
  • Loading branch information
rexy712 authored Nov 8, 2024
1 parent 7a70b20 commit f3d3ae9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ tech changes will usually be stripped from release notes for the public
- It was possible to open a 'view-only' note on a tab you weren't supposed to see
- Note manager could be empty and unusable when changing locations
- Search filter not resetting page to 1 potentially causing a blank page if on an other page
- Default edit access on notes was not correctly applied
- Shape Properties:
- Input changes could not persist or save on the wrong shape if selection focus was changed while editing (see selection changes)
- Modals
Expand Down
10 changes: 6 additions & 4 deletions client/src/game/ui/notes/NoteEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ const modals = useModal();
const note = computed(() => noteState.reactive.notes.get(noteState.reactive.currentNote!));
const defaultAccessName = "default";
const canEdit = computed(() => {
if (!note.value) return false;
const username = coreStore.state.username;
if (note.value.creator === username) return true;
return note.value.access.some((a) => a.name === username && a.can_edit);
return note.value.access.some((a) => (a.name === username || a.name === defaultAccessName) && a.can_edit);
});
const localShapenotes = computed(() =>
Expand Down Expand Up @@ -108,9 +110,9 @@ watchEffect(() => {
// and that defaultAccess is provided even if it has no DB value
const accessLevels = computed(() => {
const access = [];
let defaultAccess = { name: "default", can_view: false, can_edit: false };
let defaultAccess = { name: defaultAccessName, can_view: false, can_edit: false };
for (const a of note.value?.access ?? []) {
if (a.name === "default") defaultAccess = a;
if (a.name === defaultAccessName) defaultAccess = a;
else access.push(a);
}
return [defaultAccess, ...access];
Expand Down Expand Up @@ -278,7 +280,7 @@ function removeShape(shape: LocalId): void {
<input type="checkbox" :checked="access.can_view" @click="setViewAccess(access, $event)" />
<input type="checkbox" :checked="access.can_edit" @click="setEditAccess(access, $event)" />
<font-awesome-icon
v-if="access.name !== 'default'"
v-if="access.name !== defaultAccessName"
icon="trash-alt"
title="Remove access"
@click="noteSystem.removeAccess(note!.uuid, access.name, true)"
Expand Down

0 comments on commit f3d3ae9

Please sign in to comment.