2018-02-15 03:33:34 -06:00
|
|
|
<template>
|
2021-04-15 22:17:22 -05:00
|
|
|
<MkContainer :max-height="300" :foldable="true">
|
2021-04-20 09:22:59 -05:00
|
|
|
<template #header><i class="fas fa-image" style="margin-right: 0.5em;"></i>{{ $ts.images }}</template>
|
2020-11-25 06:31:34 -06:00
|
|
|
<div class="ujigsodd">
|
|
|
|
<MkLoading v-if="fetching"/>
|
2021-11-19 04:36:12 -06:00
|
|
|
<div v-if="!fetching && images.length > 0" class="stream">
|
2020-11-25 06:31:34 -06:00
|
|
|
<MkA v-for="image in images"
|
2021-11-19 04:36:12 -06:00
|
|
|
:key="image.id"
|
2020-11-25 06:31:34 -06:00
|
|
|
class="img"
|
|
|
|
:to="notePage(image.note)"
|
2021-04-15 22:06:54 -05:00
|
|
|
>
|
|
|
|
<ImgWithBlurhash :hash="image.blurhash" :src="thumbnail(image.file)" :alt="image.name" :title="image.name"/>
|
|
|
|
</MkA>
|
2020-11-25 06:31:34 -06:00
|
|
|
</div>
|
2021-11-19 04:36:12 -06:00
|
|
|
<p v-if="!fetching && images.length == 0" class="empty">{{ $ts.nothing }}</p>
|
2018-02-15 03:33:34 -06:00
|
|
|
</div>
|
2020-11-25 06:31:34 -06:00
|
|
|
</MkContainer>
|
2018-02-15 03:33:34 -06:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 06:12:00 -05:00
|
|
|
import { defineComponent } from 'vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import { getStaticImageUrl } from '@/scripts/get-static-image-url';
|
2021-11-28 05:29:37 -06:00
|
|
|
import { notePage } from '@/filters/note';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as os from '@/os';
|
|
|
|
import MkContainer from '@/components/ui/container.vue';
|
|
|
|
import ImgWithBlurhash from '@/components/img-with-blurhash.vue';
|
2018-03-27 02:51:12 -05:00
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
export default defineComponent({
|
2020-11-25 06:31:34 -06:00
|
|
|
components: {
|
|
|
|
MkContainer,
|
2021-04-15 22:06:54 -05:00
|
|
|
ImgWithBlurhash,
|
2020-11-25 06:31:34 -06:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
user: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
2018-02-15 03:33:34 -06:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: true,
|
2020-11-25 06:31:34 -06:00
|
|
|
images: [],
|
2018-02-15 03:33:34 -06:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2018-12-18 15:04:59 -06:00
|
|
|
const image = [
|
|
|
|
'image/jpeg',
|
|
|
|
'image/png',
|
2019-07-04 00:45:28 -05:00
|
|
|
'image/gif',
|
|
|
|
'image/apng',
|
|
|
|
'image/vnd.mozilla.apng',
|
2018-12-18 15:04:59 -06:00
|
|
|
];
|
2020-10-17 06:12:00 -05:00
|
|
|
os.api('users/notes', {
|
2018-03-29 00:48:47 -05:00
|
|
|
userId: this.user.id,
|
2018-12-18 15:04:59 -06:00
|
|
|
fileType: image,
|
2020-12-18 19:55:52 -06:00
|
|
|
excludeNsfw: this.$store.state.nsfw !== 'ignore',
|
2021-04-15 19:41:56 -05:00
|
|
|
limit: 10,
|
2018-04-07 12:30:37 -05:00
|
|
|
}).then(notes => {
|
2018-12-11 05:36:55 -06:00
|
|
|
for (const note of notes) {
|
2019-04-08 02:34:45 -05:00
|
|
|
for (const file of note.files) {
|
2021-04-15 19:41:56 -05:00
|
|
|
this.images.push({
|
|
|
|
note,
|
|
|
|
file
|
|
|
|
});
|
2018-12-11 05:36:55 -06:00
|
|
|
}
|
|
|
|
}
|
2018-02-19 08:37:09 -06:00
|
|
|
this.fetching = false;
|
2018-02-15 03:33:34 -06:00
|
|
|
});
|
2019-02-04 15:22:39 -06:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
thumbnail(image: any): string {
|
2020-12-18 19:55:52 -06:00
|
|
|
return this.$store.state.disableShowingAnimatedImages
|
2019-02-04 15:22:39 -06:00
|
|
|
? getStaticImageUrl(image.thumbnailUrl)
|
|
|
|
: image.thumbnailUrl;
|
|
|
|
},
|
2020-10-17 06:12:00 -05:00
|
|
|
notePage
|
2019-02-04 15:22:39 -06:00
|
|
|
},
|
2018-02-15 03:33:34 -06:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.ujigsodd {
|
2020-11-25 06:31:34 -06:00
|
|
|
padding: 8px;
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
> .stream {
|
2021-04-15 19:41:56 -05:00
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
|
|
|
grid-gap: 6px;
|
2018-02-15 03:33:34 -06:00
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
> .img {
|
2021-04-15 19:41:56 -05:00
|
|
|
height: 128px;
|
2020-10-17 06:12:00 -05:00
|
|
|
border-radius: 6px;
|
2021-04-15 22:06:54 -05:00
|
|
|
overflow: clip;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
}
|
2018-02-15 03:33:34 -06:00
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
> .empty {
|
|
|
|
margin: 0;
|
|
|
|
padding: 16px;
|
|
|
|
text-align: center;
|
2018-02-15 03:33:34 -06:00
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
> i {
|
|
|
|
margin-right: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-15 03:33:34 -06:00
|
|
|
</style>
|