Skip to content

Commit

Permalink
feat: Add username label on shared photos
Browse files Browse the repository at this point in the history
Fixes pulsejet#955

Signed-off-by: Jo Van Bulck <jo.vanbulck@cs.kuleuven.be>
  • Loading branch information
jovanbulck committed Aug 11, 2024
1 parent a773471 commit 34efe7d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/Db/TimelineQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class TimelineQuery
'f.etag', 'f.name AS basename',
'f.size', 'm.epoch', // auid
'mimetypes.mimetype',
'm.owner',
];

protected ?TimelineRoot $_root = null; // cache
Expand Down
5 changes: 5 additions & 0 deletions lib/Db/TimelineQueryDays.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use OCA\Memories\ClustersBackend;
use OCA\Memories\Exif;
use OCA\Memories\Settings\SystemConfig;
use OCA\Memories\Util;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;

Expand Down Expand Up @@ -315,6 +316,10 @@ private function postProcessDayPhoto(array &$row, bool $monthView = false): void
unset($row['liveid']);
}

if ($row['owner'] === Util::getUID()) {
unset($row['owner']);
}

// Favorite field, may not be present
if ($row['categoryid'] ?? null) {
$row['isfavorite'] = 1;
Expand Down
2 changes: 2 additions & 0 deletions lib/Db/TimelineWrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function processFile(
// Get parameters
$mtime = $file->getMtime();
$fileId = $file->getId();
$owner = $file->getOwner()?->getUID();
$isvideo = Index::isVideo($file);

// Get previous row
Expand Down Expand Up @@ -172,6 +173,7 @@ public function processFile(
'orphan' => $query->createNamedParameter(false, IQueryBuilder::PARAM_BOOL),
'buid' => $query->createNamedParameter($buid, IQueryBuilder::PARAM_STR),
'parent' => $query->createNamedParameter($file->getParent()->getId(), IQueryBuilder::PARAM_INT),
'owner' => $query->createNamedParameter($owner, IQueryBuilder::PARAM_STR),
];

// There is no easy way to UPSERT in standard SQL
Expand Down
31 changes: 30 additions & 1 deletion src/components/frame/Photo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@
</div>
</div>

<div class="flag bottom-left">
<div class="flag bottom-right">
<StarIcon :size="22" v-if="data.flag & c.FLAG_IS_FAVORITE" />
<LocalIcon :size="22" v-if="data.flag & c.FLAG_IS_LOCAL" />
</div>

<div class="flag bottom-left">
<AccountMultipleIcon :size="22" v-if="data.owner" />
<span class="username" v-if="data.owner" >{{ owner }}</span>
</div>

<div
class="img-outer fill-block"
:class="{ 'memories-livephoto': data.liveid }"
Expand Down Expand Up @@ -81,6 +86,9 @@ import StarIcon from 'vue-material-design-icons/Star.vue';
import VideoIcon from 'vue-material-design-icons/PlayCircleOutline.vue';
import LocalIcon from 'vue-material-design-icons/CloudOff.vue';
import RawIcon from 'vue-material-design-icons/Raw.vue';
import AccountMultipleIcon from 'vue-material-design-icons/AccountMultiple.vue'
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
import type { IDay, IPhoto } from '@typings';
import type XImg from '@components/XImg.vue';
Expand All @@ -96,6 +104,7 @@ export default defineComponent({
StarIcon,
LocalIcon,
RawIcon,
AccountMultipleIcon
},
props: {
Expand Down Expand Up @@ -173,6 +182,13 @@ export default defineComponent({
return null;
},
owner(): string | null {
console.log("data is: ");
console.log(this.data);
return this.data.owner || null;
},
videoUrl(): string | null {
if (this.data.liveid) {
return utils.getLivePhotoVideoUrl(this.data, true);
Expand Down Expand Up @@ -414,6 +430,19 @@ $icon-size: $icon-half-size * 2;
}
}
&.bottom-right {
bottom: var(--icon-dist);
right: var(--icon-dist);
.p-outer.selected > & {
transform: translate($icon-size, -$icon-size);
}
}
> .username {
font-size: 0.75em;
margin-left: 3px;
}
> .video {
display: flex;
line-height: 22px; // force text height to match
Expand Down
2 changes: 2 additions & 0 deletions src/typings/data.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ declare module '@typings' {

/** Stacked RAW photos */
stackraw?: IPhoto[];

owner?: string;
};

export interface IImageInfo {
Expand Down

0 comments on commit 34efe7d

Please sign in to comment.