mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 22:41:27 +00:00
Merge pull request #2207 from pixelfed/staging
Added New Post notification to Timeline
This commit is contained in:
commit
77fc307d1a
5 changed files with 84 additions and 4 deletions
|
@ -6,6 +6,7 @@
|
|||
- Custom content warnings for remote posts ([6afc61a4](https://github.com/pixelfed/pixelfed/commit/6afc61a4))
|
||||
- Thai translations ([74cd536](https://github.com/pixelfed/pixelfed/commit/74cd536))
|
||||
- Added Bookmarks to v1 api ([99cb48c5](https://github.com/pixelfed/pixelfed/commit/99cb48c5))
|
||||
- Added New Post notification to Timeline ([a0e7c4d5](https://github.com/pixelfed/pixelfed/commit/a0e7c4d5))
|
||||
|
||||
### Updated
|
||||
- Updated PostComponent, fix remote urls ([42716ccc](https://github.com/pixelfed/pixelfed/commit/42716ccc))
|
||||
|
|
BIN
public/js/timeline.js
vendored
BIN
public/js/timeline.js
vendored
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,11 @@
|
|||
<template>
|
||||
<div class="container" style="">
|
||||
<div v-if="layout === 'feed'" class="row">
|
||||
<div v-if="morePostsAvailable == true" class="col-12 mt-5 pt-3 mb-3 fixed-top">
|
||||
<p class="text-center">
|
||||
<button class="btn btn-dark px-4 rounded-pill font-weight-bold shadow" @click="syncNewPosts">Load New Posts</button>
|
||||
</p>
|
||||
</div>
|
||||
<div :class="[modes.distractionFree ? 'col-md-8 col-lg-8 offset-md-2 px-0 mb-sm-3 timeline order-2 order-md-1':'col-md-8 col-lg-8 px-0 mb-sm-3 timeline order-2 order-md-1']">
|
||||
<div v-if="config.features.stories">
|
||||
<story-component v-if="config.features.stories"></story-component>
|
||||
|
@ -74,7 +79,7 @@
|
|||
</div>
|
||||
|
||||
<div class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
|
||||
<div v-if="!modes.distractionFree" class="card-header d-inline-flex align-items-center bg-white">
|
||||
<div v-if="!modes.distractionFree && status" class="card-header d-inline-flex align-items-center bg-white">
|
||||
<img v-bind:src="status.account.avatar" width="38px" height="38px" class="cursor-pointer" style="border-radius: 38px;" @click="profileUrl(status)" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=2'">
|
||||
<!-- <div v-if="hasStory" class="has-story has-story-sm cursor-pointer shadow-sm" @click="profileUrl(status)">
|
||||
<img class="rounded-circle box-shadow" :src="status.account.avatar" width="32px" height="32px" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=2'">
|
||||
|
@ -628,6 +633,12 @@
|
|||
ctxEmbedShowCaption: true,
|
||||
ctxEmbedShowLikes: false,
|
||||
ctxEmbedCompactMode: false,
|
||||
morePostsAvailable: false,
|
||||
mpCount: 0,
|
||||
mpData: false,
|
||||
mpInterval: 15000,
|
||||
mpEnabled: false,
|
||||
mpPoller: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -761,6 +772,7 @@
|
|||
this.fetchHashtagPosts();
|
||||
}
|
||||
// this.fetchStories();
|
||||
this.rtw();
|
||||
}).catch(err => {
|
||||
swal(
|
||||
'Oops, something went wrong',
|
||||
|
@ -1488,7 +1500,66 @@
|
|||
.then(res => {
|
||||
this.userStory = res.data;
|
||||
})
|
||||
},
|
||||
|
||||
// real time watcher
|
||||
rtw() {
|
||||
this.mpPoller = setInterval(() => {
|
||||
let apiUrl = false;
|
||||
this.mpCount++;
|
||||
if(this.mpCount > 10) {
|
||||
this.mpInterval = 30000;
|
||||
}
|
||||
if(this.mpCount > 50) {
|
||||
this.mpInterval = (5 * 60 * 1000);
|
||||
}
|
||||
switch(this.scope) {
|
||||
case 'home':
|
||||
apiUrl = '/api/pixelfed/v1/timelines/home';
|
||||
break;
|
||||
|
||||
case 'local':
|
||||
apiUrl = '/api/pixelfed/v1/timelines/public';
|
||||
break;
|
||||
|
||||
case 'network':
|
||||
apiUrl = '/api/pixelfed/v1/timelines/network';
|
||||
break;
|
||||
}
|
||||
axios.get(apiUrl, {
|
||||
params: {
|
||||
max_id: 0,
|
||||
limit: 20
|
||||
}
|
||||
}).then(res => {
|
||||
let self = this;
|
||||
let data = res.data.filter(d => {
|
||||
return d.id > self.min_id
|
||||
});
|
||||
let ids = data.map(status => status.id);
|
||||
let max = Math.max(...ids).toString();
|
||||
let newer = max > this.min_id;
|
||||
if(newer) {
|
||||
this.morePostsAvailable = true;
|
||||
this.mpData = data;
|
||||
}
|
||||
});
|
||||
}, this.mpInterval);
|
||||
},
|
||||
|
||||
syncNewPosts() {
|
||||
let self = this;
|
||||
let data = this.mpData;
|
||||
let ids = data.map(s => s.id);
|
||||
this.min_id = Math.max(...ids).toString();
|
||||
this.max_id = Math.min(...ids).toString();
|
||||
this.feed.unshift(...data);
|
||||
this.morePostsAvailable = false;
|
||||
this.mpData = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
clearInterval(this.mpInterval);
|
||||
},
|
||||
}
|
||||
</script>
|
|
@ -2,14 +2,22 @@
|
|||
|
||||
@section('content')
|
||||
|
||||
<timeline scope="local" layout="feed"></timeline>
|
||||
|
||||
<noscript>
|
||||
<div class="container">
|
||||
<p class="pt-5 text-center lead">Please enable javascript to view this content.</p>
|
||||
</div>
|
||||
</noscript>
|
||||
|
||||
<timeline scope="local" layout="feed"></timeline>
|
||||
|
||||
<div class="modal pr-0" tabindex="-1" role="dialog" id="composeModal">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<compose-modal></compose-modal>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
|
|
Loading…
Reference in a new issue