Skip to content

Commit

Permalink
Add vibrations
Browse files Browse the repository at this point in the history
  • Loading branch information
LitoMore committed Apr 24, 2020
1 parent 9e132f3 commit ad612d9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/components/feeds-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,13 @@ function load (page, url, para) {

page.setData({feeds_arr: [result]}, () => {
if (isTimeline(url)) {
vibrate()
let withTimelineAudio = false
try {
const [latestRawId] = result.map(item => item.rawid)
withTimelineAudio = latestRawId > lastRawId
} catch (_) {}

if (withTimelineAudio) {
vibrate()
}

if (getSettings().timelineAudio && withTimelineAudio) {
audio.bubble()
}
Expand All @@ -117,15 +114,22 @@ function load (page, url, para) {
}

function isTimeline (url) {
console.log(url)
switch (url || '/statuses/home_timeline') {
case '/statuses/home_timeline':
case '/statuses/user_timeline':
case '/photos/user_timeline':
case '/statuses/public_timeline':
case '/statuses/mentions':
case '/search/public_timeline':
case '/statuses/friends_timeline':
case '/statuses/replies':
case '/search/user_timeline':
case '/favorites':
case '/users/friends':
case '/users/followers':
case '/direct_messages/conversation_list':
case '/direct_messages/conversation':
return true
default:
return false
Expand Down Expand Up @@ -199,12 +203,11 @@ function favoriteChange (page) {
for (const [feedIndex, feed] of feeds.entries()) {
if (feed.id === page.data.feed.id) {
pagePre.setData({[`feeds_arr[${feedsIndex}][${feedIndex}].favorited`]: false})
vibrate()
return
}
}
}

vibrate()
})
.catch(err => showModal(err.errMsg))
} else {
Expand All @@ -221,12 +224,11 @@ function favoriteChange (page) {
for (const [feedIndex, feed] of feeds.entries()) {
if (feed.id === page.data.feed.id) {
pagePre.setData({[`feeds_arr[${feedsIndex}][${feedIndex}].favorited`]: true})
vibrate()
return
}
}
}

vibrate()
})
.catch(err => showModal(err.errMsg))
}
Expand All @@ -250,12 +252,11 @@ function destroy (id) {
page.setData({
[`feeds_arr[${feedsIndex}]`]: page.data.feeds_arr[feedsIndex]
})
vibrate()
return
}
}
}

vibrate()
}
})
})
Expand All @@ -273,12 +274,11 @@ function destroyForTest (id) {
page.setData({
[`feeds_arr[${feedsIndex}]`]: page.data.feeds_arr[feedsIndex]
})
vibrate()
return
}
}
}

vibrate()
})
.catch(err => showModal(err.errMsg))
}
Expand All @@ -298,12 +298,11 @@ function destroyMessage (page, id) {
page.setData({
[`feeds_arr[${feedsIndex}]`]: page.data.feeds_arr[feedsIndex]
})
vibrate()
return
}
}
}

vibrate()
})
.catch(err => showModal(err.errMsg))
}
Expand Down
4 changes: 4 additions & 0 deletions src/mixins/post.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fm = require('../components/feeds-manager')
const i18n = require('../i18n/index')
const animations = require('../utils/animations')
const vibrate = require('../utils/vibrate')

module.exports = {
data: {
Expand Down Expand Up @@ -28,6 +29,7 @@ module.exports = {
this.setData({
resetPop: animations.pop().export()
}, () => {
vibrate()
setTimeout(() => {
this.setData({
param: null,
Expand All @@ -42,6 +44,7 @@ module.exports = {
this.setData({
addPhotoPop: animations.pop().export()
}, () => {
vibrate()
setTimeout(() => {
const page = this
wx.chooseImage({
Expand All @@ -57,6 +60,7 @@ module.exports = {
})
},
addGif () {
vibrate()
const page = this
wx.chooseImage({
count: 1,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/feed/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const post = require('../../mixins/post')
const tap = require('../../mixins/tap')
const i18n = require('../../i18n/index')
const util = require('../../utils/util')
const vibrate = require('../../utils/vibrate')

Page(extend({}, tap, post, {
data: {
Expand Down Expand Up @@ -37,6 +38,7 @@ Page(extend({}, tap, post, {
sendPop: null
}, () => {
setTimeout(() => {
vibrate()
this.setData({
param: {
status,
Expand All @@ -57,6 +59,7 @@ Page(extend({}, tap, post, {
sendPop: null
}, () => {
setTimeout(() => {
vibrate()
this.setData({
param: {
status,
Expand Down
2 changes: 2 additions & 0 deletions src/pages/message/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const animations = require('../../utils/animations')
const post = require('../../mixins/post')
const i18n = require('../../i18n/index')
const util = require('../../utils/util')
const vibrate = require('../../vibrate')

const url = '/direct_messages/conversation'

Expand Down Expand Up @@ -32,6 +33,7 @@ Page(extend({}, post, {
sendPop: null
}, () => {
setTimeout(() => {
vibrate()
if (!this.data.relationship.followed_by) {
wx.showModal({
confirmColor: '#33a5ff',
Expand Down

0 comments on commit ad612d9

Please sign in to comment.